Support for multiple write keys.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, typescript
- Domain
- analytics
Research direction
Start with the linked reproduction, using public/index.html and src/index.tsx to load both analytics-next instances with separate write keys. Reload the application and inspect requests to the p endpoint while only the window.analytics instance sends a page event. Done means concurrent loading no longer produces a request from the other instance.
Written by the indexing model from the issue text.
Description
Hello,
We were led to believe that it is possible to run two instances of analytics-next with different write keys side by side. One via segment source snippet (exposed on window.analytics) and the other one as an npm module.
When we try to do this, it mostly works with one quirk/bug. If the two instances are loading concurrently (which is the common scenario), it can happen that events fired via window.analytics (segment source snippet) cause two network requests - one using the segment source snippet write key and the other one using npm module's source key. Once both instances are finished loading they behave as expected with each only firing network requests for its own events.
We were speculating that this is due to the fact that window.analytics as provided by snippet creates a queueing implementation of methods (to be used before the analytics-next is fully loaded) and then somehow snippet and npm module versions both read and fire events on that queue. Not sure if this is actually the case - it's just a guess.
I assembled a small sample application that demonstrates the issue. It loads analytics-next from both snippet and npm module, but only fires a page event on the snippet version. If you reload the page several times, you should see examples of that single page event causing two requests to be sent to a p endpoint. See:

You will of course need to provide your own write keys here and here.
Using multiple instances of analytics with different write keys seems to have been something that was "advertised" as a feature, and when talking to our Segment representative they said that this should be possible with analytics-next as well.
Thanks for any help or further info.
- Dominant language
- TypeScript
- Stars
- 478
- Forks
- 161
- Avg merge
- 6h 19m
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from segmentio/analytics-next
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
segmentio/analytics-next#1324 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
segmentio/analytics-next#1366 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
segmentio/analytics-next#1338 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
segmentio/analytics-next#1337 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
segmentio/analytics-next#1332 ·
All issues in segmentio/analytics-next
Similar issues
-
bug cli service
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
create-element: same editorAlias silent-fallback bug as #201, not covered by that fixPossibly taken A pull request linked to this issue is open or already merged. Opengenerated-by-ai
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
umbraco/Umbraco-CMS-MCP-Editor#208 · 1 comment ·
Maintainers usually reply within 1 day
-
Table: Space fires onActivate in single-selection mode — the reference doc and the JSDoc disagreeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sidorares/react-x11-components#764 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
backnotprop/plannotator#1840 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JoviDeCroock/pracht#432 ·
Maintainers usually reply within 1 day