-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: edge sdks should send events to bulk/environment endpoint #256
Merged
yusinto
merged 25 commits into
main
from
yus/sc-214758/send-events-to-environment-endpoint-for-edge
Nov 12, 2023
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a2dbfe4
feat: implement useEnvironmentEndpoint logic by inspecting the sdk-ke…
cada2f6
fix: broken tests.
37bdbf4
fix: wrong events path for clientSideID
cfbc545
fix: added shell directive. added link-dev for cloudflare/example to …
2874194
chore: remove debug statements.
8bcd58a
Merge branch 'main' into yus/sc-214758/send-events-to-environment-end…
yusinto 1908227
chore: better support for event sender analytics paths (#259)
yusinto 11cb96a
chore: rollback unit test sdk- prefix changes.
yusinto a3d3132
chor: add comments
yusinto 429e92a
Update packages/shared/sdk-server-edge/src/api/LDClient.ts
yusinto 4741775
Merge branch 'main' into yus/sc-214758/send-events-to-environment-end…
f871209
chore: add release-please alpha config.
37ebde7
Update release-please-config.json
ad7d012
chore: flush events in waitUntil. improved handler types.
yusinto 303e3ae
Merge branch 'main' into yus/sc-214758/send-events-to-environment-end…
yusinto 44c8044
fix: remove link-dev and use yarn workspaces.
yusinto 2abeb13
fix: unit tests due to missing ctx. update jest version.
yusinto 8f1ad45
chore: fix flush callback arg types.
yusinto 8b5c0d9
fix: close client to fix jest open handle warnings
yusinto 6cb2165
Merge branch 'main' into yus/sc-214758/send-events-to-environment-end…
yusinto aae16d8
chore: resolve conflicts.
yusinto 2acad70
chore: in cloudflare example, rename sdkKey to clientSideID.
yusinto 5da020e
chore: added unit tests for edge sdk.
yusinto 474cdf7
chore: update cloudflare sdk dep version
yusinto 55bf9af
chore: set test data trackEvents to true
yusinto 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 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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the Vercel and/or Akamai examples also need to be updated? I initially thought this change only applied to Cloudflare because only the Cloudflare example was changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those examples can be updated, but not necessary. I'll leave that to @ldhenry .