@traffical/react-native 0.8.2 → 0.8.4
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 +20 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,7 +29,8 @@ function App() {
|
|
|
29
29
|
orgId: 'org_123',
|
|
30
30
|
projectId: 'proj_456',
|
|
31
31
|
env: 'production',
|
|
32
|
-
apiKey: '
|
|
32
|
+
apiKey: 'traffical_pk_…',
|
|
33
|
+
evaluationMode: 'bundle', // required with a publishable key — see below
|
|
33
34
|
}}
|
|
34
35
|
loadingComponent={<ActivityIndicator size="large" />}
|
|
35
36
|
>
|
|
@@ -39,6 +40,20 @@ function App() {
|
|
|
39
40
|
}
|
|
40
41
|
```
|
|
41
42
|
|
|
43
|
+
> **Publishable keys need `evaluationMode: 'bundle'`.**
|
|
44
|
+
>
|
|
45
|
+
> This package defaults to `evaluationMode: 'server'`, which calls `/v1/resolve`.
|
|
46
|
+
> That endpoint rejects publishable (`traffical_pk_…`) keys, so leaving the
|
|
47
|
+
> default in place with a `pk` returns `403` on every resolution.
|
|
48
|
+
>
|
|
49
|
+
> Set `evaluationMode: 'bundle'` and the SDK fetches the config bundle once and
|
|
50
|
+
> resolves on-device — no per-decision network call, works offline, and it is the
|
|
51
|
+
> mode we recommend for mobile regardless of key type.
|
|
52
|
+
>
|
|
53
|
+
> If you specifically need server-evaluated mode, it requires a server-side SDK
|
|
54
|
+
> key (`traffical_sk_…`), which must not ship in a mobile binary. In practice that
|
|
55
|
+
> means proxying resolution through your own backend.
|
|
56
|
+
|
|
42
57
|
### 2. Use the `useTraffical` hook in your screens
|
|
43
58
|
|
|
44
59
|
```tsx
|
|
@@ -98,7 +113,7 @@ Initializes the Traffical client with React Native defaults and provides it to c
|
|
|
98
113
|
| `config.env` | `string` | Yes | Environment (e.g., "production", "staging") |
|
|
99
114
|
| `config.apiKey` | `string` | Yes | API key for authentication |
|
|
100
115
|
| `config.baseUrl` | `string` | No | Base URL for the control plane API |
|
|
101
|
-
| `config.evaluationMode` | `"server" \| "bundle"` | No | Resolution mode (default: `"server"`) |
|
|
116
|
+
| `config.evaluationMode` | `"server" \| "bundle"` | No | Resolution mode (default: `"server"`). Use `"bundle"` with a publishable key — `"server"` calls `/v1/resolve`, which rejects `traffical_pk_…` keys |
|
|
102
117
|
| `config.refreshIntervalMs` | `number` | No | Background refresh interval (default: 60000) |
|
|
103
118
|
| `config.unitKeyFn` | `() => string` | No | Function to get the unit key. If not provided, uses automatic stable ID |
|
|
104
119
|
| `config.contextFn` | `() => Context` | No | Function to get additional context |
|
|
@@ -398,10 +413,10 @@ function PaywallScreen() {
|
|
|
398
413
|
|
|
399
414
|
### 1. Always Provide Sensible Defaults
|
|
400
415
|
|
|
401
|
-
Defaults are used when no
|
|
416
|
+
Defaults are used when no policy is running, the user doesn't match targeting, or the SDK is still loading.
|
|
402
417
|
|
|
403
418
|
```tsx
|
|
404
|
-
// ✅ Good: works without any
|
|
419
|
+
// ✅ Good: works without any policy
|
|
405
420
|
const { params } = useTraffical({
|
|
406
421
|
defaults: {
|
|
407
422
|
'pricing.discount': 0,
|
|
@@ -448,7 +463,7 @@ category.subcategory.name
|
|
|
448
463
|
|
|
449
464
|
feature.* → Feature flags (boolean)
|
|
450
465
|
ui.* → Visual variations (string, number)
|
|
451
|
-
pricing.* → Pricing
|
|
466
|
+
pricing.* → Pricing policies (number)
|
|
452
467
|
copy.* → Copywriting tests (string)
|
|
453
468
|
onboarding.* → Onboarding flow (mixed)
|
|
454
469
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@traffical/react-native",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "Traffical SDK for React Native - server-evaluated feature flags, A/B testing, and adaptive optimization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"typecheck": "tsc --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@traffical/core": "0.
|
|
26
|
-
"@traffical/js-client": "0.
|
|
25
|
+
"@traffical/core": "0.12.0",
|
|
26
|
+
"@traffical/js-client": "0.18.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/bun": "latest",
|