-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into yus/sc-214758/send-events-to-environment-end…
…point-for-edge
- Loading branch information
Showing
35 changed files
with
291 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"packages/shared/common": "1.1.0", | ||
"packages/shared/sdk-server": "1.2.2", | ||
"packages/sdk/server-node": "8.2.3", | ||
"packages/sdk/cloudflare": "2.1.3", | ||
"packages/shared/sdk-server-edge": "1.0.12", | ||
"packages/sdk/vercel": "1.1.3", | ||
"packages/sdk/akamai-base": "1.0.6", | ||
"packages/sdk/akamai-edgekv": "1.0.6", | ||
"packages/shared/akamai-edgeworker-sdk": "0.3.3", | ||
"packages/store/node-server-sdk-dynamodb": "5.0.10", | ||
"packages/store/node-server-sdk-redis": "3.0.10" | ||
"packages/shared/sdk-server": "1.2.3", | ||
"packages/sdk/server-node": "8.2.4", | ||
"packages/sdk/cloudflare": "2.2.0", | ||
"packages/shared/sdk-server-edge": "1.0.13", | ||
"packages/sdk/vercel": "1.1.4", | ||
"packages/sdk/akamai-base": "1.0.7", | ||
"packages/sdk/akamai-edgekv": "1.0.7", | ||
"packages/shared/akamai-edgeworker-sdk": "0.3.4", | ||
"packages/store/node-server-sdk-dynamodb": "5.0.11", | ||
"packages/store/node-server-sdk-redis": "3.0.11" | ||
} |
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"module": "./dist/index.mjs", | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@launchdarkly/cloudflare-server-sdk": "^2.0.2" | ||
"@launchdarkly/cloudflare-server-sdk": "^2.1.4" | ||
}, | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20230321.0", | ||
|
@@ -17,14 +17,13 @@ | |
"prettier": "^2.6.2", | ||
"ts-jest": "^28.0.3", | ||
"typescript": "5.1.6", | ||
"wrangler": "2.13.0" | ||
"wrangler": "2.20.1" | ||
}, | ||
"scripts": { | ||
"build": "yarn && yarn link-dev && node build.js", | ||
"build": "node build.js", | ||
"start": "wrangler dev", | ||
"deploy": "wrangler publish", | ||
"test": "yarn build && node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js", | ||
"clean": "rm -rf dist && rm -rf node_modules && rm -rf .yarn/cache && yarn build", | ||
"link-dev": "cd ../../../../ && yarn link-dev" | ||
"test": "yarn build && jest", | ||
"clean": "rm -rf dist && rm -rf node_modules && rm -rf .yarn/cache && yarn build" | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,15 +1,22 @@ | ||
import app from './index'; | ||
import testData from './testData.json'; | ||
|
||
test('variation true', async () => { | ||
// arrange | ||
const env = getMiniflareBindings(); | ||
const { LD_KV } = env; | ||
await LD_KV.put('LD-Env-test-sdk-key', JSON.stringify(testData)); | ||
describe('test', () => { | ||
let env: Bindings; | ||
|
||
// act | ||
const res = await app.fetch(new Request('http://localhost'), env); | ||
beforeEach(async () => { | ||
env = getMiniflareBindings(); | ||
const { LD_KV } = env; | ||
await LD_KV.put('LD-Env-test-sdk-key', JSON.stringify(testData)); | ||
}); | ||
|
||
// assert | ||
expect(await res.text()).toContain('testFlag1: true'); | ||
test('variation true', async () => { | ||
const res = await app.fetch(new Request('http://localhost/?email=truemail'), env); | ||
expect(await res.text()).toContain('testFlag1: true'); | ||
}); | ||
|
||
test('variation false', async () => { | ||
const res = await app.fetch(new Request('http://localhost/?email=falsemail'), env); | ||
expect(await res.text()).toContain('testFlag1: false'); | ||
}); | ||
}); |
This file contains 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 |
---|---|---|
|
@@ -11,7 +11,11 @@ const handler: ExportedHandler<Bindings> = { | |
): Promise<Response> { | ||
const clientSideID = 'client-side-id'; | ||
const flagKey = 'testFlag1'; | ||
const context = { kind: 'org', key: 'org-key-cf', email: '[email protected]' }; | ||
const { searchParams } = new URL(request.url); | ||
|
||
// falsemail will return false, other emails return true | ||
const email = searchParams.get('email') ?? '[email protected]'; | ||
const context = { kind: 'user', key: 'test-user-key-1', email }; | ||
|
||
// start using ld | ||
const client = initLD(clientSideID, env.LD_KV, { sendEvents: true }); | ||
|
This file contains 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 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 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,53 @@ | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import json from '@rollup/plugin-json'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import terser from '@rollup/plugin-terser'; | ||
import dts from 'rollup-plugin-dts'; | ||
import esbuild from 'rollup-plugin-esbuild'; | ||
import filesize from 'rollup-plugin-filesize'; | ||
|
||
const inputPath = 'src/index.ts'; | ||
const cjsPath = 'dist/cjs/index.js'; | ||
const esmPath = 'dist/esm/index.js'; | ||
const typingsPath = 'dist/index.d.ts'; | ||
|
||
const plugins = [resolve(), commonjs(), esbuild(), json(), terser(), filesize()]; | ||
|
||
// the second array item is a function to include all js-core packages in the bundle so they | ||
// are not imported or required as separate npm packages | ||
const external = [/node_modules/, (id: string) => !id.includes('js-core')]; | ||
|
||
export default [ | ||
{ | ||
input: inputPath, | ||
output: [ | ||
{ | ||
file: cjsPath, | ||
format: 'cjs', | ||
sourcemap: true, | ||
}, | ||
], | ||
plugins, | ||
external, | ||
}, | ||
{ | ||
input: inputPath, | ||
output: [ | ||
{ | ||
file: esmPath, | ||
format: 'esm', | ||
sourcemap: true, | ||
}, | ||
], | ||
plugins, | ||
external, | ||
}, | ||
{ | ||
input: inputPath, | ||
plugins: [dts(), json()], | ||
output: { | ||
file: typingsPath, | ||
format: 'esm', | ||
}, | ||
}, | ||
]; |
This file contains 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 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 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
Oops, something went wrong.