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/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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"url": "git+https://github.com/respectlytics/respectlytics-react-native.git"
|
|
39
39
|
},
|
|
40
40
|
"author": "Respectlytics <respectlytics@loheden.com>",
|
|
41
|
-
"license": "
|
|
41
|
+
"license": "MIT",
|
|
42
42
|
"bugs": {
|
|
43
43
|
"url": "https://github.com/respectlytics/respectlytics-react-native/issues"
|
|
44
44
|
},
|
|
@@ -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
|
@@ -1,21 +1,28 @@
|
|
|
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, 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
|
-
|
|
69
|
-
// IMMEDIATELY persist before any async operations
|
|
70
|
-
await this.persistQueue();
|
|
71
|
-
|
|
73
|
+
|
|
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/NetworkClient.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
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
9
|
import { Event } from './types';
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const DEFAULT_API_ENDPOINT = 'https://respectlytics.com/api/v1/events/';
|
|
12
12
|
const MAX_RETRIES = 3;
|
|
13
13
|
const TIMEOUT_MS = 30000;
|
|
14
14
|
|
|
@@ -25,12 +25,16 @@ export enum NetworkError {
|
|
|
25
25
|
|
|
26
26
|
export class NetworkClient {
|
|
27
27
|
private apiKey: string | null = null;
|
|
28
|
+
private apiEndpoint: string = DEFAULT_API_ENDPOINT;
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
|
-
* Configure the network client with an API key
|
|
31
|
+
* Configure the network client with an API key and optional custom endpoint
|
|
31
32
|
*/
|
|
32
|
-
configure(apiKey: string): void {
|
|
33
|
+
configure(apiKey: string, apiEndpoint?: string): void {
|
|
33
34
|
this.apiKey = apiKey;
|
|
35
|
+
if (apiEndpoint) {
|
|
36
|
+
this.apiEndpoint = apiEndpoint;
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
/**
|
|
@@ -65,7 +69,7 @@ export class NetworkClient {
|
|
|
65
69
|
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
66
70
|
|
|
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',
|
|
@@ -137,8 +141,8 @@ export class NetworkClient {
|
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
/**
|
|
140
|
-
* Convert Event object to API payload format
|
|
141
|
-
*
|
|
144
|
+
* Convert Event object to API payload format.
|
|
145
|
+
* The SDK sends 4 fields; the API stores 5 (adding country derived from IP).
|
|
142
146
|
*/
|
|
143
147
|
private eventToPayload(event: Event): Record<string, unknown> {
|
|
144
148
|
return {
|
package/src/Respectlytics.ts
CHANGED
|
@@ -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';
|
|
@@ -15,17 +15,21 @@ 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
|
-
* - Only 4 fields sent
|
|
23
|
+
* - Only 4 fields sent by SDK; 5 stored (country derived server-side)
|
|
23
24
|
*
|
|
24
25
|
* Usage:
|
|
25
26
|
* ```typescript
|
|
26
27
|
* // 1. Configure at app launch
|
|
27
28
|
* Respectlytics.configure('your-api-key');
|
|
28
29
|
*
|
|
30
|
+
* // For self-hosted instances:
|
|
31
|
+
* Respectlytics.configure('your-api-key', { apiEndpoint: 'https://your-server.com/api/v1/events/' });
|
|
32
|
+
*
|
|
29
33
|
* // 2. Track events
|
|
30
34
|
* Respectlytics.track('purchase');
|
|
31
35
|
* ```
|
|
@@ -49,25 +53,26 @@ class RespectlyticsSDK {
|
|
|
49
53
|
* Call once at app startup.
|
|
50
54
|
*
|
|
51
55
|
* @param apiKey Your Respectlytics API key from the dashboard
|
|
56
|
+
* @param options Optional configuration (e.g., apiEndpoint for self-hosted instances)
|
|
52
57
|
*/
|
|
53
|
-
configure(apiKey: string): void {
|
|
58
|
+
configure(apiKey: string, options?: { apiEndpoint?: string }): void {
|
|
54
59
|
if (!apiKey || apiKey.trim() === '') {
|
|
55
60
|
console.log('[Respectlytics] ⚠️ API key cannot be empty');
|
|
56
61
|
return;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
this.networkClient.configure(apiKey);
|
|
64
|
+
this.networkClient.configure(apiKey, options?.apiEndpoint);
|
|
60
65
|
this.eventQueue.start();
|
|
61
66
|
this.isConfigured = true;
|
|
62
67
|
|
|
63
|
-
console.log('[Respectlytics] ✓ SDK configured (
|
|
68
|
+
console.log('[Respectlytics] ✓ SDK configured (v3.0.0)');
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
72
|
* Track an event.
|
|
68
73
|
*
|
|
69
74
|
* Custom properties are NOT supported - this is by design for privacy.
|
|
70
|
-
* The API
|
|
75
|
+
* The API stores 5 fields (these 4 plus country derived server-side).
|
|
71
76
|
*
|
|
72
77
|
* @param eventName Name of the event (e.g., "purchase", "button_clicked")
|
|
73
78
|
*/
|
package/src/SessionManager.ts
CHANGED
|
@@ -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
|
/**
|
|
@@ -22,15 +22,15 @@ function generateUUID(): string {
|
|
|
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/src/index.ts
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/src/types.ts
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
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
|
/**
|
|
11
9
|
* Represents an analytics event - flat structure matching API payload
|
|
12
10
|
*
|
|
13
|
-
*
|
|
11
|
+
* The SDK sends these 4 fields. The API stores 5 total
|
|
12
|
+
* (adding country, derived server-side from IP which is immediately discarded):
|
|
14
13
|
* - event_name (required)
|
|
15
14
|
* - timestamp
|
|
16
15
|
* - session_id
|
|
@@ -24,13 +23,3 @@ export interface Event {
|
|
|
24
23
|
sessionId: string;
|
|
25
24
|
platform: string;
|
|
26
25
|
}
|
|
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
|
-
export const STORAGE_KEYS = {
|
|
35
|
-
EVENT_QUEUE: 'com.respectlytics.eventQueue',
|
|
36
|
-
} 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. All rights reserved.
|
|
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. All rights reserved.
|
|
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. All rights reserved.
|
|
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. All rights reserved.
|
|
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
|
-
}
|