respectlytics-react-native 2.2.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/README.md +33 -9
- package/lib/commonjs/EventQueue.js +17 -38
- package/lib/commonjs/EventQueue.js.map +1 -1
- package/lib/commonjs/Respectlytics.js +3 -2
- package/lib/commonjs/Respectlytics.js.map +1 -1
- package/lib/commonjs/SessionManager.js +2 -2
- package/lib/commonjs/index.js +4 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +0 -34
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/EventQueue.js +17 -38
- package/lib/module/EventQueue.js.map +1 -1
- package/lib/module/Respectlytics.js +3 -2
- package/lib/module/Respectlytics.js.map +1 -1
- package/lib/module/SessionManager.js +2 -2
- package/lib/module/index.js +4 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +0 -28
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/EventQueue.d.ts +15 -9
- package/lib/typescript/EventQueue.d.ts.map +1 -1
- package/lib/typescript/Respectlytics.d.ts +2 -1
- package/lib/typescript/Respectlytics.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +0 -9
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +3 -8
- package/src/EventQueue.ts +15 -39
- package/src/Respectlytics.ts +3 -2
- package/src/index.ts +2 -1
- package/src/types.ts +0 -10
- 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/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://github.com/respectlytics/respectlytics-react-native)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
Official Respectlytics SDK for React Native. Privacy-first, session-based analytics with automatic session management,
|
|
7
|
+
Official Respectlytics SDK for React Native. Privacy-first, session-based analytics with automatic session management, zero device storage, and no device identifier collection.
|
|
8
8
|
|
|
9
9
|
## Philosophy: Return of Avoidance (ROA)
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ That's it. No device identifiers, no fingerprinting, no persistent tracking.
|
|
|
23
23
|
|
|
24
24
|
- 🔒 **Privacy-First**: No device identifiers (IDFA, GAID, Android ID)
|
|
25
25
|
- ⚡ **Simple Integration**: 2 lines of code to get started
|
|
26
|
-
-
|
|
26
|
+
- 🧠 **RAM-Only**: Event queue and sessions held entirely in memory — zero device storage
|
|
27
27
|
- 🔄 **Automatic Sessions**: RAM-only, 2-hour rotation, new session on app restart
|
|
28
28
|
- 📱 **Cross-Platform**: iOS and Android support
|
|
29
29
|
|
|
@@ -36,13 +36,13 @@ That's it. No device identifiers, no fingerprinting, no persistent tracking.
|
|
|
36
36
|
## Installation
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
npm install respectlytics-react-native @react-native-
|
|
39
|
+
npm install respectlytics-react-native @react-native-community/netinfo
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
or with Yarn:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
yarn add respectlytics-react-native @react-native-
|
|
45
|
+
yarn add respectlytics-react-native @react-native-community/netinfo
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
### iOS Setup
|
|
@@ -159,20 +159,44 @@ The SDK handles these automatically - no developer action needed:
|
|
|
159
159
|
| Feature | Behavior |
|
|
160
160
|
|---------|----------|
|
|
161
161
|
| **Session Management** | New session ID on app launch, rotates after 2 hours |
|
|
162
|
-
| **Event Batching** | Events queued and sent in batches (max 10 events or 30 seconds) |
|
|
163
|
-
| **Offline
|
|
162
|
+
| **Event Batching** | Events queued in memory and sent in batches (max 10 events or 30 seconds) |
|
|
163
|
+
| **Offline Handling** | Events held in RAM when offline, sent when connectivity returns |
|
|
164
164
|
| **Retry Logic** | Failed requests retry with exponential backoff (max 3 attempts) |
|
|
165
165
|
| **Background Sync** | Events flushed when app enters background |
|
|
166
166
|
|
|
167
|
-
##
|
|
167
|
+
## Event Queue (RAM-Only)
|
|
168
168
|
|
|
169
|
-
Events are
|
|
169
|
+
Events are held in memory and sent automatically:
|
|
170
170
|
|
|
171
|
-
1. Events are
|
|
171
|
+
1. Events are added to an in-memory array — nothing is written to device storage
|
|
172
172
|
2. Network status is monitored via NetInfo
|
|
173
173
|
3. Queue is flushed when connectivity is restored
|
|
174
174
|
4. Failed sends are retried with exponential backoff
|
|
175
175
|
|
|
176
|
+
**Unsent events are lost on force-quit** — this is a deliberate privacy trade-off. The SDK writes zero bytes to the device for analytics purposes. The ~1-3% event loss from force-quits has no meaningful impact on session-based aggregate analytics.
|
|
177
|
+
|
|
178
|
+
## Migration from v2.x
|
|
179
|
+
|
|
180
|
+
### Changes in v3.0.0
|
|
181
|
+
|
|
182
|
+
- **BREAKING**: Event queue no longer persists to AsyncStorage
|
|
183
|
+
- **REMOVED**: `@react-native-async-storage/async-storage` peer dependency
|
|
184
|
+
- Events are now held in RAM only — zero device storage
|
|
185
|
+
- Unsent events are lost on force-quit (deliberate privacy trade-off)
|
|
186
|
+
|
|
187
|
+
### What to do
|
|
188
|
+
|
|
189
|
+
1. Update your install command (AsyncStorage is no longer needed):
|
|
190
|
+
```bash
|
|
191
|
+
# Before
|
|
192
|
+
npm install respectlytics-react-native @react-native-async-storage/async-storage @react-native-community/netinfo
|
|
193
|
+
|
|
194
|
+
# After
|
|
195
|
+
npm install respectlytics-react-native @react-native-community/netinfo
|
|
196
|
+
```
|
|
197
|
+
2. Optionally remove `@react-native-async-storage/async-storage` if nothing else uses it
|
|
198
|
+
3. **No code changes required** — the public API (`configure`, `track`, `flush`) is unchanged
|
|
199
|
+
|
|
176
200
|
## Migration from v2.1.x
|
|
177
201
|
|
|
178
202
|
### Changes in v2.2.0
|
|
@@ -6,20 +6,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.EventQueue = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _netinfo = _interopRequireDefault(require("@react-native-community/netinfo"));
|
|
9
|
-
var _Storage = require("./Storage");
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
10
|
/**
|
|
12
11
|
* EventQueue.ts
|
|
13
12
|
* Respectlytics React Native SDK
|
|
14
|
-
*
|
|
15
|
-
* Manages event batching
|
|
16
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* Manages event batching and automatic flushing.
|
|
15
|
+
*
|
|
16
|
+
* Event queue is RAM-only by design. No data is written to device storage
|
|
17
|
+
* (no AsyncStorage, no files, no databases) for analytics purposes.
|
|
18
|
+
* If the app is force-quit before the next flush, unsent events are lost.
|
|
19
|
+
* This is a deliberate privacy-first design choice — zero bytes are written
|
|
20
|
+
* to the user's device for analytics purposes.
|
|
21
|
+
*
|
|
22
|
+
* The SDK auto-flushes every 30 seconds, on 10 queued events, and when the
|
|
23
|
+
* app enters background, so the loss window is narrow.
|
|
24
|
+
*
|
|
17
25
|
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
18
26
|
*/
|
|
19
27
|
|
|
20
28
|
const MAX_QUEUE_SIZE = 10;
|
|
21
29
|
const FLUSH_INTERVAL_MS = 30000; // 30 seconds
|
|
22
|
-
|
|
30
|
+
|
|
23
31
|
class EventQueue {
|
|
24
32
|
events = [];
|
|
25
33
|
isOnline = true;
|
|
@@ -32,10 +40,9 @@ class EventQueue {
|
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
/**
|
|
35
|
-
* Initialize the queue
|
|
43
|
+
* Initialize the queue — set up listeners and start flush timer
|
|
36
44
|
*/
|
|
37
|
-
|
|
38
|
-
await this.loadPersistedQueue();
|
|
45
|
+
start() {
|
|
39
46
|
this.setupNetworkMonitor();
|
|
40
47
|
this.setupAppStateMonitor();
|
|
41
48
|
this.scheduleFlush();
|
|
@@ -61,15 +68,11 @@ class EventQueue {
|
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
/**
|
|
64
|
-
* Add an event to the queue
|
|
65
|
-
* CRITICAL: Events are persisted IMMEDIATELY before any async operations
|
|
71
|
+
* Add an event to the in-memory queue.
|
|
66
72
|
*/
|
|
67
|
-
|
|
73
|
+
add(event) {
|
|
68
74
|
this.events.push(event);
|
|
69
75
|
|
|
70
|
-
// IMMEDIATELY persist before any async operations
|
|
71
|
-
await this.persistQueue();
|
|
72
|
-
|
|
73
76
|
// Check if we should flush
|
|
74
77
|
if (this.events.length >= MAX_QUEUE_SIZE) {
|
|
75
78
|
this.flush();
|
|
@@ -96,14 +99,12 @@ class EventQueue {
|
|
|
96
99
|
// Take a snapshot of events to send
|
|
97
100
|
const batch = [...this.events];
|
|
98
101
|
this.events = [];
|
|
99
|
-
await this.persistQueue();
|
|
100
102
|
try {
|
|
101
103
|
await this.networkClient.send(batch);
|
|
102
104
|
console.log(`[Respectlytics] ✓ Sent ${batch.length} event(s)`);
|
|
103
105
|
} catch (error) {
|
|
104
106
|
// Re-add failed events to the front of the queue
|
|
105
107
|
this.events = [...batch, ...this.events];
|
|
106
|
-
await this.persistQueue();
|
|
107
108
|
console.log('[Respectlytics] Failed to send events, will retry later');
|
|
108
109
|
} finally {
|
|
109
110
|
this.isFlushing = false;
|
|
@@ -147,28 +148,6 @@ class EventQueue {
|
|
|
147
148
|
}
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
|
-
async persistQueue() {
|
|
151
|
-
try {
|
|
152
|
-
await _Storage.Storage.setItem(QUEUE_STORAGE_KEY, JSON.stringify(this.events));
|
|
153
|
-
} catch (error) {
|
|
154
|
-
console.log('[Respectlytics] Failed to persist queue:', error);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async loadPersistedQueue() {
|
|
158
|
-
try {
|
|
159
|
-
const data = await _Storage.Storage.getItem(QUEUE_STORAGE_KEY);
|
|
160
|
-
if (data) {
|
|
161
|
-
const parsed = JSON.parse(data);
|
|
162
|
-
if (Array.isArray(parsed)) {
|
|
163
|
-
this.events = parsed;
|
|
164
|
-
console.log(`[Respectlytics] Loaded ${this.events.length} persisted event(s)`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
} catch (error) {
|
|
168
|
-
console.log('[Respectlytics] Failed to load persisted queue:', error);
|
|
169
|
-
this.events = [];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
151
|
}
|
|
173
152
|
exports.EventQueue = EventQueue;
|
|
174
153
|
//# sourceMappingURL=EventQueue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_netinfo","_interopRequireDefault","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_netinfo","_interopRequireDefault","e","__esModule","default","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","NetInfo","addEventListener","state","wasOffline","isConnected","AppState","nextAppState","exports"],"sourceRoot":"../../src","sources":["EventQueue.ts"],"mappings":";;;;;;AAkBA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwE,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAnBxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,MAAMG,cAAc,GAAG,EAAE;AACzB,MAAMC,iBAAiB,GAAG,KAAK,CAAC,CAAC;;AAE1B,MAAMC,UAAU,CAAC;EACdC,MAAM,G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,IAAI,CAAC9B,QAAQ;MACjC,IAAI,CAACA,QAAQ,GAAG6B,KAAK,CAACE,WAAW,IAAI,KAAK;;MAE1C;MACA,IAAID,UAAU,IAAI,IAAI,CAAC9B,QAAQ,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,GAAG4B,qBAAQ,CAACJ,gBAAgB,CACnD,QAAQ,EACPK,YAA4B,IAAK;MAChC;MACA,IAAIA,YAAY,KAAK,YAAY,IAAIA,YAAY,KAAK,UAAU,EAAE;QAChE,IAAI,CAACb,KAAK,CAAC,CAAC;MACd;IACF,CACF,CAAC;EACH;AACF;AAACc,OAAA,CAAApC,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -19,8 +19,9 @@ var _EventQueue = require("./EventQueue");
|
|
|
19
19
|
/**
|
|
20
20
|
* Main entry point for the Respectlytics SDK.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* v3.0.0 uses session-based analytics only:
|
|
23
23
|
* - Session IDs are generated automatically in RAM
|
|
24
|
+
* - Event queue is RAM-only (zero device storage)
|
|
24
25
|
* - Sessions rotate every 2 hours
|
|
25
26
|
* - New session on every app restart
|
|
26
27
|
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
@@ -61,7 +62,7 @@ class RespectlyticsSDK {
|
|
|
61
62
|
this.networkClient.configure(apiKey, options?.apiEndpoint);
|
|
62
63
|
this.eventQueue.start();
|
|
63
64
|
this.isConfigured = true;
|
|
64
|
-
console.log('[Respectlytics] ✓ SDK configured (
|
|
65
|
+
console.log('[Respectlytics] ✓ SDK configured (v3.0.0)');
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_SessionManager","_NetworkClient","_EventQueue","RespectlyticsSDK","isConfigured","constructor","networkClient","NetworkClient","eventQueue","EventQueue","sessionManager","SessionManager","platform","Platform","OS","configure","apiKey","options","trim","console","log","apiEndpoint","start","track","eventName","length","event","timestamp","Date","toISOString","sessionId","getSessionId","add","flush","exports","Respectlytics","_default","default"],"sourceRoot":"../../src","sources":["Respectlytics.ts"],"mappings":";;;;;;AAQA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,gBAAgB,CAAC;EACbC,YAAY,GAAG,KAAK;EAM5BC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,aAAa,GAAG,IAAIC,4BAAa,CAAC,CAAC;IACxC,IAAI,CAACC,UAAU,GAAG,IAAIC,sBAAU,CAAC,IAAI,CAACH,aAAa,CAAC;IACpD,IAAI,CAACI,cAAc,GAAG,IAAIC,8BAAc,CAAC,CAAC;IAC1C,IAAI,CAACC,QAAQ,GAAGC,qBAAQ,CAACC,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;MACnCC,OAAO,CAACC,GAAG,CAAC,4CAA4C,CAAC;MACzD;IACF;IAEA,IAAI,CAACd,aAAa,CAACS,SAAS,CAACC,MAAM,EAAEC,OAAO,EAAEI,WAAW,CAAC;IAC1D,IAAI,CAACb,UAAU,CAACc,KAAK,CAAC,CAAC;IACvB,IAAI,CAAClB,YAAY,GAAG,IAAI;IAExBe,OAAO,CAACC,GAAG,CAAC,2CAA2C,CAAC;EAC1D;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,KAAKA,CAACC,SAAiB,EAAQ;IAC7B,IAAI,CAAC,IAAI,CAACpB,YAAY,EAAE;MACtBe,OAAO,CAACC,GAAG,CAAC,sEAAsE,CAAC;MACnF;IACF;IAEA,IAAI,CAACI,SAAS,IAAIA,SAAS,CAACN,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;MACzCC,OAAO,CAACC,GAAG,CAAC,+CAA+C,CAAC;MAC5D;IACF;IAEA,IAAII,SAAS,CAACC,MAAM,GAAG,GAAG,EAAE;MAC1BN,OAAO,CAACC,GAAG,CAAC,6DAA6D,CAAC;MAC1E;IACF;IAEA,MAAMM,KAAY,GAAG;MACnBF,SAAS;MACTG,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;MACnCC,SAAS,EAAE,IAAI,CAACpB,cAAc,CAACqB,YAAY,CAAC,CAAC;MAC7CnB,QAAQ,EAAE,IAAI,CAACA;IACjB,CAAC;IAED,IAAI,CAACJ,UAAU,CAACwB,GAAG,CAACN,KAAK,CAAC;EAC5B;;EAEA;AACF;AACA;AACA;EACE,MAAMO,KAAKA,CAAA,EAAkB;IAC3B,MAAM,IAAI,CAACzB,UAAU,CAACyB,KAAK,CAAC,CAAC;EAC/B;AACF;;AAEA;AAAAC,OAAA,CAAA/B,gBAAA,GAAAA,gBAAA;AACA,MAAMgC,aAAa,GAAG,IAAIhC,gBAAgB,CAAC,CAAC;AAAC,IAAAiC,QAAA,GAAAF,OAAA,CAAAG,OAAA,GAC9BF,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_SessionManager","_NetworkClient","_EventQueue","RespectlyticsSDK","isConfigured","constructor","networkClient","NetworkClient","eventQueue","EventQueue","sessionManager","SessionManager","platform","Platform","OS","configure","apiKey","options","trim","console","log","apiEndpoint","start","track","eventName","length","event","timestamp","Date","toISOString","sessionId","getSessionId","add","flush","exports","Respectlytics","_default","default"],"sourceRoot":"../../src","sources":["Respectlytics.ts"],"mappings":";;;;;;AAQA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,gBAAgB,CAAC;EACbC,YAAY,GAAG,KAAK;EAM5BC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,aAAa,GAAG,IAAIC,4BAAa,CAAC,CAAC;IACxC,IAAI,CAACC,UAAU,GAAG,IAAIC,sBAAU,CAAC,IAAI,CAACH,aAAa,CAAC;IACpD,IAAI,CAACI,cAAc,GAAG,IAAIC,8BAAc,CAAC,CAAC;IAC1C,IAAI,CAACC,QAAQ,GAAGC,qBAAQ,CAACC,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;MACnCC,OAAO,CAACC,GAAG,CAAC,4CAA4C,CAAC;MACzD;IACF;IAEA,IAAI,CAACd,aAAa,CAACS,SAAS,CAACC,MAAM,EAAEC,OAAO,EAAEI,WAAW,CAAC;IAC1D,IAAI,CAACb,UAAU,CAACc,KAAK,CAAC,CAAC;IACvB,IAAI,CAAClB,YAAY,GAAG,IAAI;IAExBe,OAAO,CAACC,GAAG,CAAC,2CAA2C,CAAC;EAC1D;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,KAAKA,CAACC,SAAiB,EAAQ;IAC7B,IAAI,CAAC,IAAI,CAACpB,YAAY,EAAE;MACtBe,OAAO,CAACC,GAAG,CAAC,sEAAsE,CAAC;MACnF;IACF;IAEA,IAAI,CAACI,SAAS,IAAIA,SAAS,CAACN,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;MACzCC,OAAO,CAACC,GAAG,CAAC,+CAA+C,CAAC;MAC5D;IACF;IAEA,IAAII,SAAS,CAACC,MAAM,GAAG,GAAG,EAAE;MAC1BN,OAAO,CAACC,GAAG,CAAC,6DAA6D,CAAC;MAC1E;IACF;IAEA,MAAMM,KAAY,GAAG;MACnBF,SAAS;MACTG,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;MACnCC,SAAS,EAAE,IAAI,CAACpB,cAAc,CAACqB,YAAY,CAAC,CAAC;MAC7CnB,QAAQ,EAAE,IAAI,CAACA;IACjB,CAAC;IAED,IAAI,CAACJ,UAAU,CAACwB,GAAG,CAACN,KAAK,CAAC;EAC5B;;EAEA;AACF;AACA;AACA;EACE,MAAMO,KAAKA,CAAA,EAAkB;IAC3B,MAAM,IAAI,CAACzB,UAAU,CAACyB,KAAK,CAAC,CAAC;EAC/B;AACF;;AAEA;AAAAC,OAAA,CAAA/B,gBAAA,GAAAA,gBAAA;AACA,MAAMgC,aAAa,GAAG,IAAIhC,gBAAgB,CAAC,CAAC;AAAC,IAAAiC,QAAA,GAAAF,OAAA,CAAAG,OAAA,GAC9BF,aAAa","ignoreList":[]}
|
|
@@ -28,13 +28,13 @@ function generateUUID() {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Manages session ID generation and rotation.
|
|
31
|
-
*
|
|
31
|
+
*
|
|
32
32
|
* Session IDs are:
|
|
33
33
|
* - Generated immediately when the SDK initializes
|
|
34
34
|
* - Stored in RAM only (never persisted to AsyncStorage)
|
|
35
35
|
* - Rotated automatically every 2 hours
|
|
36
36
|
* - Regenerated on every app restart (new instance = new session)
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* This RAM-only approach means session data never touches device storage:
|
|
39
39
|
* - Sessions exist only in memory and are lost on app restart
|
|
40
40
|
* - Each app launch creates a fresh, unlinked session
|
package/lib/commonjs/index.js
CHANGED
|
@@ -21,12 +21,13 @@ var _types = require("./types");
|
|
|
21
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
22
22
|
/**
|
|
23
23
|
* Respectlytics React Native SDK
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* Official SDK for privacy-first, session-based analytics.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* v3.0.0 Features:
|
|
28
28
|
* - Session-based analytics (no persistent user tracking)
|
|
29
29
|
* - RAM-only session storage (never persisted to disk)
|
|
30
|
+
* - RAM-only event queue (zero device storage)
|
|
30
31
|
* - Automatic 2-hour session rotation
|
|
31
32
|
* - New session on every app restart
|
|
32
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Respectlytics","_interopRequireWildcard","require","_types","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","exports","Respectlytics"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"names":["_Respectlytics","_interopRequireWildcard","require","_types","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","exports","Respectlytics"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,IAAAA,cAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AAAgC,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AArBhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAAA,IAAAkB,QAAA,GAAAC,OAAA,CAAAV,OAAA,GACeW,sBAAa,EAE5B","ignoreList":[]}
|
package/lib/commonjs/types.js
CHANGED
|
@@ -1,36 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.STORAGE_KEYS = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* types.ts
|
|
9
|
-
* Respectlytics React Native SDK
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Represents an analytics event - flat structure matching API payload
|
|
16
|
-
*
|
|
17
|
-
* The SDK sends these 4 fields. The API stores 5 total
|
|
18
|
-
* (adding country, derived server-side from IP which is immediately discarded):
|
|
19
|
-
* - event_name (required)
|
|
20
|
-
* - timestamp
|
|
21
|
-
* - session_id
|
|
22
|
-
* - platform
|
|
23
|
-
*
|
|
24
|
-
* Country is derived server-side from IP (which is immediately discarded).
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Storage keys used by the SDK
|
|
29
|
-
*
|
|
30
|
-
* Note: Only the event queue is persisted.
|
|
31
|
-
* Session IDs are RAM-only for privacy.
|
|
32
|
-
*/
|
|
33
|
-
const STORAGE_KEYS = exports.STORAGE_KEYS = {
|
|
34
|
-
EVENT_QUEUE: 'com.respectlytics.eventQueue'
|
|
35
|
-
};
|
|
36
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
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
|
-
*
|
|
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
|
+
*
|
|
7
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,GAAkC,IAAI;EAElEC,WAAWA,CAACC,aAA4B,EAAE;IACxC,IAAI,CAACA,aAAa,GAAGA,aAAa;EACpC;;EAEA;AACF;AACA;EACEC,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACC,mBAAmB,CAAC,CAAC;IAC1B,IAAI,CAACC,oBAAoB,CAAC,CAAC;IAC3B,IAAI,CAACC,aAAa,CAAC,CAAC;IACpBC,OAAO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YAAY,KAAK,YAAY,IAAIA,YAAY,KAAK,UAAU,EAAE;QAChE,IAAI,CAACX,KAAK,CAAC,CAAC;MACd;IACF,CACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -14,8 +14,9 @@ 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
22
|
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
@@ -56,7 +57,7 @@ class RespectlyticsSDK {
|
|
|
56
57
|
this.networkClient.configure(apiKey, options?.apiEndpoint);
|
|
57
58
|
this.eventQueue.start();
|
|
58
59
|
this.isConfigured = true;
|
|
59
|
-
console.log('[Respectlytics] ✓ SDK configured (
|
|
60
|
+
console.log('[Respectlytics] ✓ SDK configured (v3.0.0)');
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
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;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MAC1E;IACF;IAEA,MAAMM,KAAY,GAAG;MACnBF,SAAS;MACTG,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;MACnCC,SAAS,EAAE,IAAI,CAAClB,cAAc,CAACmB,YAAY,CAAC,CAAC;MAC7ClB,QAAQ,EAAE,IAAI,CAACA;IACjB,CAAC;IAED,IAAI,CAACF,UAAU,CAACqB,GAAG,CAACN,KAAK,CAAC;EAC5B;;EAEA;AACF;AACA;AACA;EACE,MAAMO,KAAKA,CAAA,EAAkB;IAC3B,MAAM,IAAI,CAACtB,UAAU,CAACsB,KAAK,CAAC,CAAC;EAC/B;AACF;;AAEA;AACA,MAAMC,aAAa,GAAG,IAAI3B,gBAAgB,CAAC,CAAC;AAC5C,eAAe2B,aAAa;AAC5B,SAAS3B,gBAAgB","ignoreList":[]}
|
|
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,IAA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;IACjB,CAAC;IAED,IAAI,CAACF,UAAU,CAACqB,GAAG,CAACN,KAAK,CAAC;EAC5B;;EAEA;AACF;AACA;AACA;EACE,MAAMO,KAAKA,CAAA,EAAkB;IAC3B,MAAM,IAAI,CAACtB,UAAU,CAACsB,KAAK,CAAC,CAAC;EAC/B;AACF;;AAEA;AACA,MAAMC,aAAa,GAAG,IAAI3B,gBAAgB,CAAC,CAAC;AAC5C,eAAe2B,aAAa;AAC5B,SAAS3B,gBAAgB","ignoreList":[]}
|
|
@@ -22,13 +22,13 @@ 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
|
-
*
|
|
31
|
+
*
|
|
32
32
|
* This RAM-only approach means session data never touches device storage:
|
|
33
33
|
* - Sessions exist only in memory and are lost on app restart
|
|
34
34
|
* - Each app launch creates a fresh, unlinked session
|
package/lib/module/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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
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
|
*
|
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;AACA,OAAOA,aAAa,MAAM,iBAAiB;;AAE3C;AACA,eAAeA,aAAa;;AAE5B;AACA,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,KAAK,QAAQ,SAAS","ignoreList":[]}
|
|
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,30 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* types.ts
|
|
3
|
-
* Respectlytics React Native SDK
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
6
|
-
*/
|
|
7
1
|
|
|
8
|
-
/**
|
|
9
|
-
* Represents an analytics event - flat structure matching API payload
|
|
10
|
-
*
|
|
11
|
-
* The SDK sends these 4 fields. The API stores 5 total
|
|
12
|
-
* (adding country, derived server-side from IP which is immediately discarded):
|
|
13
|
-
* - event_name (required)
|
|
14
|
-
* - timestamp
|
|
15
|
-
* - session_id
|
|
16
|
-
* - platform
|
|
17
|
-
*
|
|
18
|
-
* Country is derived server-side from IP (which is immediately discarded).
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Storage keys used by the SDK
|
|
23
|
-
*
|
|
24
|
-
* Note: Only the event queue is persisted.
|
|
25
|
-
* Session IDs are RAM-only for privacy.
|
|
26
|
-
*/
|
|
27
|
-
export const STORAGE_KEYS = {
|
|
28
|
-
EVENT_QUEUE: 'com.respectlytics.eventQueue'
|
|
29
|
-
};
|
|
30
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,8 +2,17 @@
|
|
|
2
2
|
* EventQueue.ts
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
|
-
* Manages event batching
|
|
6
|
-
*
|
|
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
|
+
*
|
|
7
16
|
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
17
|
*/
|
|
9
18
|
import { Event } from './types';
|
|
@@ -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"}
|
|
@@ -8,8 +8,9 @@
|
|
|
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
16
|
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
@@ -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,9 +3,10 @@
|
|
|
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
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
|
*
|
|
@@ -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"}
|
|
@@ -22,13 +22,4 @@ export interface Event {
|
|
|
22
22
|
sessionId: string;
|
|
23
23
|
platform: string;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Storage keys used by the SDK
|
|
27
|
-
*
|
|
28
|
-
* Note: Only the event queue is persisted.
|
|
29
|
-
* Session IDs are RAM-only for privacy.
|
|
30
|
-
*/
|
|
31
|
-
export declare const STORAGE_KEYS: {
|
|
32
|
-
readonly EVENT_QUEUE: "com.respectlytics.eventQueue";
|
|
33
|
-
};
|
|
34
25
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "respectlytics-react-native",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Official Respectlytics SDK for React Native. Privacy-first analytics with automatic session management,
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Official Respectlytics SDK for React Native. Privacy-first analytics with automatic session management, zero device storage, and no device identifier collection.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"!**/.*"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"typescript": "tsc --noEmit",
|
|
19
|
+
"typescript": "tsc --noEmit --project tsconfig.build.json",
|
|
20
20
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
21
21
|
"build": "bob build",
|
|
22
22
|
"test": "jest",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@babel/preset-env": "^7.28.5",
|
|
51
51
|
"@babel/preset-typescript": "^7.28.5",
|
|
52
|
-
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
53
52
|
"@react-native-community/netinfo": "^11.3.0",
|
|
54
53
|
"@types/jest": "^29.5.12",
|
|
55
54
|
"@types/react": "^18.2.0",
|
|
@@ -64,15 +63,11 @@
|
|
|
64
63
|
"typescript": "^5.3.3"
|
|
65
64
|
},
|
|
66
65
|
"peerDependencies": {
|
|
67
|
-
"@react-native-async-storage/async-storage": ">=1.17.0",
|
|
68
66
|
"@react-native-community/netinfo": ">=9.0.0",
|
|
69
67
|
"react": ">=18.0.0",
|
|
70
68
|
"react-native": ">=0.70.0"
|
|
71
69
|
},
|
|
72
70
|
"peerDependenciesMeta": {
|
|
73
|
-
"@react-native-async-storage/async-storage": {
|
|
74
|
-
"optional": false
|
|
75
|
-
},
|
|
76
71
|
"@react-native-community/netinfo": {
|
|
77
72
|
"optional": false
|
|
78
73
|
}
|
package/src/EventQueue.ts
CHANGED
|
@@ -2,20 +2,27 @@
|
|
|
2
2
|
* EventQueue.ts
|
|
3
3
|
* Respectlytics React Native SDK
|
|
4
4
|
*
|
|
5
|
-
* Manages event batching
|
|
6
|
-
*
|
|
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
|
+
*
|
|
7
16
|
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
17
|
*/
|
|
9
18
|
|
|
10
19
|
import { AppState, AppStateStatus } from 'react-native';
|
|
11
20
|
import NetInfo, { NetInfoState } from '@react-native-community/netinfo';
|
|
12
21
|
import { Event } from './types';
|
|
13
|
-
import { Storage } from './Storage';
|
|
14
22
|
import { NetworkClient } from './NetworkClient';
|
|
15
23
|
|
|
16
24
|
const MAX_QUEUE_SIZE = 10;
|
|
17
25
|
const FLUSH_INTERVAL_MS = 30000; // 30 seconds
|
|
18
|
-
const QUEUE_STORAGE_KEY = 'com.respectlytics.eventQueue';
|
|
19
26
|
|
|
20
27
|
export class EventQueue {
|
|
21
28
|
private events: Event[] = [];
|
|
@@ -31,10 +38,9 @@ export class EventQueue {
|
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
/**
|
|
34
|
-
* Initialize the queue
|
|
41
|
+
* Initialize the queue — set up listeners and start flush timer
|
|
35
42
|
*/
|
|
36
|
-
|
|
37
|
-
await this.loadPersistedQueue();
|
|
43
|
+
start(): void {
|
|
38
44
|
this.setupNetworkMonitor();
|
|
39
45
|
this.setupAppStateMonitor();
|
|
40
46
|
this.scheduleFlush();
|
|
@@ -60,15 +66,11 @@ export class EventQueue {
|
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
/**
|
|
63
|
-
* Add an event to the queue
|
|
64
|
-
* CRITICAL: Events are persisted IMMEDIATELY before any async operations
|
|
69
|
+
* Add an event to the in-memory queue.
|
|
65
70
|
*/
|
|
66
|
-
|
|
71
|
+
add(event: Event): void {
|
|
67
72
|
this.events.push(event);
|
|
68
73
|
|
|
69
|
-
// IMMEDIATELY persist before any async operations
|
|
70
|
-
await this.persistQueue();
|
|
71
|
-
|
|
72
74
|
// Check if we should flush
|
|
73
75
|
if (this.events.length >= MAX_QUEUE_SIZE) {
|
|
74
76
|
this.flush();
|
|
@@ -98,7 +100,6 @@ export class EventQueue {
|
|
|
98
100
|
// Take a snapshot of events to send
|
|
99
101
|
const batch = [...this.events];
|
|
100
102
|
this.events = [];
|
|
101
|
-
await this.persistQueue();
|
|
102
103
|
|
|
103
104
|
try {
|
|
104
105
|
await this.networkClient.send(batch);
|
|
@@ -106,7 +107,6 @@ export class EventQueue {
|
|
|
106
107
|
} catch (error) {
|
|
107
108
|
// Re-add failed events to the front of the queue
|
|
108
109
|
this.events = [...batch, ...this.events];
|
|
109
|
-
await this.persistQueue();
|
|
110
110
|
console.log('[Respectlytics] Failed to send events, will retry later');
|
|
111
111
|
} finally {
|
|
112
112
|
this.isFlushing = false;
|
|
@@ -155,28 +155,4 @@ export class EventQueue {
|
|
|
155
155
|
}
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
private async persistQueue(): Promise<void> {
|
|
160
|
-
try {
|
|
161
|
-
await Storage.setItem(QUEUE_STORAGE_KEY, JSON.stringify(this.events));
|
|
162
|
-
} catch (error) {
|
|
163
|
-
console.log('[Respectlytics] Failed to persist queue:', error);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private async loadPersistedQueue(): Promise<void> {
|
|
168
|
-
try {
|
|
169
|
-
const data = await Storage.getItem(QUEUE_STORAGE_KEY);
|
|
170
|
-
if (data) {
|
|
171
|
-
const parsed = JSON.parse(data);
|
|
172
|
-
if (Array.isArray(parsed)) {
|
|
173
|
-
this.events = parsed;
|
|
174
|
-
console.log(`[Respectlytics] Loaded ${this.events.length} persisted event(s)`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
} catch (error) {
|
|
178
|
-
console.log('[Respectlytics] Failed to load persisted queue:', error);
|
|
179
|
-
this.events = [];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
158
|
}
|
package/src/Respectlytics.ts
CHANGED
|
@@ -15,8 +15,9 @@ import { EventQueue } from './EventQueue';
|
|
|
15
15
|
/**
|
|
16
16
|
* Main entry point for the Respectlytics SDK.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
18
|
+
* v3.0.0 uses session-based analytics only:
|
|
19
19
|
* - Session IDs are generated automatically in RAM
|
|
20
|
+
* - Event queue is RAM-only (zero device storage)
|
|
20
21
|
* - Sessions rotate every 2 hours
|
|
21
22
|
* - New session on every app restart
|
|
22
23
|
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
@@ -64,7 +65,7 @@ class RespectlyticsSDK {
|
|
|
64
65
|
this.eventQueue.start();
|
|
65
66
|
this.isConfigured = true;
|
|
66
67
|
|
|
67
|
-
console.log('[Respectlytics] ✓ SDK configured (
|
|
68
|
+
console.log('[Respectlytics] ✓ SDK configured (v3.0.0)');
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/**
|
package/src/index.ts
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
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
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
|
*
|
package/src/types.ts
CHANGED
|
@@ -23,13 +23,3 @@ export interface Event {
|
|
|
23
23
|
sessionId: string;
|
|
24
24
|
platform: string;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Storage keys used by the SDK
|
|
29
|
-
*
|
|
30
|
-
* Note: Only the event queue is persisted.
|
|
31
|
-
* Session IDs are RAM-only for privacy.
|
|
32
|
-
*/
|
|
33
|
-
export const STORAGE_KEYS = {
|
|
34
|
-
EVENT_QUEUE: 'com.respectlytics.eventQueue',
|
|
35
|
-
} as const;
|
package/lib/commonjs/Storage.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Storage = void 0;
|
|
7
|
-
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
-
* Storage.ts
|
|
11
|
-
* Respectlytics React Native SDK
|
|
12
|
-
*
|
|
13
|
-
* Wrapper around AsyncStorage for persisting SDK data.
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Storage wrapper providing typed access to AsyncStorage
|
|
20
|
-
*/
|
|
21
|
-
class Storage {
|
|
22
|
-
/**
|
|
23
|
-
* Get a string value from storage
|
|
24
|
-
*/
|
|
25
|
-
static async getItem(key) {
|
|
26
|
-
try {
|
|
27
|
-
return await _asyncStorage.default.getItem(key);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.log(`[Respectlytics] Failed to read from storage: ${key}`);
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Set a string value in storage
|
|
36
|
-
*/
|
|
37
|
-
static async setItem(key, value) {
|
|
38
|
-
try {
|
|
39
|
-
await _asyncStorage.default.setItem(key, value);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.log(`[Respectlytics] Failed to write to storage: ${key}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Remove a value from storage
|
|
47
|
-
*/
|
|
48
|
-
static async removeItem(key) {
|
|
49
|
-
try {
|
|
50
|
-
await _asyncStorage.default.removeItem(key);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.log(`[Respectlytics] Failed to remove from storage: ${key}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.Storage = Storage;
|
|
57
|
-
//# sourceMappingURL=Storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_asyncStorage","_interopRequireDefault","require","e","__esModule","default","Storage","getItem","key","AsyncStorage","error","console","log","setItem","value","removeItem","exports"],"sourceRoot":"../../src","sources":["Storage.ts"],"mappings":";;;;;;AASA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAqE,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AATrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACO,MAAMG,OAAO,CAAC;EACnB;AACF;AACA;EACE,aAAaC,OAAOA,CAACC,GAAW,EAA0B;IACxD,IAAI;MACF,OAAO,MAAMC,qBAAY,CAACF,OAAO,CAACC,GAAG,CAAC;IACxC,CAAC,CAAC,OAAOE,KAAK,EAAE;MACdC,OAAO,CAACC,GAAG,CAAC,gDAAgDJ,GAAG,EAAE,CAAC;MAClE,OAAO,IAAI;IACb;EACF;;EAEA;AACF;AACA;EACE,aAAaK,OAAOA,CAACL,GAAW,EAAEM,KAAa,EAAiB;IAC9D,IAAI;MACF,MAAML,qBAAY,CAACI,OAAO,CAACL,GAAG,EAAEM,KAAK,CAAC;IACxC,CAAC,CAAC,OAAOJ,KAAK,EAAE;MACdC,OAAO,CAACC,GAAG,CAAC,+CAA+CJ,GAAG,EAAE,CAAC;IACnE;EACF;;EAEA;AACF;AACA;EACE,aAAaO,UAAUA,CAACP,GAAW,EAAiB;IAClD,IAAI;MACF,MAAMC,qBAAY,CAACM,UAAU,CAACP,GAAG,CAAC;IACpC,CAAC,CAAC,OAAOE,KAAK,EAAE;MACdC,OAAO,CAACC,GAAG,CAAC,kDAAkDJ,GAAG,EAAE,CAAC;IACtE;EACF;AACF;AAACQ,OAAA,CAAAV,OAAA,GAAAA,OAAA","ignoreList":[]}
|
package/lib/module/Storage.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage.ts
|
|
3
|
-
* Respectlytics React Native SDK
|
|
4
|
-
*
|
|
5
|
-
* Wrapper around AsyncStorage for persisting SDK data.
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Storage wrapper providing typed access to AsyncStorage
|
|
14
|
-
*/
|
|
15
|
-
export class Storage {
|
|
16
|
-
/**
|
|
17
|
-
* Get a string value from storage
|
|
18
|
-
*/
|
|
19
|
-
static async getItem(key) {
|
|
20
|
-
try {
|
|
21
|
-
return await AsyncStorage.getItem(key);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.log(`[Respectlytics] Failed to read from storage: ${key}`);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Set a string value in storage
|
|
30
|
-
*/
|
|
31
|
-
static async setItem(key, value) {
|
|
32
|
-
try {
|
|
33
|
-
await AsyncStorage.setItem(key, value);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.log(`[Respectlytics] Failed to write to storage: ${key}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Remove a value from storage
|
|
41
|
-
*/
|
|
42
|
-
static async removeItem(key) {
|
|
43
|
-
try {
|
|
44
|
-
await AsyncStorage.removeItem(key);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.log(`[Respectlytics] Failed to remove from storage: ${key}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=Storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["AsyncStorage","Storage","getItem","key","error","console","log","setItem","value","removeItem"],"sourceRoot":"../../src","sources":["Storage.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,2CAA2C;;AAEpE;AACA;AACA;AACA,OAAO,MAAMC,OAAO,CAAC;EACnB;AACF;AACA;EACE,aAAaC,OAAOA,CAACC,GAAW,EAA0B;IACxD,IAAI;MACF,OAAO,MAAMH,YAAY,CAACE,OAAO,CAACC,GAAG,CAAC;IACxC,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACC,GAAG,CAAC,gDAAgDH,GAAG,EAAE,CAAC;MAClE,OAAO,IAAI;IACb;EACF;;EAEA;AACF;AACA;EACE,aAAaI,OAAOA,CAACJ,GAAW,EAAEK,KAAa,EAAiB;IAC9D,IAAI;MACF,MAAMR,YAAY,CAACO,OAAO,CAACJ,GAAG,EAAEK,KAAK,CAAC;IACxC,CAAC,CAAC,OAAOJ,KAAK,EAAE;MACdC,OAAO,CAACC,GAAG,CAAC,+CAA+CH,GAAG,EAAE,CAAC;IACnE;EACF;;EAEA;AACF;AACA;EACE,aAAaM,UAAUA,CAACN,GAAW,EAAiB;IAClD,IAAI;MACF,MAAMH,YAAY,CAACS,UAAU,CAACN,GAAG,CAAC;IACpC,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACC,GAAG,CAAC,kDAAkDH,GAAG,EAAE,CAAC;IACtE;EACF;AACF","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage.ts
|
|
3
|
-
* Respectlytics React Native SDK
|
|
4
|
-
*
|
|
5
|
-
* Wrapper around AsyncStorage for persisting SDK data.
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Storage wrapper providing typed access to AsyncStorage
|
|
11
|
-
*/
|
|
12
|
-
export declare class Storage {
|
|
13
|
-
/**
|
|
14
|
-
* Get a string value from storage
|
|
15
|
-
*/
|
|
16
|
-
static getItem(key: string): Promise<string | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Set a string value in storage
|
|
19
|
-
*/
|
|
20
|
-
static setItem(key: string, value: string): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Remove a value from storage
|
|
23
|
-
*/
|
|
24
|
-
static removeItem(key: string): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=Storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../src/Storage.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,qBAAa,OAAO;IAClB;;OAEG;WACU,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IASzD;;OAEG;WACU,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D;;OAEG;WACU,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOpD"}
|
package/src/Storage.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage.ts
|
|
3
|
-
* Respectlytics React Native SDK
|
|
4
|
-
*
|
|
5
|
-
* Wrapper around AsyncStorage for persisting SDK data.
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Storage wrapper providing typed access to AsyncStorage
|
|
14
|
-
*/
|
|
15
|
-
export class Storage {
|
|
16
|
-
/**
|
|
17
|
-
* Get a string value from storage
|
|
18
|
-
*/
|
|
19
|
-
static async getItem(key: string): Promise<string | null> {
|
|
20
|
-
try {
|
|
21
|
-
return await AsyncStorage.getItem(key);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.log(`[Respectlytics] Failed to read from storage: ${key}`);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Set a string value in storage
|
|
30
|
-
*/
|
|
31
|
-
static async setItem(key: string, value: string): Promise<void> {
|
|
32
|
-
try {
|
|
33
|
-
await AsyncStorage.setItem(key, value);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.log(`[Respectlytics] Failed to write to storage: ${key}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Remove a value from storage
|
|
41
|
-
*/
|
|
42
|
-
static async removeItem(key: string): Promise<void> {
|
|
43
|
-
try {
|
|
44
|
-
await AsyncStorage.removeItem(key);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.log(`[Respectlytics] Failed to remove from storage: ${key}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|