@bytem/bytem-tracker-app 0.0.12 → 0.0.13
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/dist/package.json +2 -4
- package/dist/src/BytemTracker.js +2 -0
- package/dist/src/core/device.js +3 -32
- package/dist/test/BytemTracker.test.js +11 -0
- package/dist/test/setup.js +1 -1
- package/package.json +2 -4
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytem/bytem-tracker-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Bytem Tracker SDK for React Native",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"uuid": "^9.0.0",
|
|
33
|
-
"@react-native-async-storage/async-storage": "^1.19.0"
|
|
34
|
-
"react-native-device-info": "^10.8.0"
|
|
33
|
+
"@react-native-async-storage/async-storage": "^1.19.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@react-native-async-storage/async-storage": "^1.19.0",
|
|
@@ -43,7 +42,6 @@
|
|
|
43
42
|
"jest": "^30.2.0",
|
|
44
43
|
"react": "18.2.0",
|
|
45
44
|
"react-native": "0.72.0",
|
|
46
|
-
"react-native-device-info": "^10.8.0",
|
|
47
45
|
"ts-jest": "^29.4.6",
|
|
48
46
|
"typescript": "^5.0.0"
|
|
49
47
|
},
|
package/dist/src/BytemTracker.js
CHANGED
|
@@ -726,6 +726,7 @@ class BytemTracker {
|
|
|
726
726
|
async getSystemInfo() {
|
|
727
727
|
try {
|
|
728
728
|
const info = await (0, device_1.getDeviceInfo)();
|
|
729
|
+
const deviceId = await this.getRealDeviceId();
|
|
729
730
|
return {
|
|
730
731
|
platform: info.platform,
|
|
731
732
|
os: info.os,
|
|
@@ -737,6 +738,7 @@ class BytemTracker {
|
|
|
737
738
|
sdk_version: this.SDK_VERSION,
|
|
738
739
|
app_key: this.appKey,
|
|
739
740
|
visitor_id: this.visitorId,
|
|
741
|
+
device_id: deviceId,
|
|
740
742
|
device_id_type: this.deviceIdType,
|
|
741
743
|
api_path: this.apiPath,
|
|
742
744
|
base_url: this.baseUrl,
|
package/dist/src/core/device.js
CHANGED
|
@@ -4,36 +4,10 @@ exports.generateUUID = exports.getDeviceInfo = void 0;
|
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
5
|
const getDeviceInfo = async () => {
|
|
6
6
|
var _a, _b, _c;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const os = react_native_1.Platform.OS;
|
|
8
|
+
const osVersion = String(react_native_1.Platform.Version);
|
|
9
9
|
let model = 'unknown';
|
|
10
10
|
let userAgent = `BytemTracker/${react_native_1.Platform.OS}`;
|
|
11
|
-
try {
|
|
12
|
-
// Safely attempt to get native device info
|
|
13
|
-
// Use require() dynamically to avoid top-level import crashes in environments like Expo Go
|
|
14
|
-
// where react-native-device-info native module is not linked.
|
|
15
|
-
const mod = require('react-native-device-info');
|
|
16
|
-
const RNDeviceInfo = mod.default || mod;
|
|
17
|
-
if (RNDeviceInfo) {
|
|
18
|
-
if (typeof RNDeviceInfo.getSystemName === 'function') {
|
|
19
|
-
os = RNDeviceInfo.getSystemName();
|
|
20
|
-
}
|
|
21
|
-
if (typeof RNDeviceInfo.getSystemVersion === 'function') {
|
|
22
|
-
osVersion = RNDeviceInfo.getSystemVersion();
|
|
23
|
-
}
|
|
24
|
-
if (typeof RNDeviceInfo.getModel === 'function') {
|
|
25
|
-
model = RNDeviceInfo.getModel();
|
|
26
|
-
}
|
|
27
|
-
if (typeof RNDeviceInfo.getUserAgent === 'function') {
|
|
28
|
-
userAgent = await RNDeviceInfo.getUserAgent();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
// Native module missing or failed, keep default values
|
|
34
|
-
// console.warn('[BytemTracker] Native device info not available (lazy load failed).');
|
|
35
|
-
}
|
|
36
|
-
// Try to get language
|
|
37
11
|
let language = 'en';
|
|
38
12
|
try {
|
|
39
13
|
if (react_native_1.Platform.OS === 'ios') {
|
|
@@ -44,9 +18,7 @@ const getDeviceInfo = async () => {
|
|
|
44
18
|
language = ((_c = react_native_1.NativeModules.I18nManager) === null || _c === void 0 ? void 0 : _c.localeIdentifier) || 'en';
|
|
45
19
|
}
|
|
46
20
|
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
// Ignore language detection errors
|
|
49
|
-
}
|
|
21
|
+
catch (e) { }
|
|
50
22
|
const { width, height } = react_native_1.Dimensions.get('window');
|
|
51
23
|
return {
|
|
52
24
|
platform: react_native_1.Platform.OS,
|
|
@@ -61,7 +33,6 @@ const getDeviceInfo = async () => {
|
|
|
61
33
|
};
|
|
62
34
|
exports.getDeviceInfo = getDeviceInfo;
|
|
63
35
|
const generateUUID = () => {
|
|
64
|
-
// Simple UUID v4 generator that doesn't require crypto polyfills
|
|
65
36
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
66
37
|
const r = (Math.random() * 16) | 0;
|
|
67
38
|
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
@@ -298,4 +298,15 @@ describe('BytemTracker SDK', () => {
|
|
|
298
298
|
});
|
|
299
299
|
});
|
|
300
300
|
});
|
|
301
|
+
describe('System Info', () => {
|
|
302
|
+
beforeEach(async () => {
|
|
303
|
+
await BytemTracker_1.default.init(mockConfig);
|
|
304
|
+
});
|
|
305
|
+
it('should return system info with device_id', async () => {
|
|
306
|
+
const info = await BytemTracker_1.default.getSystemInfo();
|
|
307
|
+
expect(info.device_id).toBeDefined();
|
|
308
|
+
expect(typeof info.device_id).toBe('string');
|
|
309
|
+
expect(info.app_key).toBe(mockConfig.appId);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
301
312
|
});
|
package/dist/test/setup.js
CHANGED
|
@@ -25,7 +25,7 @@ jest.mock('react-native-device-info', () => ({
|
|
|
25
25
|
getSystemVersion: jest.fn(() => '14.0'),
|
|
26
26
|
getModel: jest.fn(() => 'iPhone 11'),
|
|
27
27
|
getUserAgent: jest.fn(() => Promise.resolve('Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)')),
|
|
28
|
-
}));
|
|
28
|
+
}), { virtual: true });
|
|
29
29
|
// Mock React Native
|
|
30
30
|
jest.mock('react-native', () => ({
|
|
31
31
|
Platform: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytem/bytem-tracker-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Bytem Tracker SDK for React Native",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"uuid": "^9.0.0",
|
|
33
|
-
"@react-native-async-storage/async-storage": "^1.19.0"
|
|
34
|
-
"react-native-device-info": "^10.8.0"
|
|
33
|
+
"@react-native-async-storage/async-storage": "^1.19.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@react-native-async-storage/async-storage": "^1.19.0",
|
|
@@ -43,7 +42,6 @@
|
|
|
43
42
|
"jest": "^30.2.0",
|
|
44
43
|
"react": "18.2.0",
|
|
45
44
|
"react-native": "0.72.0",
|
|
46
|
-
"react-native-device-info": "^10.8.0",
|
|
47
45
|
"ts-jest": "^29.4.6",
|
|
48
46
|
"typescript": "^5.0.0"
|
|
49
47
|
},
|