segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
367 stars 191 forks source link

[Question] Relevant anonymous user id #1030

Open daniiltkach-ms opened 1 week ago

daniiltkach-ms commented 1 week ago

Hello guys, I suppose my issue is just a question.

Overview

So when we set explicitly anonymousId via client?.userInfo.set there is way to get this data from userInfo.get() method later.

client?.userInfo.set({
  anonymousId: userId,
  userId: undefined,
});

The issue is that when App is closed and opened again, the value from userInfo.get() is not same what is sets in the all events for segment. The value in the events is correct and it's equal to value what was saved there via client?.userInfo.set however the anonymousId from userInfo.get() is completely different each time when app is re-opened.

The question is Am I doing right to get this value anonymousId or there is an another method for recievening value of anonymousId ?

p.s. client?.userInfo.set is called only once (for the first opening of app).