@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextInfo.d.ts","sourceRoot":"","sources":["../../../src/analytics/utils/contextInfo.ts"],"names":[],"mappings":"
|
|
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 {
|
|
2
|
-
import
|
|
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(
|
|
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
|
|
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 =
|
|
26
|
-
if (typeof Intl !==
|
|
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:
|
|
33
|
-
version: (_b = pkg.version) !== null && _b !== void 0 ? _b :
|
|
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 :
|
|
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 :
|
|
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 :
|
|
41
|
-
type: ((_j = DeviceInfo === null || DeviceInfo === void 0 ? void 0 : DeviceInfo.getSystemName) === null || _j === void 0 ? void 0 : _j.call(DeviceInfo)) ===
|
|
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 :
|
|
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 :
|
|
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 :
|
|
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 :
|
|
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 :
|
|
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 :
|
|
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
|
|
55
|
-
height
|
|
56
|
-
density
|
|
58
|
+
width,
|
|
59
|
+
height,
|
|
60
|
+
density,
|
|
57
61
|
},
|
|
58
62
|
network: {
|
|
59
|
-
wifi: (
|
|
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;
|