Skip to content

Commit d987110

Browse files
authored
Merge pull request #5688 from segmentio/bcaudillo-patch-6
Grab the anonymousId with npm library
2 parents e29b424 + 5d86fab commit d987110

File tree

1 file changed

+5
-0
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+5
-0
lines changed

src/connections/sources/catalog/libraries/website/javascript/identity.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ analytics.user().anonymousId();
4545

4646
If the user's `anonymousId` is `null` (meaning not set) when you call this function, Analytics.js automatically generated and sets a new `anonymousId` for the user.
4747

48+
If you are using the npm library, the previous call returns a promise for `user()`. As a workaround, you'll need to grab the user's current `anonymousId` in the following way:
49+
50+
```js
51+
analytics.instance?.user().anonymousId()
52+
```
4853
4954
### Refreshing the Anonymous ID
5055

0 commit comments

Comments
 (0)