@metarouter/react-native-sdk 1.1.1 → 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.
@@ -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.1",
3
+ "version": "1.1.2",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "exports": {