@metarouter/react-native-sdk 1.1.4 → 1.1.5
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.
- package/lib/analytics/init.d.ts +1 -1
- package/lib/analytics/init.d.ts.map +1 -1
- package/lib/analytics/init.js +25 -37
- package/package.json +1 -1
package/lib/analytics/init.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { InitOptions, AnalyticsInterface } from "./types";
|
|
2
|
-
export declare function createAnalyticsClient(options: InitOptions):
|
|
2
|
+
export declare function createAnalyticsClient(options: InitOptions): AnalyticsInterface;
|
|
3
3
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/analytics/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK/D,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/analytics/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK/D,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GACnB,kBAAkB,CAwBpB"}
|
package/lib/analytics/init.js
CHANGED
|
@@ -1,41 +1,29 @@
|
|
|
1
1
|
import { MetaRouterAnalyticsClient } from "./MetaRouterAnalyticsClient";
|
|
2
2
|
import { proxyClient, setRealClient } from "./proxy/proxyClient";
|
|
3
|
-
//
|
|
4
|
-
let
|
|
5
|
-
export
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setRealClient(null, { dropPending: true }); // proxy goes idle; calls will queue or no-op
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
// 3) Bind the proxy to this fully-initialized client
|
|
31
|
-
setRealClient(boundClient);
|
|
32
|
-
// 4) Return the proxy as the single public handle
|
|
33
|
-
return proxyClient;
|
|
34
|
-
})();
|
|
35
|
-
try {
|
|
36
|
-
return await inFlight;
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
inFlight = null;
|
|
3
|
+
// Only one initialization in flight
|
|
4
|
+
let initPromise = null;
|
|
5
|
+
export function createAnalyticsClient(options) {
|
|
6
|
+
if (!initPromise) {
|
|
7
|
+
initPromise = (async () => {
|
|
8
|
+
const instance = new MetaRouterAnalyticsClient(options);
|
|
9
|
+
await instance.init();
|
|
10
|
+
const boundClient = {
|
|
11
|
+
track: (event, props) => instance.track(event, props),
|
|
12
|
+
identify: (userId, traits) => instance.identify(userId, traits),
|
|
13
|
+
group: (groupId, traits) => instance.group(groupId, traits),
|
|
14
|
+
screen: (name, props) => instance.screen(name, props),
|
|
15
|
+
page: (name, props) => instance.page(name, props),
|
|
16
|
+
alias: (newUserId) => instance.alias(newUserId),
|
|
17
|
+
enableDebugLogging: () => instance.enableDebugLogging(),
|
|
18
|
+
getDebugInfo: () => instance.getDebugInfo(),
|
|
19
|
+
flush: () => instance.flush(),
|
|
20
|
+
reset: async () => {
|
|
21
|
+
await instance.reset();
|
|
22
|
+
setRealClient(null, { dropPending: true });
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
setRealClient(boundClient);
|
|
26
|
+
})();
|
|
40
27
|
}
|
|
28
|
+
return proxyClient;
|
|
41
29
|
}
|