launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
79 stars 67 forks source link

No events sent for Insights if not using camelCaseKeys #180

Closed ajmers closed 1 year ago

ajmers commented 1 year ago

Describe the bug If using the React SDK with camelCaseKeys: false, it is impossible to get events sent for event tracking/insights.

https://github.com/launchdarkly/react-client-sdk/blob/12ac400d100129aafc2d3d9199e681b1ee4a3889/src/getFlagsProxy.ts#L63 If camelCaseKeys is false, this flagKeyMap will be empty and thus we never get to line 71 of the same file, where ldClient.variation is called. Per a conversation with Launchdarkly support, it's necessary to call ldClient.variation in order to get any events for Insights.

To reproduce Instantiate Launchdarkly client with camelCaseKeys set to false: const provider = withLDProvider({ clientSideID: ${id}, user: { key: "anonymous", name: "anonymous", anonymous: false }, reactOptions: { useCamelCaseFlagKeys: false, }, });

Use flag in code and check Network Tab for events sent to events.launchdarkly.com/events/bulk/ (there will be none). Then change useCamelCaseFlagKeys to true and notice that events are sent.

Expected behavior It should be possible to not use camelCaseKeys and still have events sent to the events API.

Logs If applicable, add any log output related to your problem.

SDK version 2.29.2

yusinto commented 1 year ago

Thank you for reporting this and submitting the pr for the fix #181. We are in process of reviewing the pr and will update this issue soon.

yusinto commented 1 year ago

This has been fixed in 3.0.3.