Skip to content

Commit 0f3e21e

Browse files
authored
fix(web): decode JSON-stringified ajs_anonymous_id from localStorage (#196) (#197)
analytics.js stores ajs_anonymous_id as a JSON-encoded string, wrapping the UUID in surrounding double-quote characters. getExistingAnonymousId() read the raw value without decoding, causing identity mismatches between the JS and Flutter SDKs.
1 parent efc6cd4 commit 0f3e21e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎packages/core/lib/utils/store/web.dart‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ class StoreImpl implements Store {
8989
}
9090
}
9191
}
92+
93+
if (anonymousId != null) {
94+
try {
95+
final decoded = json.decode(anonymousId);
96+
if (decoded is String) {
97+
anonymousId = decoded;
98+
}
99+
} catch (_) {}
100+
}
101+
92102
return anonymousId ?? '';
93103
}
94104
}

0 commit comments

Comments
 (0)