🪟 🐛 Remove reinitialization of AnalyticsService #19304
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.