From d4dc7b88e29859fdce3650734f9a04cffd3d3f74 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 27 Mar 2026 15:27:15 -0500 Subject: [PATCH] fix(web): decode JSON-stringified ajs_anonymous_id from localStorage (#196) 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. --- packages/core/lib/utils/store/web.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/core/lib/utils/store/web.dart b/packages/core/lib/utils/store/web.dart index a90b27e..59ea72c 100644 --- a/packages/core/lib/utils/store/web.dart +++ b/packages/core/lib/utils/store/web.dart @@ -89,6 +89,16 @@ class StoreImpl implements Store { } } } + + if (anonymousId != null) { + try { + final decoded = json.decode(anonymousId); + if (decoded is String) { + anonymousId = decoded; + } + } catch (_) {} + } + return anonymousId ?? ''; } }