segmentio / analytics-next

Segment Analytics.js 2.0
https://segment.com/docs/connections/sources/catalog/libraries/website/javascript
MIT License
385 stars 128 forks source link

Support loading analytics into a custom global variable when using snippet version 5.2.1 or later #1032

Closed zikaari closed 5 months ago

zikaari commented 5 months ago

Fixes #1014

Please refer to the original issue for more information

Docs for this feature - https://github.com/segmentio/segment-docs/pull/5949

changeset-bot[bot] commented 5 months ago

🦋 Changeset detected

Latest commit: d6caafac71ebf1b418b50cceb9dda8bc3aae8a15

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------------- | ----- | | @segment/analytics-next | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

silesky commented 5 months ago

@chrisradek should we get it out of the way and link to our segment doc update PR here, so it doesn't get lost in the fray?

zikaari commented 5 months ago

My docs PR was 1:1 replica of Seth's PR. Where do I explain the usage of this feature?

chrisradek commented 5 months ago

My docs PR was 1:1 replica of https://github.com/segmentio/segment-docs/pull/5754. Where do I explain the usage of this feature?

Do we currently explain anywhere in the docs that you can change the variable used to install analytics? I originally thought you also had to use the globalAnalyticsKey with this feature - but looking at your test looks like that's probably not the case. So might make sense to add another section to Segment Docs on using something other than window.analytics for snippet users.

zikaari commented 5 months ago

Will add a section to the javascript, what do you think should the section be titled? "Installing Analytics under custom namespace"?

chrisradek commented 5 months ago

"Installing Analytics under custom namespace"

I think something like that is fine. We can always update it as well, just want to make sure we are documenting our changes - we've not always been great about that historically.

zikaari commented 5 months ago

Docs are here - https://github.com/segmentio/segment-docs/pull/5949