@metarouter/react-native-sdk 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityManager.d.ts","sourceRoot":"","sources":["../../src/analytics/IdentityManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG1D;;;;;;GAMG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB;;;KAGC;IACK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"IdentityManager.d.ts","sourceRoot":"","sources":["../../src/analytics/IdentityManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG1D;;;;;;GAMG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB;;;KAGC;IACK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB3B;;;OAGG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM;IAU7B;;;OAGG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM;IAU3B;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS;IAI/B;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS;IAIhC;;;;OAIG;IACH,eAAe,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,CAAC,GAAG,iBAAiB;IASpE;;;OAGG;IACG,KAAK;CAaZ"}
|
|
@@ -17,15 +17,23 @@ export class IdentityManager {
|
|
|
17
17
|
*/
|
|
18
18
|
async init() {
|
|
19
19
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const storedAnonId = await getIdentityField(ANONYMOUS_ID_KEY);
|
|
21
|
+
if (!storedAnonId) {
|
|
22
|
+
const newId = `anon-${Date.now()}-${Math.random().toString(36).substring(2, 10)}`;
|
|
23
|
+
await setIdentityField(ANONYMOUS_ID_KEY, newId);
|
|
24
|
+
this.anonymousId = newId;
|
|
25
|
+
log('Generated and stored new anonymous ID:', newId);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.anonymousId = storedAnonId;
|
|
29
|
+
log('Loaded stored anonymous ID:', storedAnonId);
|
|
30
|
+
}
|
|
22
31
|
this.userId = await getIdentityField(USER_ID_KEY) || undefined;
|
|
23
32
|
this.groupId = await getIdentityField(GROUP_ID_KEY) || undefined;
|
|
24
33
|
log('IdentityManager initialized with anonymous ID:', this.anonymousId, 'userId:', this.userId, 'groupId:', this.groupId);
|
|
25
34
|
}
|
|
26
35
|
catch (error) {
|
|
27
36
|
warn('Failed to initialize IdentityManager, using fallback anonymous ID', error);
|
|
28
|
-
// Fallback: generate a temporary anonymous ID
|
|
29
37
|
this.anonymousId = `fallback-${Date.now()}-${Math.random().toString(36).substring(2, 10)}`;
|
|
30
38
|
log('Using fallback anonymous ID:', this.anonymousId);
|
|
31
39
|
}
|