-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: edge sdks should send events to bulk/environment endpoint #256
Conversation
This pull request has been linked to Shortcut Story #214758: Send events to environment endpoint for edge sdks. |
I still need to test this PR in a real application but based on existing js sdk code, this PR should work. |
I am not sure about this. The events that can be generated from a client SDK are not 100% the same. So I do not know how the endpoints for a client SDK handle the data. The server-side SDKs, which these are, generate prerequisite record events. Would the client SDK endpoint for events handle those correctly? If we have a definitive answer, then I can see pursuing it. |
Secondarily it appears these changes break many contract tests, so some investigation is need there. |
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.
Need to investigate the event test failures in the contract tests.
@kinyoklion Thank you for your feedback. I submitted this PR having done due diligence checking the event recorder logic how it handles events for server and client sdks. My investigation reveals both the /bulk and /events/bulk/{envId} endpoints are handled equally by the postBulkEvents handler. You'll see this postBulkEvents contain the RecordRequest logic you are concerned with so I think this is covered for both server and client sdks. I understand your concerns though and you want us to be thorough with this kind of hybrid logic because we never had to mix the two before. The edge sdks are unique in this way, it is truly somewhat of a hybrid. This approach opens the door for the future for such sdks so I'm hopeful this works. I will assign someone from the events pipeline to review my work. I will investigate the contract tests failures, I suspect they are related to the |
Added @samstokes as reviewer from the Events pipeline team. |
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.
LGTM from an event pipeline standpoint. (Leaving it to the SDK team to do the approving.)
Re:
The events that can be generated from a client SDK are not 100% the same. So I do not know how the endpoints for a client SDK handle the data.
I can confirm that both endpoints behave identically in terms of what event payloads they will accept. e.g. even though only browser SDKs generate click
events, the /bulk
endpoint that handles server-side SDK payloads will happily accept a click
event. It all goes into the same Kinesis stream :)
Re the specific concern about prerequisite events:
The server-side SDKs, which these are, generate prerequisite record events. Would the client SDK endpoint for events handle those correctly? If we have a definitive answer, then I can see pursuing it.
I don't think anything in our event pipeline does anything special with prerequisites. Definitely the events endpoint handlers don't.
(AFAIK there's nothing special about prerequisite events, right - they're just regular evaluation events? And the only special consideration is that client-side SDKs don't send them.
Thanks @samstokes ! I have improved the code to provide a better distinction between sdkKey and clientSideID. |
@ldhenry pls re-review when able. Thank you |
Yep we can try querying cmetrics directly following these instructions. |
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.
Nothing to add, just commenting so GitHub will stop reminding me about this PR. If there's anything that does need my feedback please feel free to "re-request review".
@ldhenry @kinyoklion I resolved conflicts and made minor updates and added unit tests. Please re-review. Thank you. Tested with the example app and verified in the UI. |
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 .
@ldhenry please approve so this can be merged. Thank you. |
🤖 I have created a release *beep* *boop* --- <details><summary>@launchdarkly/akamai-edgeworker-sdk-common: 1.0.3</summary> ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from ^2.0.2 to ^2.1.0 </details> <details><summary>@launchdarkly/akamai-server-base-sdk: 2.0.3</summary> ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/akamai-edgeworker-sdk-common bumped from ^1.0.2 to ^1.0.3 * @launchdarkly/js-server-sdk-common bumped from ^2.0.2 to ^2.1.0 </details> <details><summary>@launchdarkly/akamai-server-edgekv-sdk: 1.0.11</summary> ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/akamai-edgeworker-sdk-common bumped from ^1.0.2 to ^1.0.3 * @launchdarkly/js-server-sdk-common bumped from ^2.0.2 to ^2.1.0 </details> <details><summary>cloudflare-server-sdk: 2.3.0</summary> ## [2.3.0](cloudflare-server-sdk-v2.2.3...cloudflare-server-sdk-v2.3.0) (2023-11-14) ### Features * edge sdks should send events to bulk/environment endpoint ([#256](#256)) ([f45910f](f45910f)) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-server-sdk-common-edge bumped from 2.0.2 to 2.1.0 </details> <details><summary>js-sdk-common: 2.1.0</summary> ## [2.1.0](js-sdk-common-v2.0.0...js-sdk-common-v2.1.0) (2023-11-14) ### Features * edge sdks should send events to bulk/environment endpoint ([#256](#256)) ([f45910f](f45910f)) </details> <details><summary>js-server-sdk-common: 2.1.0</summary> ## [2.1.0](js-server-sdk-common-v2.0.2...js-server-sdk-common-v2.1.0) (2023-11-14) ### Features * edge sdks should send events to bulk/environment endpoint ([#256](#256)) ([f45910f](f45910f)) ### Bug Fixes * Better handle waiting for initialization for failure cases. ([#314](#314)) ([16515df](16515df)), closes [#312](#312) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-sdk-common bumped from 2.0.0 to 2.1.0 </details> <details><summary>js-server-sdk-common-edge: 2.1.0</summary> ## [2.1.0](js-server-sdk-common-edge-v2.0.2...js-server-sdk-common-edge-v2.1.0) (2023-11-14) ### Features * edge sdks should send events to bulk/environment endpoint ([#256](#256)) ([f45910f](f45910f)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.0.2 to 2.1.0 </details> <details><summary>@launchdarkly/node-server-sdk: 9.0.3</summary> ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.0.2 to 2.1.0 </details> <details><summary>@launchdarkly/node-server-sdk-dynamodb: 6.0.3</summary> ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.0.2 to 9.0.3 </details> <details><summary>@launchdarkly/node-server-sdk-redis: 4.0.3</summary> ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.0.2 to 9.0.3 </details> <details><summary>vercel-server-sdk: 1.2.0</summary> ## [1.2.0](vercel-server-sdk-v1.1.7...vercel-server-sdk-v1.2.0) (2023-11-14) ### Features * Support analytics events in the vercel SDK. ([#316](#316)) ([cc41db4](cc41db4)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common-edge bumped from 2.0.2 to 2.1.0 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Ryan Lamb <[email protected]>
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.