-
Notifications
You must be signed in to change notification settings - Fork 149
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
fix(analytics): segment not passing context to mixpanel #5662
Conversation
WalkthroughThe updates involve two main changes. First, the Changes
Sequence Diagram(s)No sequence diagrams are necessary for these changes since they primarily involve minor enhancements and cleanup of existing functionality rather than introducing new features or altering control flows. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
c150686
to
5c6b463
Compare
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.
payload.obj.context.ip = '0.0.0.0'; | ||
payload.obj.properties = payload.obj.properties || {}; | ||
payload.obj.properties[key] = value; |
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.
Consider privacy implications and potential data overwriting.
Setting the IP address to '0.0.0.0' might be intended to anonymize users, but it's important to document why this specific value is used to avoid confusion. Additionally, directly modifying payload.obj.properties
might overwrite existing properties. Consider merging properties instead of assigning them directly to ensure data integrity.
- payload.obj.properties[key] = value;
+ payload.obj.properties = { ...payload.obj.properties, [key]: value };
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
payload.obj.context.ip = '0.0.0.0'; | |
payload.obj.properties = payload.obj.properties || {}; | |
payload.obj.properties[key] = value; | |
payload.obj.context.ip = '0.0.0.0'; | |
payload.obj.properties = payload.obj.properties || {}; | |
payload.obj.properties = { ...payload.obj.properties, [key]: value }; |
Are events currently getting reported to Segment aka Mixpanel without any properties at all? Or just some missing? |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/app/common/persistence.ts (2 hunks)
Additional comments not posted (2)
src/app/common/persistence.ts (2)
20-20
: Assess the impact of removingqueryCache
configuration.The removal of
queryCache
configuration fromqueryClient
initialization simplifies the setup. However, verify that all functionalities previously handled byqueryCache
, especially error handling, are still effectively managed.
2-2
: Verify the removal ofQueryCache
.The removal of
QueryCache
from imports suggests it's no longer used. Ensure that there are no lingering references toQueryCache
elsewhere in the codebase that could lead to runtime errors.Verification successful
Verified the removal of
QueryCache
.The
QueryCache
is no longer referenced in the codebase, ensuring that its removal from the imports does not lead to any runtime errors.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that there are no references to `QueryCache` in the codebase. # Test: Search for `QueryCache` usage. Expect: No occurrences. rg --type python 'QueryCache'Length of output: 60
Script:
#!/bin/bash # Description: Verify that there are no references to `QueryCache` in the codebase. # Test: Search for `QueryCache` usage. Expect: No occurrences. rg --type ts 'QueryCache'Length of output: 69
Script:
#!/bin/bash # Description: Inspect the usage of `QueryCache` in `src/app/debug.ts`. # Test: Show lines around the reference to `QueryCache` for context. rg --type ts 'QueryCache' -A 5 -B 5 src/app/debug.tsLength of output: 363
Script:
#!/bin/bash # Description: Inspect the usage of `QueryCache` within the `clearReactQueryCache` function in `src/app/debug.ts`. # Test: Search for `QueryCache` within the `clearReactQueryCache` function. rg 'clearReactQueryCache' -A 10 src/app/debug.ts | rg 'QueryCache'Length of output: 91
In some earlier changes, I refactored Analytics such that there's a single mechanism to track events.
Segment's analytics library has two concepts:
I followed these concepts, tracking global metadata such as the app version number as general event context. However, it appears this doesn't enter Mixpanel in the way expected, meaning events appear without the properties they had before.
As this negatively impacts our dashboard, I've changed this to be reported as properties, not context.
Summary by CodeRabbit
Bug Fixes
ip
to '0.0.0.0' and ensuringproperties
are initialized correctly.Refactor
QueryClient
by removing unnecessaryqueryCache
configuration.