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/LICENSE
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2025 Respectlytics. All rights reserved.
|
|
1
|
+
MIT License
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
- View and read the source code for transparency and security review
|
|
6
|
-
- Install the SDK via official package managers (SPM, npm, pub.dev)
|
|
7
|
-
- Use the SDK to send analytics data to the official Respectlytics service
|
|
3
|
+
Copyright (c) 2025 Respectlytics
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
shall not be liable for any damages arising from the use of this SDK.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/respectlytics-react-native)
|
|
4
4
|
[](https://github.com/respectlytics/respectlytics-react-native)
|
|
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
|
|
|
11
11
|
Respectlytics helps developers avoid collecting personal data in the first place. We believe the best way to handle sensitive data is to never collect it.
|
|
12
12
|
|
|
13
|
-
Our SDK collects only 4 fields:
|
|
13
|
+
Our SDK collects only 4 fields, and the API stores 5 total:
|
|
14
14
|
- `event_name` - What happened
|
|
15
|
-
- `timestamp` - When it happened
|
|
15
|
+
- `timestamp` - When it happened
|
|
16
16
|
- `session_id` - Groups events in a session (RAM-only, auto-rotates)
|
|
17
17
|
- `platform` - iOS or Android
|
|
18
|
+
- `country` - Derived server-side from IP (IP immediately discarded, never stored)
|
|
18
19
|
|
|
19
20
|
That's it. No device identifiers, no fingerprinting, no persistent tracking.
|
|
20
21
|
|
|
@@ -22,7 +23,7 @@ That's it. No device identifiers, no fingerprinting, no persistent tracking.
|
|
|
22
23
|
|
|
23
24
|
- 🔒 **Privacy-First**: No device identifiers (IDFA, GAID, Android ID)
|
|
24
25
|
- ⚡ **Simple Integration**: 2 lines of code to get started
|
|
25
|
-
-
|
|
26
|
+
- 🧠 **RAM-Only**: Event queue and sessions held entirely in memory — zero device storage
|
|
26
27
|
- 🔄 **Automatic Sessions**: RAM-only, 2-hour rotation, new session on app restart
|
|
27
28
|
- 📱 **Cross-Platform**: iOS and Android support
|
|
28
29
|
|
|
@@ -35,13 +36,13 @@ That's it. No device identifiers, no fingerprinting, no persistent tracking.
|
|
|
35
36
|
## Installation
|
|
36
37
|
|
|
37
38
|
```bash
|
|
38
|
-
npm install respectlytics-react-native @react-native-
|
|
39
|
+
npm install respectlytics-react-native @react-native-community/netinfo
|
|
39
40
|
```
|
|
40
41
|
|
|
41
42
|
or with Yarn:
|
|
42
43
|
|
|
43
44
|
```bash
|
|
44
|
-
yarn add respectlytics-react-native @react-native-
|
|
45
|
+
yarn add respectlytics-react-native @react-native-community/netinfo
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
### iOS Setup
|
|
@@ -65,20 +66,36 @@ Respectlytics.configure('your-api-key');
|
|
|
65
66
|
// 2. Track events
|
|
66
67
|
Respectlytics.track('purchase');
|
|
67
68
|
Respectlytics.track('view_product');
|
|
69
|
+
|
|
70
|
+
// For self-hosted instances:
|
|
71
|
+
Respectlytics.configure('your-api-key', {
|
|
72
|
+
apiEndpoint: 'https://your-server.com/api/v1/events/',
|
|
73
|
+
});
|
|
68
74
|
```
|
|
69
75
|
|
|
70
76
|
That's it! Session management is fully automatic.
|
|
71
77
|
|
|
72
78
|
## API Reference
|
|
73
79
|
|
|
74
|
-
### `configure(apiKey: string)`
|
|
80
|
+
### `configure(apiKey: string, options?: { apiEndpoint?: string })`
|
|
75
81
|
|
|
76
82
|
Initialize the SDK with your API key. Call once at app startup.
|
|
77
83
|
|
|
78
84
|
```typescript
|
|
85
|
+
// Respectlytics Cloud (default)
|
|
79
86
|
Respectlytics.configure('your-api-key');
|
|
87
|
+
|
|
88
|
+
// Self-hosted instance
|
|
89
|
+
Respectlytics.configure('your-api-key', {
|
|
90
|
+
apiEndpoint: 'https://your-server.com/api/v1/events/',
|
|
91
|
+
});
|
|
80
92
|
```
|
|
81
93
|
|
|
94
|
+
| Parameter | Type | Required | Description |
|
|
95
|
+
|-----------|------|----------|-------------|
|
|
96
|
+
| `apiKey` | `string` | Yes | Your Respectlytics API key |
|
|
97
|
+
| `options.apiEndpoint` | `string` | No | Custom endpoint for self-hosted instances |
|
|
98
|
+
|
|
82
99
|
### `track(eventName: string)`
|
|
83
100
|
|
|
84
101
|
Track an event.
|
|
@@ -142,26 +159,61 @@ The SDK handles these automatically - no developer action needed:
|
|
|
142
159
|
| Feature | Behavior |
|
|
143
160
|
|---------|----------|
|
|
144
161
|
| **Session Management** | New session ID on app launch, rotates after 2 hours |
|
|
145
|
-
| **Event Batching** | Events queued and sent in batches (max 10 events or 30 seconds) |
|
|
146
|
-
| **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 |
|
|
147
164
|
| **Retry Logic** | Failed requests retry with exponential backoff (max 3 attempts) |
|
|
148
165
|
| **Background Sync** | Events flushed when app enters background |
|
|
149
166
|
|
|
150
|
-
##
|
|
167
|
+
## Event Queue (RAM-Only)
|
|
151
168
|
|
|
152
|
-
Events are
|
|
169
|
+
Events are held in memory and sent automatically:
|
|
153
170
|
|
|
154
|
-
1. Events are
|
|
171
|
+
1. Events are added to an in-memory array — nothing is written to device storage
|
|
155
172
|
2. Network status is monitored via NetInfo
|
|
156
173
|
3. Queue is flushed when connectivity is restored
|
|
157
174
|
4. Failed sends are retried with exponential backoff
|
|
158
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
|
+
|
|
200
|
+
## Migration from v2.1.x
|
|
201
|
+
|
|
202
|
+
### Changes in v2.2.0
|
|
203
|
+
|
|
204
|
+
- `configure()` now accepts an optional second argument `{ apiEndpoint }` for self-hosted instances
|
|
205
|
+
- License changed from proprietary to MIT
|
|
206
|
+
- The API stores 5 fields total (the 4 sent by the SDK plus `country` derived server-side)
|
|
207
|
+
|
|
208
|
+
### What to do
|
|
209
|
+
|
|
210
|
+
No breaking changes. Existing code works as-is.
|
|
211
|
+
|
|
159
212
|
## Migration from v2.0.x
|
|
160
213
|
|
|
161
214
|
### Changes in v2.1.0
|
|
162
215
|
|
|
163
216
|
- `track()` method now takes only `eventName` - the `screen` parameter has been removed
|
|
164
|
-
- The SDK now sends only 4 fields to the API (down from 10)
|
|
165
217
|
- Deprecated fields (`screen`, `os_version`, `app_version`, `locale`, `device_type`, `region`) are no longer collected
|
|
166
218
|
|
|
167
219
|
### What to do
|
|
@@ -182,7 +234,7 @@ Respectlytics provides a technical solution focused on privacy. Regulations vary
|
|
|
182
234
|
|
|
183
235
|
## License
|
|
184
236
|
|
|
185
|
-
This SDK is
|
|
237
|
+
This SDK is licensed under the [MIT License](LICENSE).
|
|
186
238
|
|
|
187
239
|
## Support
|
|
188
240
|
|
|
@@ -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
|
-
*
|
|
17
|
-
*
|
|
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
|
+
*
|
|
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,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,MAAMC,UAAU,GAAG,CAAC,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":[]}
|
|
@@ -9,10 +9,10 @@ exports.networkClient = exports.NetworkError = exports.NetworkClient = void 0;
|
|
|
9
9
|
* Respectlytics React Native SDK
|
|
10
10
|
*
|
|
11
11
|
* Handles HTTP communication with the Respectlytics API.
|
|
12
|
-
* Copyright (c) 2025 Respectlytics.
|
|
12
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const DEFAULT_API_ENDPOINT = 'https://respectlytics.com/api/v1/events/';
|
|
16
16
|
const MAX_RETRIES = 3;
|
|
17
17
|
const TIMEOUT_MS = 30000;
|
|
18
18
|
let NetworkError = exports.NetworkError = /*#__PURE__*/function (NetworkError) {
|
|
@@ -28,12 +28,16 @@ let NetworkError = exports.NetworkError = /*#__PURE__*/function (NetworkError) {
|
|
|
28
28
|
}({});
|
|
29
29
|
class NetworkClient {
|
|
30
30
|
apiKey = null;
|
|
31
|
+
apiEndpoint = DEFAULT_API_ENDPOINT;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
* Configure the network client with an API key
|
|
34
|
+
* Configure the network client with an API key and optional custom endpoint
|
|
34
35
|
*/
|
|
35
|
-
configure(apiKey) {
|
|
36
|
+
configure(apiKey, apiEndpoint) {
|
|
36
37
|
this.apiKey = apiKey;
|
|
38
|
+
if (apiEndpoint) {
|
|
39
|
+
this.apiEndpoint = apiEndpoint;
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/**
|
|
@@ -65,7 +69,7 @@ class NetworkClient {
|
|
|
65
69
|
const controller = new AbortController();
|
|
66
70
|
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
67
71
|
try {
|
|
68
|
-
const response = await fetch(
|
|
72
|
+
const response = await fetch(this.apiEndpoint, {
|
|
69
73
|
method: 'POST',
|
|
70
74
|
headers: {
|
|
71
75
|
'Content-Type': 'application/json',
|
|
@@ -129,8 +133,8 @@ class NetworkClient {
|
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
/**
|
|
132
|
-
* Convert Event object to API payload format
|
|
133
|
-
*
|
|
136
|
+
* Convert Event object to API payload format.
|
|
137
|
+
* The SDK sends 4 fields; the API stores 5 (adding country derived from IP).
|
|
134
138
|
*/
|
|
135
139
|
eventToPayload(event) {
|
|
136
140
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DEFAULT_API_ENDPOINT","MAX_RETRIES","TIMEOUT_MS","NetworkError","exports","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":";;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KAAK,CAACoC,SAAS;MAC3BC,QAAQ,EAAErC,KAAK,CAACqC;IAClB,CAAC;EACH;;EAEA;AACF;AACA;EACUf,KAAKA,CAACgB,EAAU,EAAiB;IACvC,OAAO,IAAIC,OAAO,CAACC,OAAO,IAAIlC,UAAU,CAACkC,OAAO,EAAEF,EAAE,CAAC,CAAC;EACxD;AACF;AAAChD,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAEM,MAAMkD,aAAa,GAAAnD,OAAA,CAAAmD,aAAA,GAAG,IAAIlD,aAAa,CAAC,CAAC","ignoreList":[]}
|
|
@@ -13,23 +13,27 @@ var _EventQueue = require("./EventQueue");
|
|
|
13
13
|
* Respectlytics React Native SDK
|
|
14
14
|
*
|
|
15
15
|
* Main entry point for the SDK.
|
|
16
|
-
* Copyright (c) 2025 Respectlytics.
|
|
16
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
17
17
|
*/
|
|
18
18
|
|
|
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
|
-
* - Only 4 fields sent
|
|
27
|
+
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
27
28
|
*
|
|
28
29
|
* Usage:
|
|
29
30
|
* ```typescript
|
|
30
31
|
* // 1. Configure at app launch
|
|
31
32
|
* Respectlytics.configure('your-api-key');
|
|
32
33
|
*
|
|
34
|
+
* // For self-hosted instances:
|
|
35
|
+
* Respectlytics.configure('your-api-key', { apiEndpoint: 'https://your-server.com/api/v1/events/' });
|
|
36
|
+
*
|
|
33
37
|
* // 2. Track events
|
|
34
38
|
* Respectlytics.track('purchase');
|
|
35
39
|
* ```
|
|
@@ -48,23 +52,24 @@ class RespectlyticsSDK {
|
|
|
48
52
|
* Call once at app startup.
|
|
49
53
|
*
|
|
50
54
|
* @param apiKey Your Respectlytics API key from the dashboard
|
|
55
|
+
* @param options Optional configuration (e.g., apiEndpoint for self-hosted instances)
|
|
51
56
|
*/
|
|
52
|
-
configure(apiKey) {
|
|
57
|
+
configure(apiKey, options) {
|
|
53
58
|
if (!apiKey || apiKey.trim() === '') {
|
|
54
59
|
console.log('[Respectlytics] ⚠️ API key cannot be empty');
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
57
|
-
this.networkClient.configure(apiKey);
|
|
62
|
+
this.networkClient.configure(apiKey, options?.apiEndpoint);
|
|
58
63
|
this.eventQueue.start();
|
|
59
64
|
this.isConfigured = true;
|
|
60
|
-
console.log('[Respectlytics] ✓ SDK configured (
|
|
65
|
+
console.log('[Respectlytics] ✓ SDK configured (v3.0.0)');
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
/**
|
|
64
69
|
* Track an event.
|
|
65
70
|
*
|
|
66
71
|
* Custom properties are NOT supported - this is by design for privacy.
|
|
67
|
-
* The API
|
|
72
|
+
* The API stores 5 fields (these 4 plus country derived server-side).
|
|
68
73
|
*
|
|
69
74
|
* @param eventName Name of the event (e.g., "purchase", "button_clicked")
|
|
70
75
|
*/
|
|
@@ -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","trim","console","log","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,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;EACEC,SAASA,CAACC,MAAc,EAAQ;
|
|
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;I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ACqB,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":[]}
|
|
@@ -9,10 +9,10 @@ exports.SessionManager = void 0;
|
|
|
9
9
|
* Respectlytics React Native SDK
|
|
10
10
|
*
|
|
11
11
|
* Manages session ID generation and rotation.
|
|
12
|
-
* Sessions are stored in RAM only (never persisted
|
|
12
|
+
* Sessions are stored in RAM only (never persisted to disk).
|
|
13
13
|
* Sessions automatically rotate every 2 hours.
|
|
14
14
|
*
|
|
15
|
-
* Copyright (c) 2025 Respectlytics.
|
|
15
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -28,15 +28,15 @@ 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
|
-
*
|
|
38
|
-
* This RAM-only approach
|
|
39
|
-
* -
|
|
37
|
+
*
|
|
38
|
+
* This RAM-only approach means session data never touches device storage:
|
|
39
|
+
* - Sessions exist only in memory and are lost on app restart
|
|
40
40
|
* - Each app launch creates a fresh, unlinked session
|
|
41
41
|
*/
|
|
42
42
|
class SessionManager {
|
package/lib/commonjs/index.js
CHANGED
|
@@ -21,16 +21,17 @@ 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
|
-
* - RAM-only session storage (
|
|
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
|
-
* Copyright (c) 2025 Respectlytics.
|
|
33
|
+
*
|
|
34
|
+
* Copyright (c) 2025 Respectlytics. Licensed under MIT.
|
|
34
35
|
*/
|
|
35
36
|
// Default export - the main SDK instance
|
|
36
37
|
var _default = exports.default = _Respectlytics.default; // Named exports for advanced usage
|
|
@@ -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":";;;;;;;;;;;;;;;;;;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;
|
|
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,37 +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. All rights reserved.
|
|
12
|
-
* This SDK is provided under a proprietary license.
|
|
13
|
-
* See LICENSE file for details.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Represents an analytics event - flat structure matching API payload
|
|
18
|
-
*
|
|
19
|
-
* v2.1.0: Only 4 fields are sent (strict API allowlist):
|
|
20
|
-
* - event_name (required)
|
|
21
|
-
* - timestamp
|
|
22
|
-
* - session_id
|
|
23
|
-
* - platform
|
|
24
|
-
*
|
|
25
|
-
* Country is derived server-side from IP (which is immediately discarded).
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Storage keys used by the SDK
|
|
30
|
-
*
|
|
31
|
-
* Note: Only the event queue is persisted.
|
|
32
|
-
* Session IDs are RAM-only for privacy.
|
|
33
|
-
*/
|
|
34
|
-
const STORAGE_KEYS = exports.STORAGE_KEYS = {
|
|
35
|
-
EVENT_QUEUE: 'com.respectlytics.eventQueue'
|
|
36
|
-
};
|
|
37
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|