Skip to content

Use different write keys for an already initialized Analytics instance #360

@sidbhar

Description

@sidbhar

Is your feature request related to a problem? Please describe.
We have 2 different sources set up for sending unauthenticated vs. authenticated events. It's set up this way so we can limit damage, in case the keys are compromised. If user is signed out, events are sent to the unauthenticated source. Once the user signs in, we initialize another instance of Analytics with the appropriate write keys, and send events to the authenticated source. The unauthenticated Analytics instance is killed. This causes some issues with 2 different device_ids being created for each instance and identity merge not happening correctly (we're forwarding to Mixpanel with the simplified API).

Describe the solution you'd like
It would be great if we only had to initialize Analytics once, but could change the write key based on the user's state (signed out/in).

Describe alternatives you've considered
We could consider generating the device_id ourselves and setting it to be the same value explicitly for each instance of Analytics (and resetting it when the user signs out)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions