@bytem/bytem-tracker-app 0.0.13 → 0.0.16
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/README.md +2 -2
- package/dist/package.json +1 -1
- package/dist/src/BytemTracker.js +1 -1
- package/dist/src/core/base.d.ts +1 -1
- package/dist/src/core/base.js +2 -2
- package/dist/src/types.d.ts +3 -3
- package/dist/test/BytemTracker.test.js +6 -6
- package/dist/test/debug.test.js +1 -1
- package/dist/test/network_error.test.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ This is the official Bytem Tracker SDK for React Native applications.
|
|
|
7
7
|
Install the package and its peer dependencies using Yarn:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
yarn add @bytem/bytem-tracker-app
|
|
10
|
+
yarn add @bytem/bytem-tracker-app react-native-device-info
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
### iOS Setup
|
|
@@ -29,7 +29,7 @@ const App = () => {
|
|
|
29
29
|
useEffect(() => {
|
|
30
30
|
const initTracker = async () => {
|
|
31
31
|
await BytemTracker.init({
|
|
32
|
-
|
|
32
|
+
appKey: 'your-app-key',
|
|
33
33
|
endpoint: 'https://api.bytem.com/track',
|
|
34
34
|
debug: __DEV__, // Enable debug logs in development
|
|
35
35
|
});
|
package/dist/package.json
CHANGED
package/dist/src/BytemTracker.js
CHANGED
package/dist/src/core/base.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { BaseParams } from '../types';
|
|
2
|
-
export declare const buildBaseRequestParams: (
|
|
2
|
+
export declare const buildBaseRequestParams: (appKey: string, visitorId: string) => Promise<BaseParams>;
|
package/dist/src/core/base.js
CHANGED
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildBaseRequestParams = void 0;
|
|
4
4
|
const device_1 = require("./device");
|
|
5
5
|
const session_1 = require("./session");
|
|
6
|
-
const buildBaseRequestParams = async (
|
|
6
|
+
const buildBaseRequestParams = async (appKey, visitorId) => {
|
|
7
7
|
const deviceInfo = await (0, device_1.getDeviceInfo)();
|
|
8
8
|
const sessionInfo = (0, session_1.getSessionInfo)();
|
|
9
9
|
return {
|
|
10
|
-
|
|
10
|
+
app_key: appKey,
|
|
11
11
|
device_id: visitorId,
|
|
12
12
|
session_id: sessionInfo ? sessionInfo.sessionId : '',
|
|
13
13
|
timestamp: Date.now(),
|
package/dist/src/types.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Configuration for initializing the BytemTracker.
|
|
3
3
|
*/
|
|
4
4
|
export interface TrackerConfig {
|
|
5
|
-
/** The unique application
|
|
6
|
-
|
|
5
|
+
/** The unique application Key provided by Bytem. */
|
|
6
|
+
appKey: string;
|
|
7
7
|
/** Custom endpoint URL for tracking requests. */
|
|
8
8
|
endpoint?: string;
|
|
9
9
|
/** Custom path for the API endpoint (default: '/i'). */
|
|
@@ -47,7 +47,7 @@ export interface SessionInfo {
|
|
|
47
47
|
startTime: number;
|
|
48
48
|
}
|
|
49
49
|
export interface BaseParams {
|
|
50
|
-
|
|
50
|
+
app_key: string;
|
|
51
51
|
device_id: string;
|
|
52
52
|
session_id: string;
|
|
53
53
|
timestamp: number;
|
|
@@ -9,7 +9,7 @@ const async_storage_1 = __importDefault(require("@react-native-async-storage/asy
|
|
|
9
9
|
const types_1 = require("../src/types");
|
|
10
10
|
describe('BytemTracker SDK', () => {
|
|
11
11
|
const mockConfig = {
|
|
12
|
-
|
|
12
|
+
appKey: 'test-app-id',
|
|
13
13
|
endpoint: 'https://api.example.com/track',
|
|
14
14
|
debug: true,
|
|
15
15
|
};
|
|
@@ -46,11 +46,11 @@ describe('BytemTracker SDK', () => {
|
|
|
46
46
|
// Verify Storage was checked for Visitor ID
|
|
47
47
|
expect(async_storage_1.default.getItem).toHaveBeenCalledWith(storage_1.StorageKeys.VISITOR_ID);
|
|
48
48
|
// Verify Session was initialized (checks storage)
|
|
49
|
-
expect(async_storage_1.default.getItem).toHaveBeenCalledWith(`${mockConfig.
|
|
49
|
+
expect(async_storage_1.default.getItem).toHaveBeenCalledWith(`${mockConfig.appKey}/cly_session`);
|
|
50
50
|
});
|
|
51
51
|
it('should use default endpoint when not provided', async () => {
|
|
52
52
|
await BytemTracker_1.default.init({
|
|
53
|
-
|
|
53
|
+
appKey: 'test-app-id',
|
|
54
54
|
// endpoint is omitted
|
|
55
55
|
debug: true,
|
|
56
56
|
});
|
|
@@ -63,7 +63,7 @@ describe('BytemTracker SDK', () => {
|
|
|
63
63
|
});
|
|
64
64
|
it('should override endpoint path when path is configured', async () => {
|
|
65
65
|
await BytemTracker_1.default.init({
|
|
66
|
-
|
|
66
|
+
appKey: 'test-app-id-2',
|
|
67
67
|
endpoint: 'https://api.example.com/track',
|
|
68
68
|
path: '/collect',
|
|
69
69
|
debug: true,
|
|
@@ -89,7 +89,7 @@ describe('BytemTracker SDK', () => {
|
|
|
89
89
|
expect(eventCall).toBeDefined();
|
|
90
90
|
const options = eventCall[1];
|
|
91
91
|
const body = options.body;
|
|
92
|
-
expect(body).toContain(`app_key=${mockConfig.
|
|
92
|
+
expect(body).toContain(`app_key=${mockConfig.appKey}`);
|
|
93
93
|
expect(body).toContain('events=%5B%7B%22key%22%3A%22test_event%22');
|
|
94
94
|
});
|
|
95
95
|
it('should track event with count and sum', async () => {
|
|
@@ -306,7 +306,7 @@ describe('BytemTracker SDK', () => {
|
|
|
306
306
|
const info = await BytemTracker_1.default.getSystemInfo();
|
|
307
307
|
expect(info.device_id).toBeDefined();
|
|
308
308
|
expect(typeof info.device_id).toBe('string');
|
|
309
|
-
expect(info.app_key).toBe(mockConfig.
|
|
309
|
+
expect(info.app_key).toBe(mockConfig.appKey);
|
|
310
310
|
});
|
|
311
311
|
});
|
|
312
312
|
});
|
package/dist/test/debug.test.js
CHANGED
|
@@ -7,7 +7,7 @@ const BytemTracker_1 = __importDefault(require("../src/BytemTracker"));
|
|
|
7
7
|
const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
8
8
|
describe('Debug Scenarios', () => {
|
|
9
9
|
const mockConfig = {
|
|
10
|
-
|
|
10
|
+
appKey: 'debug-app-id',
|
|
11
11
|
endpoint: 'https://debug-api.bytem.com/track',
|
|
12
12
|
debug: true,
|
|
13
13
|
};
|
|
@@ -7,7 +7,7 @@ const BytemTracker_1 = __importDefault(require("../src/BytemTracker"));
|
|
|
7
7
|
const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
8
8
|
describe('BytemTracker Network Error Resilience', () => {
|
|
9
9
|
const mockConfig = {
|
|
10
|
-
|
|
10
|
+
appKey: 'test-app-id',
|
|
11
11
|
endpoint: 'https://api.example.com/track',
|
|
12
12
|
debug: true,
|
|
13
13
|
};
|