segmentio / analytics_flutter

The hassle-free way to add Segment analytics to your Flutter app.
MIT License
26 stars 33 forks source link

Prefer ajs_anonymous_id from cookies to LocalStorage #47

Closed QoLTech closed 5 months ago

QoLTech commented 6 months ago

Addresses the issue I'm having here.

If the file we're trying to grab from LocalStorage is userInfo, also try to grab the browser cookies and parse out the "ajs_anonymous_id". If it's not null, replace LocalStorage.anonymousId with the value from the cookie. This allows us to keep our anonymousId tracking consistent across Analytics.js and analytics_flutter.

Your _readFromStorage is generic and I'm introducing changes specific to an individual file, so this probably isn't ideal, but it at least gives you a visualization what I'm trying to do.