respectlytics-react-native 2.1.0 → 3.0.0
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/LICENSE +17 -20
- package/README.md +67 -15
- package/lib/commonjs/EventQueue.js +18 -39
- package/lib/commonjs/EventQueue.js.map +1 -1
- package/lib/commonjs/NetworkClient.js +11 -7
- package/lib/commonjs/NetworkClient.js.map +1 -1
- package/lib/commonjs/Respectlytics.js +12 -7
- package/lib/commonjs/Respectlytics.js.map +1 -1
- package/lib/commonjs/SessionManager.js +6 -6
- package/lib/commonjs/index.js +7 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +0 -35
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/EventQueue.js +18 -39
- package/lib/module/EventQueue.js.map +1 -1
- package/lib/module/NetworkClient.js +11 -7
- package/lib/module/NetworkClient.js.map +1 -1
- package/lib/module/Respectlytics.js +12 -7
- package/lib/module/Respectlytics.js.map +1 -1
- package/lib/module/SessionManager.js +6 -6
- package/lib/module/index.js +7 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +0 -29
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/EventQueue.d.ts +16 -10
- package/lib/typescript/EventQueue.d.ts.map +1 -1
- package/lib/typescript/NetworkClient.d.ts +6 -5
- package/lib/typescript/NetworkClient.d.ts.map +1 -1
- package/lib/typescript/Respectlytics.d.ts +12 -5
- package/lib/typescript/Respectlytics.d.ts.map +1 -1
- package/lib/typescript/SessionManager.d.ts +4 -4
- package/lib/typescript/index.d.ts +4 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +3 -13
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +4 -9
- package/src/EventQueue.ts +18 -42
- package/src/NetworkClient.ts +11 -7
- package/src/Respectlytics.ts +12 -7
- package/src/SessionManager.ts +6 -6
- package/src/index.ts +7 -7
- package/src/types.ts +3 -14
- package/lib/commonjs/Storage.js +0 -57
- package/lib/commonjs/Storage.js.map +0 -1
- package/lib/module/Storage.js +0 -50
- package/lib/module/Storage.js.map +0 -1
- package/lib/typescript/Storage.d.ts +0 -26
- package/lib/typescript/Storage.d.ts.map +0 -1
- package/src/Storage.ts +0 -49
package/lib/module/EventQueue.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EventQueue.ts
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
|
-
*
|
|
5
|
-
* Manages event batching
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* Manages event batching and automatic flushing.
|
|
6
|
+
*
|
|
7
|
+
* Event queue is RAM-only by design. No data is written to device storage
|
|
8
|
+
* (no AsyncStorage, no files, no databases) for analytics purposes.
|
|
9
|
+
* If the app is force-quit before the next flush, unsent events are lost.
|
|
10
|
+
* This is a deliberate privacy-first design choice — zero bytes are written
|
|
11
|
+
* to the user's device for analytics purposes.
|
|
12
|
+
*
|
|
13
|
+
* The SDK auto-flushes every 30 seconds, on 10 queued events, and when the
|
|
14
|
+
* app enters background, so the loss window is narrow.
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
17
|
*/
|
|
9
18
|
|
|
10
19
|
import { AppState } from 'react-native';
|
|
11
20
|
import NetInfo from '@react-native-community/netinfo';
|
|
12
|
-
import { Storage } from './Storage';
|
|
13
21
|
const MAX_QUEUE_SIZE = 10;
|
|
14
22
|
const FLUSH_INTERVAL_MS = 30000; // 30 seconds
|
|
15
|
-
|
|
23
|
+
|
|
16
24
|
export class EventQueue {
|
|
17
25
|
events = [];
|
|
18
26
|
isOnline = true;
|
|
@@ -25,10 +33,9 @@ export class EventQueue {
|
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
/**
|
|
28
|
-
* Initialize the queue
|
|
36
|
+
* Initialize the queue — set up listeners and start flush timer
|
|
29
37
|
*/
|
|
30
|
-
|
|
31
|
-
await this.loadPersistedQueue();
|
|
38
|
+
start() {
|
|
32
39
|
this.setupNetworkMonitor();
|
|
33
40
|
this.setupAppStateMonitor();
|
|
34
41
|
this.scheduleFlush();
|
|
@@ -54,15 +61,11 @@ export class EventQueue {
|
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
|
-
* Add an event to the queue
|
|
58
|
-
* CRITICAL: Events are persisted IMMEDIATELY before any async operations
|
|
64
|
+
* Add an event to the in-memory queue.
|
|
59
65
|
*/
|
|
60
|
-
|
|
66
|
+
add(event) {
|
|
61
67
|
this.events.push(event);
|
|
62
68
|
|
|
63
|
-
// IMMEDIATELY persist before any async operations
|
|
64
|
-
await this.persistQueue();
|
|
65
|
-
|
|
66
69
|
// Check if we should flush
|
|
67
70
|
if (this.events.length >= MAX_QUEUE_SIZE) {
|
|
68
71
|
this.flush();
|
|
@@ -89,14 +92,12 @@ export class EventQueue {
|
|
|
89
92
|
// Take a snapshot of events to send
|
|
90
93
|
const batch = [...this.events];
|
|
91
94
|
this.events = [];
|
|
92
|
-
await this.persistQueue();
|
|
93
95
|
try {
|
|
94
96
|
await this.networkClient.send(batch);
|
|
95
97
|
console.log(`[Respectlytics] ✓ Sent ${batch.length} event(s)`);
|
|
96
98
|
} catch (error) {
|
|
97
99
|
// Re-add failed events to the front of the queue
|
|
98
100
|
this.events = [...batch, ...this.events];
|
|
99
|
-
await this.persistQueue();
|
|
100
101
|
console.log('[Respectlytics] Failed to send events, will retry later');
|
|
101
102
|
} finally {
|
|
102
103
|
this.isFlushing = false;
|
|
@@ -140,27 +141,5 @@ export class EventQueue {
|
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
|
-
async persistQueue() {
|
|
144
|
-
try {
|
|
145
|
-
await Storage.setItem(QUEUE_STORAGE_KEY, JSON.stringify(this.events));
|
|
146
|
-
} catch (error) {
|
|
147
|
-
console.log('[Respectlytics] Failed to persist queue:', error);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async loadPersistedQueue() {
|
|
151
|
-
try {
|
|
152
|
-
const data = await Storage.getItem(QUEUE_STORAGE_KEY);
|
|
153
|
-
if (data) {
|
|
154
|
-
const parsed = JSON.parse(data);
|
|
155
|
-
if (Array.isArray(parsed)) {
|
|
156
|
-
this.events = parsed;
|
|
157
|
-
console.log(`[Respectlytics] Loaded ${this.events.length} persisted event(s)`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
} catch (error) {
|
|
161
|
-
console.log('[Respectlytics] Failed to load persisted queue:', error);
|
|
162
|
-
this.events = [];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
144
|
}
|
|
166
145
|
//# sourceMappingURL=EventQueue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AppState","NetInfo","
|
|
1
|
+
{"version":3,"names":["AppState","NetInfo","MAX_QUEUE_SIZE","FLUSH_INTERVAL_MS","EventQueue","events","isOnline","flushTimer","isFlushing","unsubscribeNetInfo","appStateSubscription","constructor","networkClient","start","setupNetworkMonitor","setupAppStateMonitor","scheduleFlush","console","log","stop","clearInterval","remove","add","event","push","length","flush","isConfigured","batch","send","error","getQueueSize","setInterval","addEventListener","state","wasOffline","isConnected","nextAppState"],"sourceRoot":"../../src","sources":["EventQueue.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAwB,cAAc;AACvD,OAAOC,OAAO,MAAwB,iCAAiC;AAIvE,MAAMC,cAAc,GAAG,EAAE;AACzB,MAAMC,iBAAiB,GAAG,KAAK,CAAC,CAAC;;AAEjC,OAAO,MAAMC,UAAU,CAAC;EACdC,MAAM,GAAY,EAAE;EACpBC,QAAQ,GAAG,IAAI;EACfC,UAAU,GAA0C,IAAI;EAExDC,UAAU,GAAG,KAAK;EAClBC,kBAAkB,GAAwB,IAAI;EAC9CC,oBAAoB,GA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,EAAE;QAC/BW,OAAO,CAACC,GAAG,CAAC,kDAAkD,CAAC;QAC/D,IAAI,CAACQ,KAAK,CAAC,CAAC;MACd;IACF,CAAC,CAAC;EACJ;EAEQX,oBAAoBA,CAAA,EAAS;IACnC,IAAI,CAACL,oBAAoB,GAAGV,QAAQ,CAACiC,gBAAgB,CACnD,QAAQ,EACPI,YAA4B,IAAK;MAChC;MACA,IAAIA,YAAY,KAAK,YAAY,IAAIA,YAAY,KAAK,UAAU,EAAE;QAChE,IAAI,CAACX,KAAK,CAAC,CAAC;MACd;IACF,CACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
5
|
* Handles HTTP communication with the Respectlytics API.
|
|
6
|
-
* Copyright (c) 2025 Respectlytics.
|
|
6
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const DEFAULT_API_ENDPOINT = 'https://respectlytics.com/api/v1/events/';
|
|
10
10
|
const MAX_RETRIES = 3;
|
|
11
11
|
const TIMEOUT_MS = 30000;
|
|
12
12
|
export let NetworkError = /*#__PURE__*/function (NetworkError) {
|
|
@@ -22,12 +22,16 @@ export let NetworkError = /*#__PURE__*/function (NetworkError) {
|
|
|
22
22
|
}({});
|
|
23
23
|
export class NetworkClient {
|
|
24
24
|
apiKey = null;
|
|
25
|
+
apiEndpoint = DEFAULT_API_ENDPOINT;
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
|
-
* Configure the network client with an API key
|
|
28
|
+
* Configure the network client with an API key and optional custom endpoint
|
|
28
29
|
*/
|
|
29
|
-
configure(apiKey) {
|
|
30
|
+
configure(apiKey, apiEndpoint) {
|
|
30
31
|
this.apiKey = apiKey;
|
|
32
|
+
if (apiEndpoint) {
|
|
33
|
+
this.apiEndpoint = apiEndpoint;
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
/**
|
|
@@ -59,7 +63,7 @@ export class NetworkClient {
|
|
|
59
63
|
const controller = new AbortController();
|
|
60
64
|
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
61
65
|
try {
|
|
62
|
-
const response = await fetch(
|
|
66
|
+
const response = await fetch(this.apiEndpoint, {
|
|
63
67
|
method: 'POST',
|
|
64
68
|
headers: {
|
|
65
69
|
'Content-Type': 'application/json',
|
|
@@ -123,8 +127,8 @@ export class NetworkClient {
|
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
/**
|
|
126
|
-
* Convert Event object to API payload format
|
|
127
|
-
*
|
|
130
|
+
* Convert Event object to API payload format.
|
|
131
|
+
* The SDK sends 4 fields; the API stores 5 (adding country derived from IP).
|
|
128
132
|
*/
|
|
129
133
|
eventToPayload(event) {
|
|
130
134
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DEFAULT_API_ENDPOINT","MAX_RETRIES","TIMEOUT_MS","NetworkError","NetworkClient","apiKey","apiEndpoint","configure","isConfigured","send","events","Error","NotConfigured","event","sendEvent","attempt","controller","AbortController","timeoutId","setTimeout","abort","response","fetch","method","headers","body","JSON","stringify","eventToPayload","signal","clearTimeout","ok","status","Unauthorized","BadRequest","delay","Math","pow","RateLimited","ServerError","InvalidResponse","error","message","name","Timeout","event_name","eventName","timestamp","session_id","sessionId","platform","ms","Promise","resolve","networkClient"],"sourceRoot":"../../src","sources":["NetworkClient.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMA,oBAAoB,GAAG,0CAA0C;AACvE,MAAMC,WAAW,GAAG,CAAC;AACrB,MAAMC,UAAU,GAAG,KAAK;AAExB,WAAYC,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;E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":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
5
|
* Main entry point for the SDK.
|
|
6
|
-
* Copyright (c) 2025 Respectlytics.
|
|
6
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { Platform } from 'react-native';
|
|
@@ -14,17 +14,21 @@ import { EventQueue } from './EventQueue';
|
|
|
14
14
|
/**
|
|
15
15
|
* Main entry point for the Respectlytics SDK.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* v3.0.0 uses session-based analytics only:
|
|
18
18
|
* - Session IDs are generated automatically in RAM
|
|
19
|
+
* - Event queue is RAM-only (zero device storage)
|
|
19
20
|
* - Sessions rotate every 2 hours
|
|
20
21
|
* - New session on every app restart
|
|
21
|
-
* - Only 4 fields sent
|
|
22
|
+
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
22
23
|
*
|
|
23
24
|
* Usage:
|
|
24
25
|
* ```typescript
|
|
25
26
|
* // 1. Configure at app launch
|
|
26
27
|
* Respectlytics.configure('your-api-key');
|
|
27
28
|
*
|
|
29
|
+
* // For self-hosted instances:
|
|
30
|
+
* Respectlytics.configure('your-api-key', { apiEndpoint: 'https://your-server.com/api/v1/events/' });
|
|
31
|
+
*
|
|
28
32
|
* // 2. Track events
|
|
29
33
|
* Respectlytics.track('purchase');
|
|
30
34
|
* ```
|
|
@@ -43,23 +47,24 @@ class RespectlyticsSDK {
|
|
|
43
47
|
* Call once at app startup.
|
|
44
48
|
*
|
|
45
49
|
* @param apiKey Your Respectlytics API key from the dashboard
|
|
50
|
+
* @param options Optional configuration (e.g., apiEndpoint for self-hosted instances)
|
|
46
51
|
*/
|
|
47
|
-
configure(apiKey) {
|
|
52
|
+
configure(apiKey, options) {
|
|
48
53
|
if (!apiKey || apiKey.trim() === '') {
|
|
49
54
|
console.log('[Respectlytics] ⚠️ API key cannot be empty');
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
|
-
this.networkClient.configure(apiKey);
|
|
57
|
+
this.networkClient.configure(apiKey, options?.apiEndpoint);
|
|
53
58
|
this.eventQueue.start();
|
|
54
59
|
this.isConfigured = true;
|
|
55
|
-
console.log('[Respectlytics] ✓ SDK configured (
|
|
60
|
+
console.log('[Respectlytics] ✓ SDK configured (v3.0.0)');
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
59
64
|
* Track an event.
|
|
60
65
|
*
|
|
61
66
|
* Custom properties are NOT supported - this is by design for privacy.
|
|
62
|
-
* The API
|
|
67
|
+
* The API stores 5 fields (these 4 plus country derived server-side).
|
|
63
68
|
*
|
|
64
69
|
* @param eventName Name of the event (e.g., "purchase", "button_clicked")
|
|
65
70
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","SessionManager","NetworkClient","EventQueue","RespectlyticsSDK","isConfigured","constructor","networkClient","eventQueue","sessionManager","platform","OS","configure","apiKey","trim","console","log","start","track","eventName","length","event","timestamp","Date","toISOString","sessionId","getSessionId","add","flush","Respectlytics"],"sourceRoot":"../../src","sources":["Respectlytics.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,UAAU,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,CAAC;EACbC,YAAY,GAAG,KAAK;EAM5BC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,aAAa,GAAG,IAAIL,aAAa,CAAC,CAAC;IACxC,IAAI,CAACM,UAAU,GAAG,IAAIL,UAAU,CAAC,IAAI,CAACI,aAAa,CAAC;IACpD,IAAI,CAACE,cAAc,GAAG,IAAIR,cAAc,CAAC,CAAC;IAC1C,IAAI,CAACS,QAAQ,GAAGV,QAAQ,CAACW,EAAE,KAAK,KAAK,GAAG,KAAK,GAAG,SAAS;EAC3D;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACC,MAAc,EAAQ;
|
|
1
|
+
{"version":3,"names":["Platform","SessionManager","NetworkClient","EventQueue","RespectlyticsSDK","isConfigured","constructor","networkClient","eventQueue","sessionManager","platform","OS","configure","apiKey","options","trim","console","log","apiEndpoint","start","track","eventName","length","event","timestamp","Date","toISOString","sessionId","getSessionId","add","flush","Respectlytics"],"sourceRoot":"../../src","sources":["Respectlytics.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,UAAU,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,CAAC;EACbC,YAAY,GAAG,KAAK;EAM5BC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,aAAa,GAAG,IAAIL,aAAa,CAAC,CAAC;IACxC,IAAI,CAACM,UAAU,GAAG,IAAIL,UAAU,CAAC,IAAI,CAACI,aAAa,CAAC;IACpD,IAAI,CAACE,cAAc,GAAG,IAAIR,cAAc,CAAC,CAAC;IAC1C,IAAI,CAACS,QAAQ,GAAGV,QAAQ,CAACW,EAAE,KAAK,KAAK,GAAG,KAAK,GAAG,SAAS;EAC3D;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACC,MAAc,EAAEC,OAAkC,EAAQ;IAClE,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;MACnC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@
|
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
5
|
* Manages session ID generation and rotation.
|
|
6
|
-
* Sessions are stored in RAM only (never persisted
|
|
6
|
+
* Sessions are stored in RAM only (never persisted to disk).
|
|
7
7
|
* Sessions automatically rotate every 2 hours.
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2025 Respectlytics.
|
|
9
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -22,15 +22,15 @@ function generateUUID() {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Manages session ID generation and rotation.
|
|
25
|
-
*
|
|
25
|
+
*
|
|
26
26
|
* Session IDs are:
|
|
27
27
|
* - Generated immediately when the SDK initializes
|
|
28
28
|
* - Stored in RAM only (never persisted to AsyncStorage)
|
|
29
29
|
* - Rotated automatically every 2 hours
|
|
30
30
|
* - Regenerated on every app restart (new instance = new session)
|
|
31
|
-
*
|
|
32
|
-
* This RAM-only approach
|
|
33
|
-
* -
|
|
31
|
+
*
|
|
32
|
+
* This RAM-only approach means session data never touches device storage:
|
|
33
|
+
* - Sessions exist only in memory and are lost on app restart
|
|
34
34
|
* - Each app launch creates a fresh, unlinked session
|
|
35
35
|
*/
|
|
36
36
|
export class SessionManager {
|
package/lib/module/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Respectlytics React Native SDK
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Official SDK for privacy-first, session-based analytics.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* v3.0.0 Features:
|
|
7
7
|
* - Session-based analytics (no persistent user tracking)
|
|
8
|
-
* - RAM-only session storage (
|
|
8
|
+
* - RAM-only session storage (never persisted to disk)
|
|
9
|
+
* - RAM-only event queue (zero device storage)
|
|
9
10
|
* - Automatic 2-hour session rotation
|
|
10
11
|
* - New session on every app restart
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2025 Respectlytics.
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
import Respectlytics from './Respectlytics';
|
|
16
16
|
|
|
17
17
|
// Default export - the main SDK instance
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Respectlytics","RespectlyticsSDK","Event"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"names":["Respectlytics","RespectlyticsSDK","Event"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,iBAAiB;;AAE3C;AACA,eAAeA,aAAa;;AAE5B;AACA,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,KAAK,QAAQ,SAAS","ignoreList":[]}
|
package/lib/module/types.js
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* types.ts
|
|
3
|
-
* Respectlytics React Native SDK
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2025 Respectlytics. All rights reserved.
|
|
6
|
-
* This SDK is provided under a proprietary license.
|
|
7
|
-
* See LICENSE file for details.
|
|
8
|
-
*/
|
|
9
1
|
|
|
10
|
-
/**
|
|
11
|
-
* Represents an analytics event - flat structure matching API payload
|
|
12
|
-
*
|
|
13
|
-
* v2.1.0: Only 4 fields are sent (strict API allowlist):
|
|
14
|
-
* - event_name (required)
|
|
15
|
-
* - timestamp
|
|
16
|
-
* - session_id
|
|
17
|
-
* - platform
|
|
18
|
-
*
|
|
19
|
-
* Country is derived server-side from IP (which is immediately discarded).
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Storage keys used by the SDK
|
|
24
|
-
*
|
|
25
|
-
* Note: Only the event queue is persisted.
|
|
26
|
-
* Session IDs are RAM-only for privacy.
|
|
27
|
-
*/
|
|
28
|
-
export const STORAGE_KEYS = {
|
|
29
|
-
EVENT_QUEUE: 'com.respectlytics.eventQueue'
|
|
30
|
-
};
|
|
31
2
|
//# sourceMappingURL=types.js.map
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -2,9 +2,18 @@
|
|
|
2
2
|
* EventQueue.ts
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
|
-
* Manages event batching
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Manages event batching and automatic flushing.
|
|
6
|
+
*
|
|
7
|
+
* Event queue is RAM-only by design. No data is written to device storage
|
|
8
|
+
* (no AsyncStorage, no files, no databases) for analytics purposes.
|
|
9
|
+
* If the app is force-quit before the next flush, unsent events are lost.
|
|
10
|
+
* This is a deliberate privacy-first design choice — zero bytes are written
|
|
11
|
+
* to the user's device for analytics purposes.
|
|
12
|
+
*
|
|
13
|
+
* The SDK auto-flushes every 30 seconds, on 10 queued events, and when the
|
|
14
|
+
* app enters background, so the loss window is narrow.
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
17
|
*/
|
|
9
18
|
import { Event } from './types';
|
|
10
19
|
import { NetworkClient } from './NetworkClient';
|
|
@@ -18,18 +27,17 @@ export declare class EventQueue {
|
|
|
18
27
|
private appStateSubscription;
|
|
19
28
|
constructor(networkClient: NetworkClient);
|
|
20
29
|
/**
|
|
21
|
-
* Initialize the queue
|
|
30
|
+
* Initialize the queue — set up listeners and start flush timer
|
|
22
31
|
*/
|
|
23
|
-
start():
|
|
32
|
+
start(): void;
|
|
24
33
|
/**
|
|
25
34
|
* Stop the queue and clean up resources
|
|
26
35
|
*/
|
|
27
36
|
stop(): void;
|
|
28
37
|
/**
|
|
29
|
-
* Add an event to the queue
|
|
30
|
-
* CRITICAL: Events are persisted IMMEDIATELY before any async operations
|
|
38
|
+
* Add an event to the in-memory queue.
|
|
31
39
|
*/
|
|
32
|
-
add(event: Event):
|
|
40
|
+
add(event: Event): void;
|
|
33
41
|
/**
|
|
34
42
|
* Force flush all queued events
|
|
35
43
|
*/
|
|
@@ -41,7 +49,5 @@ export declare class EventQueue {
|
|
|
41
49
|
private scheduleFlush;
|
|
42
50
|
private setupNetworkMonitor;
|
|
43
51
|
private setupAppStateMonitor;
|
|
44
|
-
private persistQueue;
|
|
45
|
-
private loadPersistedQueue;
|
|
46
52
|
}
|
|
47
53
|
//# sourceMappingURL=EventQueue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventQueue.d.ts","sourceRoot":"","sources":["../../src/EventQueue.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"EventQueue.d.ts","sourceRoot":"","sources":["../../src/EventQueue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,kBAAkB,CAA6B;IACvD,OAAO,CAAC,oBAAoB,CAAuC;gBAEvD,aAAa,EAAE,aAAa;IAIxC;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;OAEG;IACH,IAAI,IAAI,IAAI;IAeZ;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IASvB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC5B;;OAEG;IACH,YAAY,IAAI,MAAM;IAMtB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,oBAAoB;CAW7B"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
5
|
* Handles HTTP communication with the Respectlytics API.
|
|
6
|
-
* Copyright (c) 2025 Respectlytics.
|
|
6
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
7
7
|
*/
|
|
8
8
|
import { Event } from './types';
|
|
9
9
|
export declare enum NetworkError {
|
|
@@ -18,10 +18,11 @@ export declare enum NetworkError {
|
|
|
18
18
|
}
|
|
19
19
|
export declare class NetworkClient {
|
|
20
20
|
private apiKey;
|
|
21
|
+
private apiEndpoint;
|
|
21
22
|
/**
|
|
22
|
-
* Configure the network client with an API key
|
|
23
|
+
* Configure the network client with an API key and optional custom endpoint
|
|
23
24
|
*/
|
|
24
|
-
configure(apiKey: string): void;
|
|
25
|
+
configure(apiKey: string, apiEndpoint?: string): void;
|
|
25
26
|
/**
|
|
26
27
|
* Check if the client is configured
|
|
27
28
|
*/
|
|
@@ -35,8 +36,8 @@ export declare class NetworkClient {
|
|
|
35
36
|
*/
|
|
36
37
|
private sendEvent;
|
|
37
38
|
/**
|
|
38
|
-
* Convert Event object to API payload format
|
|
39
|
-
*
|
|
39
|
+
* Convert Event object to API payload format.
|
|
40
|
+
* The SDK sends 4 fields; the API stores 5 (adding country derived from IP).
|
|
40
41
|
*/
|
|
41
42
|
private eventToPayload;
|
|
42
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkClient.d.ts","sourceRoot":"","sources":["../../src/NetworkClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMhC,oBAAY,YAAY;IACtB,aAAa,mBAAmB;IAChC,eAAe,qBAAqB;IACpC,YAAY,iBAAiB;IAC7B,UAAU,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,WAAW,iBAAiB;IAC5B,YAAY,kBAAkB;IAC9B,OAAO,YAAY;CACpB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAuB;
|
|
1
|
+
{"version":3,"file":"NetworkClient.d.ts","sourceRoot":"","sources":["../../src/NetworkClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMhC,oBAAY,YAAY;IACtB,aAAa,mBAAmB;IAChC,eAAe,qBAAqB;IACpC,YAAY,iBAAiB;IAC7B,UAAU,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,WAAW,iBAAiB;IAC5B,YAAY,kBAAkB;IAC9B,OAAO,YAAY;CACpB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAgC;IAEnD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAOrD;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1C;;OAEG;YACW,SAAS;IAgFvB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -3,22 +3,26 @@
|
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
5
|
* Main entry point for the SDK.
|
|
6
|
-
* Copyright (c) 2025 Respectlytics.
|
|
6
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* Main entry point for the Respectlytics SDK.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* v3.0.0 uses session-based analytics only:
|
|
12
12
|
* - Session IDs are generated automatically in RAM
|
|
13
|
+
* - Event queue is RAM-only (zero device storage)
|
|
13
14
|
* - Sessions rotate every 2 hours
|
|
14
15
|
* - New session on every app restart
|
|
15
|
-
* - Only 4 fields sent
|
|
16
|
+
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
16
17
|
*
|
|
17
18
|
* Usage:
|
|
18
19
|
* ```typescript
|
|
19
20
|
* // 1. Configure at app launch
|
|
20
21
|
* Respectlytics.configure('your-api-key');
|
|
21
22
|
*
|
|
23
|
+
* // For self-hosted instances:
|
|
24
|
+
* Respectlytics.configure('your-api-key', { apiEndpoint: 'https://your-server.com/api/v1/events/' });
|
|
25
|
+
*
|
|
22
26
|
* // 2. Track events
|
|
23
27
|
* Respectlytics.track('purchase');
|
|
24
28
|
* ```
|
|
@@ -35,13 +39,16 @@ declare class RespectlyticsSDK {
|
|
|
35
39
|
* Call once at app startup.
|
|
36
40
|
*
|
|
37
41
|
* @param apiKey Your Respectlytics API key from the dashboard
|
|
42
|
+
* @param options Optional configuration (e.g., apiEndpoint for self-hosted instances)
|
|
38
43
|
*/
|
|
39
|
-
configure(apiKey: string
|
|
44
|
+
configure(apiKey: string, options?: {
|
|
45
|
+
apiEndpoint?: string;
|
|
46
|
+
}): void;
|
|
40
47
|
/**
|
|
41
48
|
* Track an event.
|
|
42
49
|
*
|
|
43
50
|
* Custom properties are NOT supported - this is by design for privacy.
|
|
44
|
-
* The API
|
|
51
|
+
* The API stores 5 fields (these 4 plus country derived server-side).
|
|
45
52
|
*
|
|
46
53
|
* @param eventName Name of the event (e.g., "purchase", "button_clicked")
|
|
47
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Respectlytics.d.ts","sourceRoot":"","sources":["../../src/Respectlytics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH
|
|
1
|
+
{"version":3,"file":"Respectlytics.d.ts","sourceRoot":"","sources":["../../src/Respectlytics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,cAAM,gBAAgB;IACpB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAS;;IASzB;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAanE;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IA0B9B;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAGD,QAAA,MAAM,aAAa,kBAAyB,CAAC;AAC7C,eAAe,aAAa,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
5
|
* Manages session ID generation and rotation.
|
|
6
|
-
* Sessions are stored in RAM only (never persisted
|
|
6
|
+
* Sessions are stored in RAM only (never persisted to disk).
|
|
7
7
|
* Sessions automatically rotate every 2 hours.
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2025 Respectlytics.
|
|
9
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* Manages session ID generation and rotation.
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* - Rotated automatically every 2 hours
|
|
18
18
|
* - Regenerated on every app restart (new instance = new session)
|
|
19
19
|
*
|
|
20
|
-
* This RAM-only approach
|
|
21
|
-
* -
|
|
20
|
+
* This RAM-only approach means session data never touches device storage:
|
|
21
|
+
* - Sessions exist only in memory and are lost on app restart
|
|
22
22
|
* - Each app launch creates a fresh, unlinked session
|
|
23
23
|
*/
|
|
24
24
|
export declare class SessionManager {
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Official SDK for privacy-first, session-based analytics.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* v3.0.0 Features:
|
|
7
7
|
* - Session-based analytics (no persistent user tracking)
|
|
8
|
-
* - RAM-only session storage (
|
|
8
|
+
* - RAM-only session storage (never persisted to disk)
|
|
9
|
+
* - RAM-only event queue (zero device storage)
|
|
9
10
|
* - Automatic 2-hour session rotation
|
|
10
11
|
* - New session on every app restart
|
|
11
12
|
*
|
|
12
|
-
* Copyright (c) 2025 Respectlytics.
|
|
13
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
13
14
|
*/
|
|
14
15
|
import Respectlytics from './Respectlytics';
|
|
15
16
|
export default Respectlytics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,eAAe,aAAa,CAAC;AAG7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* types.ts
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2025 Respectlytics.
|
|
6
|
-
* This SDK is provided under a proprietary license.
|
|
7
|
-
* See LICENSE file for details.
|
|
5
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
6
|
*/
|
|
9
7
|
/**
|
|
10
8
|
* Represents an analytics event - flat structure matching API payload
|
|
11
9
|
*
|
|
12
|
-
*
|
|
10
|
+
* The SDK sends these 4 fields. The API stores 5 total
|
|
11
|
+
* (adding country, derived server-side from IP which is immediately discarded):
|
|
13
12
|
* - event_name (required)
|
|
14
13
|
* - timestamp
|
|
15
14
|
* - session_id
|
|
@@ -23,13 +22,4 @@ export interface Event {
|
|
|
23
22
|
sessionId: string;
|
|
24
23
|
platform: string;
|
|
25
24
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Storage keys used by the SDK
|
|
28
|
-
*
|
|
29
|
-
* Note: Only the event queue is persisted.
|
|
30
|
-
* Session IDs are RAM-only for privacy.
|
|
31
|
-
*/
|
|
32
|
-
export declare const STORAGE_KEYS: {
|
|
33
|
-
readonly EVENT_QUEUE: "com.respectlytics.eventQueue";
|
|
34
|
-
};
|
|
35
25
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,KAAK;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|