@metarouter/react-native-sdk 1.1.0 → 1.1.2

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.
@@ -8,7 +8,6 @@ import { InitOptions } from "./types";
8
8
  */
9
9
  export declare class MetaRouterAnalyticsClient {
10
10
  private initialized;
11
- private initPromise;
12
11
  private queue;
13
12
  private flushIntervalMs;
14
13
  private flushTimer;
@@ -29,11 +28,6 @@ export declare class MetaRouterAnalyticsClient {
29
28
  * @returns A promise that resolves when the client is initialized.
30
29
  */
31
30
  private init;
32
- /**
33
- * Waits for the analytics client to be initialized.
34
- * @returns A promise that resolves when the client is initialized.
35
- */
36
- waitForInitialization(): Promise<void>;
37
31
  /**
38
32
  * Starts the flush loop.
39
33
  */
@@ -1 +1 @@
1
- {"version":3,"file":"MetaRouterAnalyticsClient.d.ts","sourceRoot":"","sources":["../../src/analytics/MetaRouterAnalyticsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,SAAS,CAAC;AAQlE;;;;;;GAMG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,oBAAoB,CAAwC;IACpE,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAM;IAE5C;;;OAGG;gBACS,OAAO,EAAE,WAAW;IAmChC;;;OAGG;YACW,IAAI;IA8BlB;;;OAGG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;I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;;;;;;;;;;IAkDX;;;;;;OAMG;IACH,KAAK;CAqBN"}
@@ -55,7 +55,7 @@ export class MetaRouterAnalyticsClient {
55
55
  : 10000;
56
56
  setDebugLogging((_a = options.debug) !== null && _a !== void 0 ? _a : false);
57
57
  this.identityManager = new IdentityManager();
58
- this.initPromise = this.init();
58
+ this.init();
59
59
  log("Analytics client constructor completed, initialization in progress...");
60
60
  }
61
61
  /**
@@ -86,13 +86,6 @@ export class MetaRouterAnalyticsClient {
86
86
  throw error;
87
87
  }
88
88
  }
89
- /**
90
- * Waits for the analytics client to be initialized.
91
- * @returns A promise that resolves when the client is initialized.
92
- */
93
- async waitForInitialization() {
94
- await this.initPromise;
95
- }
96
89
  /**
97
90
  * Starts the flush loop.
98
91
  */
@@ -5,5 +5,5 @@ import type { InitOptions, AnalyticsInterface } from "./types";
5
5
  * @param options Initialization options.
6
6
  * @returns A fully initialized analytics interface.
7
7
  */
8
- export declare function createAnalyticsClient(options: InitOptions): Promise<AnalyticsInterface>;
8
+ export declare function createAnalyticsClient(options: InitOptions): AnalyticsInterface;
9
9
  //# 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;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,kBAAkB,CAAC,CAwB7B"}
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;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GACnB,kBAAkB,CAuBpB"}
@@ -8,9 +8,8 @@ let proxyBound = false;
8
8
  * @param options Initialization options.
9
9
  * @returns A fully initialized analytics interface.
10
10
  */
11
- export async function createAnalyticsClient(options) {
11
+ export function createAnalyticsClient(options) {
12
12
  const instance = new MetaRouterAnalyticsClient(options);
13
- await instance.waitForInitialization();
14
13
  const analyticsInterface = {
15
14
  track: (event, props) => instance.track(event, props),
16
15
  identify: (userId, traits) => instance.identify(userId, traits),
@@ -1,4 +1,4 @@
1
- import { EventContext } from '../types';
1
+ import { EventContext } from "../types";
2
2
  /**
3
3
  * Gathers and caches device, app, and environment context information for analytics events.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"contextInfo.d.ts","sourceRoot":"","sources":["../../../src/analytics/utils/contextInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAWxC;;;;;;;;;GASG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC,CA2C5D"}
1
+ {"version":3,"file":"contextInfo.d.ts","sourceRoot":"","sources":["../../../src/analytics/utils/contextInfo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAWxC;;;;;;;;;GASG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC,CAiD5D"}
@@ -1,9 +1,10 @@
1
- import { getTimeZone } from './timezone';
2
- import pkg from '../../../package.json';
1
+ import { Dimensions, PixelRatio } from "react-native";
2
+ import { getTimeZone } from "./timezone";
3
+ import pkg from "../../../package.json";
3
4
  let cachedContext = null;
4
5
  let DeviceInfo = null;
5
6
  try {
6
- DeviceInfo = require('react-native-device-info');
7
+ DeviceInfo = require("react-native-device-info");
7
8
  }
8
9
  catch {
9
10
  DeviceInfo = null;
@@ -19,44 +20,47 @@ catch {
19
20
  * @returns {Promise<EventContext>} A promise that resolves to the context information object.
20
21
  */
21
22
  export async function getContextInfo() {
22
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
23
24
  if (cachedContext)
24
25
  return cachedContext;
25
- let locale = 'en-US';
26
- if (typeof Intl !== 'undefined' && typeof Intl.DateTimeFormat === 'function') {
26
+ let locale = "en-US";
27
+ if (typeof Intl !== "undefined" &&
28
+ typeof Intl.DateTimeFormat === "function") {
27
29
  const resolved = Intl.DateTimeFormat().resolvedOptions();
28
30
  locale = (_a = resolved.locale) !== null && _a !== void 0 ? _a : locale;
29
31
  }
32
+ const { width, height } = Dimensions.get("screen");
33
+ const density = Number(PixelRatio.get().toFixed(2));
30
34
  cachedContext = {
31
35
  library: {
32
- name: 'metarouter-react-native-sdk',
33
- version: (_b = pkg.version) !== null && _b !== void 0 ? _b : '0.0.0',
36
+ name: "metarouter-react-native-sdk",
37
+ version: (_b = pkg.version) !== null && _b !== void 0 ? _b : "0.0.0",
34
38
  },
35
39
  locale,
36
40
  timezone: getTimeZone(),
37
41
  device: {
38
- manufacturer: (_d = await ((_c = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getManufacturer) === null || _c === void 0 ? void 0 : _c.call(DeviceInfo))) !== null && _d !== void 0 ? _d : 'unknown',
39
- model: (_f = (_e = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getModel) === null || _e === void 0 ? void 0 : _e.call(DeviceInfo)) !== null && _f !== void 0 ? _f : 'unknown',
40
- name: (_h = await ((_g = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getDeviceName) === null || _g === void 0 ? void 0 : _g.call(DeviceInfo))) !== null && _h !== void 0 ? _h : 'unknown',
41
- type: ((_j = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getSystemName) === null || _j === void 0 ? void 0 : _j.call(DeviceInfo)) === 'Android' ? 'android' : 'ios',
42
+ manufacturer: (_d = (await ((_c = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getManufacturer) === null || _c === void 0 ? void 0 : _c.call(DeviceInfo)))) !== null && _d !== void 0 ? _d : "unknown",
43
+ model: (_f = (_e = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getModel) === null || _e === void 0 ? void 0 : _e.call(DeviceInfo)) !== null && _f !== void 0 ? _f : "unknown",
44
+ name: (_h = (await ((_g = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getDeviceName) === null || _g === void 0 ? void 0 : _g.call(DeviceInfo)))) !== null && _h !== void 0 ? _h : "unknown",
45
+ type: ((_j = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getSystemName) === null || _j === void 0 ? void 0 : _j.call(DeviceInfo)) === "Android" ? "android" : "ios",
42
46
  },
43
47
  os: {
44
- name: (_l = (_k = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getSystemName) === null || _k === void 0 ? void 0 : _k.call(DeviceInfo)) !== null && _l !== void 0 ? _l : 'unknown',
45
- version: (_o = (_m = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getSystemVersion) === null || _m === void 0 ? void 0 : _m.call(DeviceInfo)) !== null && _o !== void 0 ? _o : 'unknown',
48
+ name: (_l = (_k = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getSystemName) === null || _k === void 0 ? void 0 : _k.call(DeviceInfo)) !== null && _l !== void 0 ? _l : "unknown",
49
+ version: (_o = (_m = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getSystemVersion) === null || _m === void 0 ? void 0 : _m.call(DeviceInfo)) !== null && _o !== void 0 ? _o : "unknown",
46
50
  },
47
51
  app: {
48
- name: (_q = (_p = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getApplicationName) === null || _p === void 0 ? void 0 : _p.call(DeviceInfo)) !== null && _q !== void 0 ? _q : 'unknown',
49
- version: (_t = (_s = (_r = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getVersion) === null || _r === void 0 ? void 0 : _r.call(DeviceInfo)) !== null && _s !== void 0 ? _s : pkg.version) !== null && _t !== void 0 ? _t : 'unknown',
50
- build: (_v = (_u = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getBuildNumber) === null || _u === void 0 ? void 0 : _u.call(DeviceInfo)) !== null && _v !== void 0 ? _v : 'unknown',
51
- namespace: (_x = (_w = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getBundleId) === null || _w === void 0 ? void 0 : _w.call(DeviceInfo)) !== null && _x !== void 0 ? _x : 'unknown',
52
+ name: (_q = (_p = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getApplicationName) === null || _p === void 0 ? void 0 : _p.call(DeviceInfo)) !== null && _q !== void 0 ? _q : "unknown",
53
+ version: (_t = (_s = (_r = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getVersion) === null || _r === void 0 ? void 0 : _r.call(DeviceInfo)) !== null && _s !== void 0 ? _s : pkg.version) !== null && _t !== void 0 ? _t : "unknown",
54
+ build: (_v = (_u = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getBuildNumber) === null || _u === void 0 ? void 0 : _u.call(DeviceInfo)) !== null && _v !== void 0 ? _v : "unknown",
55
+ namespace: (_x = (_w = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getBundleId) === null || _w === void 0 ? void 0 : _w.call(DeviceInfo)) !== null && _x !== void 0 ? _x : "unknown",
52
56
  },
53
57
  screen: {
54
- width: (_z = (_y = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getScreenWidth) === null || _y === void 0 ? void 0 : _y.call(DeviceInfo)) !== null && _z !== void 0 ? _z : 0,
55
- height: (_1 = (_0 = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getScreenHeight) === null || _0 === void 0 ? void 0 : _0.call(DeviceInfo)) !== null && _1 !== void 0 ? _1 : 0,
56
- density: (_3 = (_2 = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getDensity) === null || _2 === void 0 ? void 0 : _2.call(DeviceInfo)) !== null && _3 !== void 0 ? _3 : 1,
58
+ width,
59
+ height,
60
+ density,
57
61
  },
58
62
  network: {
59
- wifi: (_5 = await ((_4 = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.isWifiEnabled) === null || _4 === void 0 ? void 0 : _4.call(DeviceInfo))) !== null && _5 !== void 0 ? _5 : false,
63
+ wifi: (_z = (await ((_y = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.isWifiEnabled) === null || _y === void 0 ? void 0 : _y.call(DeviceInfo)))) !== null && _z !== void 0 ? _z : false,
60
64
  },
61
65
  };
62
66
  return cachedContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metarouter/react-native-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "exports": {