analytics-next icon indicating copy to clipboard operation
analytics-next copied to clipboard

User.anonymousId() returns an object instead of an ID

Open disaacson opened this issue 2 years ago • 2 comments

The anonymousId method of User https://github.com/segmentio/analytics-next/blob/40745ffe649556195405118d0f33e81d8e7c3b14/packages/browser/src/core/user/index.ts#L432 has a return type of ID (type ID = string | null | undefined), but is returning the following object instead image

disaacson avatar May 10 '23 02:05 disaacson

It looks like the anonymousId is currently accessed via user.anonymousId().event.id in that object.

disaacson avatar May 10 '23 15:05 disaacson

I tried it in a new incognito browser and the anonymousId() method is now returning a string. It looks like the behavior above is state dependent. FWIW - I had previously tried to call alias. Perhaps that triggered the code path that resulted in the state above?

disaacson avatar May 11 '23 14:05 disaacson