@osano/osano-cmp-react-native 0.17.0 → 0.17.1
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.dev.md +130 -0
- package/README.md +1 -1
- package/package.json +15 -5
package/README.dev.md
CHANGED
|
@@ -396,6 +396,136 @@ const {
|
|
|
396
396
|
} = React.useContext(OsanoContext);
|
|
397
397
|
```
|
|
398
398
|
|
|
399
|
+
#### Internal Developer API Reference
|
|
400
|
+
|
|
401
|
+
The following methods are exposed through the `OsanoContext` for internal development and debugging:
|
|
402
|
+
|
|
403
|
+
##### `getConsent(category?: ConsentCategory): boolean | ConsentCategory[]`
|
|
404
|
+
|
|
405
|
+
**Internal Implementation Details:**
|
|
406
|
+
- Delegates to `consentManager.current.hasConsent(category)` for specific category checks
|
|
407
|
+
- Returns `consentManager.current.consent ?? [ConsentCategory.ESSENTIAL]` for all categories
|
|
408
|
+
- Backed by the `getConsent` selector in `src/selectors.ts` which reads from `state.consent`
|
|
409
|
+
- State is managed through the reducer pattern with thunk middleware
|
|
410
|
+
|
|
411
|
+
```js
|
|
412
|
+
// Development usage examples:
|
|
413
|
+
const analyticsConsent = getConsent('ANALYTICS'); // boolean check
|
|
414
|
+
const allCategories = getConsent(); // array of consented categories
|
|
415
|
+
|
|
416
|
+
// Available categories from src/constants.ts:
|
|
417
|
+
// ESSENTIAL, ANALYTICS, MARKETING, PERSONALIZATION, OPT_OUT, STORAGE
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
##### `clearConsent(): void`
|
|
421
|
+
|
|
422
|
+
**Internal Implementation Details:**
|
|
423
|
+
- Dispatches `CLEAR_CONSENT` action to reset state
|
|
424
|
+
- Triggers Google Consent Mode update with only `ConsentCategory.ESSENTIAL`
|
|
425
|
+
- Clears both local storage and remote consent records
|
|
426
|
+
- Implemented in `handleClearConsent` with `useCallback` optimization
|
|
427
|
+
|
|
428
|
+
```js
|
|
429
|
+
// Development debugging:
|
|
430
|
+
clearConsent(); // Resets to clean slate for testing
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
##### `getDeviceId(): string`
|
|
434
|
+
|
|
435
|
+
**Internal Implementation Details:**
|
|
436
|
+
- Returns `consentManager.current.deviceId` property
|
|
437
|
+
- Device ID is fetched asynchronously via native module in `src/native/OsanoCmp.ts`
|
|
438
|
+
- Used for cross-device consent tracking and analytics correlation
|
|
439
|
+
- Persisted across app sessions for consistent identification
|
|
440
|
+
|
|
441
|
+
```js
|
|
442
|
+
// Development debugging:
|
|
443
|
+
const deviceId = getDeviceId();
|
|
444
|
+
console.log(`[DevDebug] Device ID: ${deviceId}`);
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
##### `locale: string`
|
|
448
|
+
|
|
449
|
+
**Internal Implementation Details:**
|
|
450
|
+
- Read from `consentManager.current.translator.locale`
|
|
451
|
+
- Managed by the `Translator` class in `src/utils/Translator.ts`
|
|
452
|
+
- Default is `Translator.DEFAULT_LANGUAGE` ('en')
|
|
453
|
+
- Triggers UI re-renders when changed via dependency array
|
|
454
|
+
|
|
455
|
+
```js
|
|
456
|
+
// Development debugging:
|
|
457
|
+
console.log(`[DevDebug] Current locale: ${locale}`);
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
##### `setLocale(locale: string): void`
|
|
461
|
+
|
|
462
|
+
**Internal Implementation Details:**
|
|
463
|
+
- Calls `consentManager.current.translator.load()` with success/failure callbacks
|
|
464
|
+
- Dispatches `setLocale(value)` action on successful load
|
|
465
|
+
- Uses exponential backoff retry logic for network failures
|
|
466
|
+
- Locale files fetched from `env.LOCALE_URI` endpoint
|
|
467
|
+
|
|
468
|
+
```js
|
|
469
|
+
// Development testing:
|
|
470
|
+
setLocale('es'); // Test Spanish localization
|
|
471
|
+
setLocale('invalid'); // Test error handling
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
##### `showBanner(): void`
|
|
475
|
+
|
|
476
|
+
**Internal Implementation Details:**
|
|
477
|
+
- Uses `retryWithBackoff` helper with 3 retries and exponential delay (100ms base)
|
|
478
|
+
- Dispatches `showDialog()` thunk action
|
|
479
|
+
- Checks `consentManager.current.loaded` state before execution
|
|
480
|
+
- Geographic location determines UI variant and timeout behavior
|
|
481
|
+
|
|
482
|
+
```js
|
|
483
|
+
// Development debugging:
|
|
484
|
+
try {
|
|
485
|
+
showBanner();
|
|
486
|
+
} catch (error) {
|
|
487
|
+
console.log('[DevDebug] Banner show failed:', error);
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
##### `showDrawer(): void`
|
|
492
|
+
|
|
493
|
+
**Internal Implementation Details:**
|
|
494
|
+
- Similar retry logic to `showBanner()` but dispatches `showDrawer()` thunk
|
|
495
|
+
- No automatic timeout - requires explicit user interaction
|
|
496
|
+
- Renders all consent categories with toggle controls
|
|
497
|
+
- State managed through drawer stack in `state.stack`
|
|
498
|
+
|
|
499
|
+
```js
|
|
500
|
+
// Development testing:
|
|
501
|
+
showDrawer(); // Always requires user interaction to dismiss
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
##### `isReady: boolean`
|
|
505
|
+
|
|
506
|
+
**Internal Implementation Details:**
|
|
507
|
+
- Reflects `consentManager.current.loaded` property
|
|
508
|
+
- Set to `true` after successful config loading in `ConsentManager.load()`
|
|
509
|
+
- Dependency in `useMemo` for context value - triggers re-renders
|
|
510
|
+
- Critical for preventing race conditions in consent operations
|
|
511
|
+
|
|
512
|
+
```js
|
|
513
|
+
// Development pattern:
|
|
514
|
+
useEffect(() => {
|
|
515
|
+
if (isReady) {
|
|
516
|
+
console.log('[DevDebug] SDK ready for operations');
|
|
517
|
+
// Safe to call other methods
|
|
518
|
+
}
|
|
519
|
+
}, [isReady]);
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
**Development Notes:**
|
|
523
|
+
- All methods use `useCallback` for performance optimization
|
|
524
|
+
- State management follows Redux-like pattern with actions and reducers
|
|
525
|
+
- Native bridge communication handled through `react-native` `NativeModules`
|
|
526
|
+
- Error boundaries should wrap components using these methods
|
|
527
|
+
- Testing with both Legacy and New Architecture supported via test scripts
|
|
528
|
+
|
|
399
529
|
### UI Builder
|
|
400
530
|
|
|
401
531
|
Now that you have created an instance of the `ConsentManager`, you can
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# Osano CMP SDK for React Native
|
|
2
2
|
|
|
3
|
-
Visit the [Developer Docs](https://developers.osano.com/cmp/react-native/) to learn more about installation and usage.
|
|
3
|
+
Visit the [Developer Docs](https://developers.osano.com/cmp/mobile-sdks/react-native/) to learn more about installation and usage.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osano/osano-cmp-react-native",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Package and example for the react-native Osano CMP SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"update:locale": "node ./scripts/updateLocalization.js",
|
|
42
42
|
"prepare": "bob build",
|
|
43
43
|
"release": "release-it",
|
|
44
|
-
"release:prod": "release-it
|
|
44
|
+
"release:prod": "release-it --no-increment --no-git --ci -VV",
|
|
45
45
|
"doc:start": "docusaurus start ./documentation",
|
|
46
46
|
"doc:build": "docusaurus build ./documentation",
|
|
47
47
|
"doc:clear": "docusaurus clear ./documentation",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
],
|
|
55
55
|
"repository": {
|
|
56
56
|
"type": "git",
|
|
57
|
-
"url": "
|
|
57
|
+
"url": ""
|
|
58
58
|
},
|
|
59
59
|
"author": "Osano (A Public Benefit Company) <engineering@osano.com> (https://www.osano.com)",
|
|
60
60
|
"license": "UNLICENSED",
|
|
61
61
|
"bugs": {
|
|
62
62
|
"url": "https://github.com/osano/osano-consentmgr-react-native/issues"
|
|
63
63
|
},
|
|
64
|
-
"homepage": "https://
|
|
64
|
+
"homepage": "https://developers.osano.com/cmp/mobile-sdks/",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"registry": "https://registry.npmjs.org/",
|
|
67
67
|
"access": "public"
|
|
@@ -135,11 +135,21 @@
|
|
|
135
135
|
]
|
|
136
136
|
},
|
|
137
137
|
"release-it": {
|
|
138
|
+
"git": {
|
|
139
|
+
"requireBranch": false,
|
|
140
|
+
"commit": false,
|
|
141
|
+
"tag": false,
|
|
142
|
+
"push": false
|
|
143
|
+
},
|
|
138
144
|
"npm": {
|
|
139
|
-
"publish": true
|
|
145
|
+
"publish": true,
|
|
146
|
+
"versionArgs": "--no-git-tag-version"
|
|
140
147
|
},
|
|
141
148
|
"github": {
|
|
142
149
|
"release": false
|
|
150
|
+
},
|
|
151
|
+
"hooks": {
|
|
152
|
+
"before:init": "echo 'Using version from package.json: ${version}'"
|
|
143
153
|
}
|
|
144
154
|
},
|
|
145
155
|
"react-native-builder-bob": {
|