-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: edge sdks should send events to bulk/environment endpoint (#256)
Edge sdks use clientSideID not sdk-key. We should be able to post events to the eventsUri/bulk/clientSideID endpoint for edge sdks without needing to specify the sdk key in the authorization header. This is an alternate solution to #217. Both prs are attempting to enable events for edge sdks. Don't be alarmed with the filecount, it's mostly shell file fixes unrelated to this to include a directive which seems to be needed for local build. --------- Co-authored-by: LaunchDarklyReleaseBot <[email protected]>
- Loading branch information
Showing
20 changed files
with
202 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,13 @@ | |
"module": "./dist/index.mjs", | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@launchdarkly/cloudflare-server-sdk": "^2.1.4" | ||
"@launchdarkly/cloudflare-server-sdk": "2.2.3" | ||
}, | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20230321.0", | ||
"@types/jest": "^27.5.1", | ||
"@types/jest": "^29.5.5", | ||
"esbuild": "^0.14.41", | ||
"jest": "^28.1.0", | ||
"jest": "^29.7.0", | ||
"jest-environment-miniflare": "^2.5.0", | ||
"miniflare": "^2.5.0", | ||
"prettier": "^2.6.2", | ||
|
@@ -23,6 +23,7 @@ | |
"build": "node build.js", | ||
"start": "wrangler dev", | ||
"deploy": "wrangler publish", | ||
"test": "yarn build && jest" | ||
"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
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
15 changes: 15 additions & 0 deletions
15
packages/shared/common/src/internal/events/LDInternalOptions.ts
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,15 @@ | ||
/** | ||
* This is for internal use only. | ||
* | ||
* Edge sdks use clientSideID to query feature stores. They also send analytics | ||
* using this clientSideID. This is a hybrid behavior because they are based | ||
* on js-server-common, but uses the clientSideID instead of the sdkKey for the | ||
* above reasons. These internal options allow the edge sdks to use the | ||
* EventSender to send analytics to the correct LD endpoints using | ||
* the clientSideId. | ||
*/ | ||
export type LDInternalOptions = { | ||
analyticsEventPath?: string; | ||
diagnosticEventPath?: string; | ||
includeAuthorizationHeader?: boolean; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { internal } from '@launchdarkly/js-server-sdk-common'; | ||
import { basicPlatform } from '@launchdarkly/private-js-mocks'; | ||
|
||
import LDClient from './LDClient'; | ||
|
||
jest.mock('@launchdarkly/js-sdk-common', () => { | ||
const actual = jest.requireActual('@launchdarkly/js-sdk-common'); | ||
return { | ||
...actual, | ||
...{ | ||
internal: { | ||
...actual.internal, | ||
DiagnosticsManager: jest.fn(), | ||
EventProcessor: jest.fn(), | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
const mockEventProcessor = internal.EventProcessor as jest.Mock; | ||
describe('Edge LDClient', () => { | ||
it('uses clientSideID endpoints', async () => { | ||
const client = new LDClient('client-side-id', basicPlatform.info, { | ||
sendEvents: true, | ||
}); | ||
await client.waitForInitialization(); | ||
const passedConfig = mockEventProcessor.mock.calls[0][0]; | ||
|
||
expect(passedConfig).toMatchObject({ | ||
sendEvents: true, | ||
serviceEndpoints: { | ||
includeAuthorizationHeader: false, | ||
analyticsEventPath: '/events/bulk/client-side-id', | ||
diagnosticEventPath: '/events/diagnostic/client-side-id', | ||
events: 'https://events.launchdarkly.com', | ||
polling: 'https://sdk.launchdarkly.com', | ||
streaming: 'https://stream.launchdarkly.com', | ||
}, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.