segmentio / analytics_flutter

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

Prefer ajs_anonymous_id to userInfo #48

Closed QoLTech closed 8 months ago

QoLTech commented 9 months ago

Addresses the issue I'm having https://github.com/segmentio/analytics_flutter/issues/46.

If the file we're trying to grab from LocalStorage is userInfo, also try to grab the ajs_anonymous_id from LocalStorage. If it's not null, replace UserInfo.anonymousId with the value from the ajs_anonymous_id. 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.