-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
🪟 🐛 Remove reinitialization of AnalyticsService #19304
Conversation
@@ -29,11 +29,11 @@ export const useIntercom = (): IntercomContextValues => { | |||
useEffect(() => { | |||
intercomContextValues.update({ | |||
customAttributes: { | |||
workspace_id: analyticsContext.workspace_id, |
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.
ℹ️ This likely never worked, since there was no workspace_id
on that analytics context, but since it was also not typed it was never caught. Switched this to use the actual correct hook.
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 ✨ did not test locally
* Remvoe reinitialization of AnalyticsService * Change to ref * Make useCurrentWorkspaceId work globally * Fix workspace id
What
This cleans up the AnalyticsService to no longer reinitialize every time someone changes the context parameters on it.
We've noticed that in Segment a lot of the User.Create events are coming with
experiments
and - while not being able to reproduce fully - I suspect the issue here was, that as soon as we create a user/login we change the context, which itself will cause a newAnalyticsService
to be recreated, while though some components that haven't rerendered might still send their events to the old instance with the old context.Either way not recreating this class on every context change sounds like the better approach, so we should give this a try if it fixes our login problem.
I've validated that intercom still gets the correct workspace_id send as a property, as well as segment events still getting the right properties and they are changing correctly when e.g. changing workspace.