Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
only copy flags if buffer is not empty
  • Loading branch information
billyvg committed Nov 20, 2024
commit 4195a8e8c7e24c240b7e559558991738fb8dbc0e
4 changes: 4 additions & 0 deletions packages/browser/src/utils/featureFlags.ts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine we'll want to use this in node/server environments as well, would it make sense to move these to core?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the handler being used in the LD integration is only available for client-side js, that's why this was moved to the browser. Not sure if this will change for other integrations in the future

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in these util functions are specific to LD integration, it stores flag values to scope. It's possible for a server side implementation to re-use these functions.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export function copyFlagsFromScopeToEvent(event: Event): Event {
const flagContext = scope.getScopeData().contexts.flags;
const flagBuffer = flagContext ? flagContext.values : [];

if (!flagBuffer.length) {
return event;
}

if (event.contexts === undefined) {
event.contexts = {};
}
Expand Down
Loading