-
Notifications
You must be signed in to change notification settings - Fork 85
[FSSDK-12107] refactor build system #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
raju-opti
wants to merge
10
commits into
master
Choose a base branch
from
raju/build_refacator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,855
−723
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
505d935
wip
raju-opti c85bdfb
updage
raju-opti 28acb1f
upd
raju-opti fb91a7c
add ts check
raju-opti ac0df81
upd
raju-opti f08c17a
upd
raju-opti db7453d
update
raju-opti 8bdf12c
updates
raju-opti 235839b
updates
raju-opti 749e806
cr
raju-opti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| node_modules/ | ||
| dist/ | ||
| *.log | ||
| .DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # TypeScript Example - Optimizely SDK | ||
|
|
||
| This example demonstrates all factory functions from the Optimizely SDK, including static and polling datafile managers. | ||
|
|
||
| ## Files | ||
|
|
||
| - `src/index.ts` - Main example demonstrating all SDK factory functions | ||
| - `datafile.json` - Test datafile with Optimizely configuration | ||
| - `datafile-server.js` - Simple HTTP server for testing polling datafile manager | ||
|
|
||
| ## Running the Example | ||
|
|
||
| ### From Project Root (Recommended) | ||
|
|
||
| Run from the project root to automatically build the SDK, create a tarball, and run the example: | ||
| ```bash | ||
| npm run test-typescript | ||
| ``` | ||
|
|
||
| This will: | ||
| 1. Install SDK dependencies | ||
| 2. Pack the SDK as a tarball (triggers build via `prepare` script) | ||
| 3. Install the tarball in this example | ||
| 4. Build and run the TypeScript example | ||
| 5. Start the datafile server automatically | ||
| 6. Clean up after completion | ||
|
|
||
| ### Manual Setup | ||
|
|
||
| ### 1. Start the Datafile Server (for polling manager test) | ||
|
|
||
| In a separate terminal, run: | ||
| ```bash | ||
| node datafile-server.js | ||
| ``` | ||
|
|
||
| This starts an HTTP server at `http://localhost:8910` that serves the `datafile.json` file. The polling project config manager will fetch updates from this server every 10 seconds. | ||
|
|
||
| ### 2. Run the Example | ||
|
|
||
| ```bash | ||
| npm start | ||
| ``` | ||
|
|
||
| ## What This Example Demonstrates | ||
|
|
||
| 1. **createStaticProjectConfigManager** - Creates a config manager with a static datafile | ||
| 2. **createInstance** - Creates an Optimizely client instance with the static config manager | ||
| 3. **createPollingProjectConfigManager** - Creates a config manager that polls for datafile updates from localhost:8910 | ||
| 4. **getSendBeaconEventDispatcher** - Gets the SendBeacon event dispatcher (Node.js returns undefined) | ||
| 5. **eventDispatcher** - Default event dispatcher | ||
| 6. **createForwardingEventProcessor** - Creates an event processor that forwards events immediately | ||
| 7. **createBatchEventProcessor** - Creates an event processor that batches events | ||
| 8. **createOdpManager** - Creates an Optimizely Data Platform manager | ||
| 9. **createVuidManager** - Creates a Visitor Unique ID manager | ||
|
|
||
| ## Test Datafile | ||
|
|
||
| The `datafile.json` contains a complete Optimizely configuration with: | ||
| - 2 feature flags (`flag_1`, `flag_2`) | ||
| - 4 experiments (`exp_1`, `exp_2`, `exp_3`, `exp_4`) | ||
| - 7 typed audiences based on age conditions | ||
| - 2 rollouts with delivery rules | ||
| - 1 integer variable (`integer_variable`) | ||
|
|
||
| This datafile is used for testing SDK functionality with realistic configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * Copyright 2026, Optimizely | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| /** | ||
| * Simple HTTP server to serve the datafile for testing polling project config manager | ||
| * Runs at http://localhost:PORT | ||
| */ | ||
|
|
||
| import http from 'http'; | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { dirname } from 'path'; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = dirname(__filename); | ||
|
|
||
| const PORT = 8910; | ||
| const datafilePath = path.join(__dirname, 'datafile.json'); | ||
|
|
||
| const server = http.createServer((req, res) => { | ||
| console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`); | ||
|
|
||
| // Read and serve the datafile | ||
| fs.readFile(datafilePath, 'utf8', (err, data) => { | ||
| if (err) { | ||
| console.error('Error reading datafile:', err); | ||
| res.writeHead(500, { 'Content-Type': 'application/json' }); | ||
| res.end(JSON.stringify({ error: 'Failed to read datafile' })); | ||
| return; | ||
| } | ||
|
|
||
| // Set CORS headers for cross-origin requests | ||
| res.writeHead(200, { | ||
| 'Content-Type': 'application/json', | ||
| 'Access-Control-Allow-Origin': '*', | ||
| 'Access-Control-Allow-Methods': 'GET, OPTIONS', | ||
| 'Access-Control-Allow-Headers': 'Content-Type' | ||
| }); | ||
|
|
||
| res.end(data); | ||
| }); | ||
| }); | ||
|
|
||
| server.listen(PORT, () => { | ||
| console.log(`\n=== Datafile Server Started ===`); | ||
| console.log(`Server running at http://localhost:${PORT}`); | ||
| console.log(`Serving datafile from: ${datafilePath}`); | ||
| console.log(`\nPress Ctrl+C to stop the server\n`); | ||
| }); | ||
|
|
||
| // Handle graceful shutdown | ||
| const shutdown = () => { | ||
| console.log('\n\nShutting down datafile server...'); | ||
| server.close(() => { | ||
| console.log('Server stopped'); | ||
| process.exit(0); | ||
| }); | ||
| }; | ||
|
|
||
| process.on('SIGINT', shutdown); | ||
| process.on('SIGTERM', shutdown); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.