riuve-rn 1.0.1 → 1.0.3
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 +5 -6
- package/dist/Riuve.d.ts +4 -0
- package/dist/Riuve.d.ts.map +1 -1
- package/dist/Riuve.js +37 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/storage.d.ts +2 -0
- package/dist/types/storage.d.ts.map +1 -1
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ export default function App() {
|
|
|
98
98
|
|
|
99
99
|
const initializeSDK = async () => {
|
|
100
100
|
try {
|
|
101
|
-
// Get your API key from
|
|
101
|
+
// Get your API key from Riuve dashboard
|
|
102
102
|
await Riuve.initialize('riuve_base_xxxxxxxxxxxxxxxxxxxxx', {
|
|
103
103
|
// Basic configuration
|
|
104
104
|
batchSize: 10, // Number of events per batch (default: 10)
|
|
@@ -119,7 +119,7 @@ export default function App() {
|
|
|
119
119
|
|
|
120
120
|
**Important Notes:**
|
|
121
121
|
- The `baseUrl` is hardcoded in the SDK (`https://api.riuve.com`), no need to pass it
|
|
122
|
-
- Get your API key from the [
|
|
122
|
+
- Get your API key from the [Riuve Dashboard](https://dashboard.riuve.com)
|
|
123
123
|
|
|
124
124
|
### Step 2: Identify Users
|
|
125
125
|
|
|
@@ -559,12 +559,12 @@ await Riuve.initialize(apiKey: string, config?: RiuveConfig): Promise<void>
|
|
|
559
559
|
```
|
|
560
560
|
|
|
561
561
|
**Parameters:**
|
|
562
|
-
- `apiKey` (string, required): Your API key from
|
|
562
|
+
- `apiKey` (string, required): Your API key from Riuve dashboard
|
|
563
563
|
- `config` (object, optional): Configuration object
|
|
564
564
|
|
|
565
565
|
**Example:**
|
|
566
566
|
```typescript
|
|
567
|
-
await Riuve.initialize('
|
|
567
|
+
await Riuve.initialize('riuve_base_xxx', {
|
|
568
568
|
batchSize: 10,
|
|
569
569
|
});
|
|
570
570
|
```
|
|
@@ -824,7 +824,7 @@ const handleInAppPurchase = async (item: Item) => {
|
|
|
824
824
|
const API_KEY = process.env.EXPO_PUBLIC_RIUVE_API_KEY || '';
|
|
825
825
|
|
|
826
826
|
// ❌ BAD: Hardcoded
|
|
827
|
-
const API_KEY = '
|
|
827
|
+
const API_KEY = 'riuve_base_xxxxxxxxxxxxx';
|
|
828
828
|
```
|
|
829
829
|
|
|
830
830
|
---
|
|
@@ -834,7 +834,6 @@ const API_KEY = 'nock_live_xxxxxxxxxxxxx';
|
|
|
834
834
|
For questions and support:
|
|
835
835
|
- 📧 Email: support@riuve.com
|
|
836
836
|
- 📚 Documentation: https://docs.riuve.com
|
|
837
|
-
- 💬 Discord: [Nock Community](https://discord.gg/nock)
|
|
838
837
|
|
|
839
838
|
---
|
|
840
839
|
|
package/dist/Riuve.d.ts
CHANGED
|
@@ -53,6 +53,10 @@ declare class RiuveSDK {
|
|
|
53
53
|
* Gets the external user ID
|
|
54
54
|
*/
|
|
55
55
|
getExternalUserId(): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Sets locale override and syncs to backend (updates session locale).
|
|
58
|
+
*/
|
|
59
|
+
setLocale(locale: string): Promise<void>;
|
|
56
60
|
/**
|
|
57
61
|
* Gets the current configuration
|
|
58
62
|
*/
|
package/dist/Riuve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Riuve.d.ts","sourceRoot":"","sources":["../src/Riuve.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,SAAS,CAAC;AAWlD,cAAM,QAAQ;IACZ,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAyB;IAChD,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,aAAa,CAAkB;IAEvC,OAAO,CAAC,UAAU,CAA2B;IAC7C,O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M,CAAC,MAAM,EAAE,GAAG,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC;IAuChB;;OAEG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAuDpF;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC/C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB5B;;OAEG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAO/B;;OAEG;IACH,iBAAiB,IAAI,MAAM,GAAG,IAAI;IAOlC;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB9C;;OAEG;IACH,SAAS,IAAI,WAAW,GAAG,IAAI;IAI/B;;OAEG;IACH,YAAY,IAAI,MAAM;IAOtB;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAO5C;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA4B/B;AAGD,QAAA,MAAM,KAAK,UAAyB,CAAC;AAErC,eAAe,KAAK,CAAC"}
|
package/dist/Riuve.js
CHANGED
|
@@ -51,6 +51,13 @@ class RiuveSDK {
|
|
|
51
51
|
...config,
|
|
52
52
|
apiKey,
|
|
53
53
|
};
|
|
54
|
+
// Restore persisted locale override if not passed in config
|
|
55
|
+
if (this.config.localeOverride === undefined) {
|
|
56
|
+
const storedLocale = await Storage_1.storage.get('LOCALE_OVERRIDE');
|
|
57
|
+
if (storedLocale) {
|
|
58
|
+
this.config.localeOverride = storedLocale;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
54
61
|
// Enable debug mode if configured
|
|
55
62
|
logger_1.logger.setDebugMode(this.config.debugMode);
|
|
56
63
|
logger_1.logger.info('Initializing Riuve SDK...');
|
|
@@ -70,7 +77,10 @@ class RiuveSDK {
|
|
|
70
77
|
// Initialize batch manager
|
|
71
78
|
this.batchManager = new BatchManager_1.BatchManager(this.eventQueue, this.apiClient, this.networkManager, this.identityManager, this.config.eventRetentionDays);
|
|
72
79
|
// Collect device info
|
|
73
|
-
|
|
80
|
+
let deviceInfo = await DeviceInfo_1.deviceInfoCollector.collect();
|
|
81
|
+
if (this.config.localeOverride) {
|
|
82
|
+
deviceInfo = { ...deviceInfo, locale: this.config.localeOverride };
|
|
83
|
+
}
|
|
74
84
|
// Call initialize endpoint
|
|
75
85
|
if (this.networkManager.isConnected()) {
|
|
76
86
|
try {
|
|
@@ -307,6 +317,32 @@ class RiuveSDK {
|
|
|
307
317
|
}
|
|
308
318
|
return this.identityManager.getExternalUserId();
|
|
309
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Sets locale override and syncs to backend (updates session locale).
|
|
322
|
+
*/
|
|
323
|
+
async setLocale(locale) {
|
|
324
|
+
this.ensureInitialized();
|
|
325
|
+
if (!this.config)
|
|
326
|
+
return;
|
|
327
|
+
this.config.localeOverride = locale;
|
|
328
|
+
await Storage_1.storage.set('LOCALE_OVERRIDE', locale);
|
|
329
|
+
DeviceInfo_1.deviceInfoCollector.clearCache();
|
|
330
|
+
let deviceInfo = await DeviceInfo_1.deviceInfoCollector.collect();
|
|
331
|
+
deviceInfo = { ...deviceInfo, locale };
|
|
332
|
+
const anonymousId = this.identityManager.getAnonymousId();
|
|
333
|
+
if (anonymousId && this.networkManager.isConnected()) {
|
|
334
|
+
try {
|
|
335
|
+
await this.apiClient.initialize({
|
|
336
|
+
anonymous_id: anonymousId,
|
|
337
|
+
device_info: deviceInfo,
|
|
338
|
+
});
|
|
339
|
+
logger_1.logger.info('Locale updated on backend');
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
logger_1.logger.warn('Failed to update locale on backend:', error);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
310
346
|
/**
|
|
311
347
|
* Gets the current configuration
|
|
312
348
|
*/
|
package/dist/constants.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const STORAGE_KEYS: {
|
|
|
9
9
|
readonly FCM_TOKEN: "@riuve/fcm_token";
|
|
10
10
|
readonly EVENT_QUEUE: "@riuve/event_queue";
|
|
11
11
|
readonly FAILED_BATCHES: "@riuve/failed_batches";
|
|
12
|
+
readonly LOCALE_OVERRIDE: "@riuve/locale_override";
|
|
12
13
|
};
|
|
13
14
|
export declare const DEFAULT_CONFIG: {
|
|
14
15
|
readonly batchSize: 10;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC;AAEX,eAAO,MAAM,YAAY,0BAA0B,CAAC;AAEpD,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;CAQjB,CAAC"}
|
package/dist/constants.js
CHANGED
package/dist/types/config.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface RiuveConfig {
|
|
|
24
24
|
requestTimeout: number;
|
|
25
25
|
/** Enable debug mode with detailed logging (default: false) */
|
|
26
26
|
debugMode: boolean;
|
|
27
|
+
/** Override device locale for session (e.g. 'tr', 'en', 'ar'). Persisted and sent to backend. */
|
|
28
|
+
localeOverride?: string;
|
|
27
29
|
}
|
|
28
30
|
/** Partial configuration that can be passed during initialization */
|
|
29
31
|
export type RiuveConfigInput = Partial<Omit<RiuveConfig, 'apiKey'>> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IAEf,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAElB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IAErB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IAEnB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IAEnB,oEAAoE;IACpE,aAAa,EAAE,OAAO,CAAC;IAEvB,6EAA6E;IAC7E,qBAAqB,EAAE,OAAO,CAAC;IAE/B,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IAErB,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,CAAC;IAE3B,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IAEvB,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IAEf,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAElB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IAErB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IAEnB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IAEnB,oEAAoE;IACpE,aAAa,EAAE,OAAO,CAAC;IAEvB,6EAA6E;IAC7E,qBAAqB,EAAE,OAAO,CAAC;IAE/B,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IAErB,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,CAAC;IAE3B,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IAEvB,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;IAEnB,iGAAiG;IACjG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qEAAqE;AACrE,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,GAAG;IACpE,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/dist/types/storage.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface StorageSchema {
|
|
|
18
18
|
EVENT_QUEUE: Event[];
|
|
19
19
|
/** Failed batches that need to be retried */
|
|
20
20
|
FAILED_BATCHES: FailedBatch[];
|
|
21
|
+
/** Override locale for session (e.g. 'tr', 'en', 'ar') */
|
|
22
|
+
LOCALE_OVERRIDE: string;
|
|
21
23
|
}
|
|
22
24
|
/** Storage keys type */
|
|
23
25
|
export type StorageKey = keyof StorageSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/types/storage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE/D,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IAErB,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAE5C,gCAAgC;IAChC,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;IAE/B,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,yCAAyC;IACzC,WAAW,EAAE,KAAK,EAAE,CAAC;IAErB,6CAA6C;IAC7C,cAAc,EAAE,WAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/types/storage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE/D,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IAErB,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAE5C,gCAAgC;IAChC,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;IAE/B,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,yCAAyC;IACzC,WAAW,EAAE,KAAK,EAAE,CAAC;IAErB,6CAA6C;IAC7C,cAAc,EAAE,WAAW,EAAE,CAAC;IAE9B,0DAA0D;IAC1D,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,wBAAwB;AACxB,MAAM,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;AAE7C,sCAAsC;AACtC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "riuve-rn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Behavioral event tracking SDK for React Native with offline support and intelligent batching",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"author": "",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react-native": ">=
|
|
31
|
-
"
|
|
30
|
+
"@react-native-async-storage/async-storage": ">=1.19.0",
|
|
31
|
+
"react-native": ">=0.70.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
34
34
|
"react-native-device-info": {
|
|
@@ -50,16 +50,15 @@
|
|
|
50
50
|
"optional": true
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
-
"dependencies": {},
|
|
54
53
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"typescript": "^5.3.0",
|
|
57
|
-
"jest": "^29.7.0",
|
|
54
|
+
"@react-native-community/netinfo": "^11.5.2",
|
|
58
55
|
"@types/jest": "^29.5.0",
|
|
59
|
-
"
|
|
56
|
+
"@types/react-native": "^0.72.0",
|
|
60
57
|
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
|
61
58
|
"@typescript-eslint/parser": "^6.15.0",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
59
|
+
"eslint": "^8.55.0",
|
|
60
|
+
"jest": "^29.7.0",
|
|
61
|
+
"react-native-device-info": "^15.0.1",
|
|
62
|
+
"typescript": "^5.3.0"
|
|
64
63
|
}
|
|
65
64
|
}
|