@splithub/core 0.4.3 → 0.5.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/README.md +30 -2
- package/dist/{chunk-7CE2FI5Y.js → chunk-O4D5SUSA.js} +313 -54
- package/dist/chunk-O4D5SUSA.js.map +1 -0
- package/dist/index.cjs +317 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -10
- package/dist/index.d.ts +101 -10
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/{types-DKx9MXeC.d.cts → types-0c_5qhVX.d.cts} +38 -4
- package/dist/{types-DKx9MXeC.d.ts → types-0c_5qhVX.d.ts} +38 -4
- package/dist/vite.cjs +3 -2
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/package.json +12 -4
- package/dist/chunk-7CE2FI5Y.js.map +0 -1
package/README.md
CHANGED
|
@@ -18,5 +18,33 @@ weights, `value` payloads changed without a deploy): the cached copy from
|
|
|
18
18
|
localStorage is applied synchronously on page load, a fresh copy is fetched in
|
|
19
19
|
the background for the next load. Assignments never change mid-page.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
## In an app
|
|
22
|
+
|
|
23
|
+
Outside the browser, give the client a `platform` adapter instead of a page: a
|
|
24
|
+
synchronous storage, the app's info and its lifecycle.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createClient, memoryStorage } from '@splithub/core';
|
|
28
|
+
|
|
29
|
+
const client = createClient(config, {
|
|
30
|
+
platform: {
|
|
31
|
+
storage: memoryStorage(), // any sync getItem / setItem / removeItem store
|
|
32
|
+
app: { platform: 'ios', id: 'com.acme.shop', version: '2.4.1' },
|
|
33
|
+
onBackground: (cb) => appState.on('background', cb), // flush when the app hides
|
|
34
|
+
onForeground: (cb) => appState.on('foreground', cb), // new session after 30 minutes away
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
client.screen('Settings'); // a pageview of /Settings
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
With an adapter the client keeps the visitor in `storage`, sends pageviews only
|
|
41
|
+
from `screen()`, and keeps unsent events on the device (up to 1,000) until the
|
|
42
|
+
network is back. Experiments can target the app with the `platform` and
|
|
43
|
+
`app_version` fields; `app_version` takes `gte` / `lt` and compares part by
|
|
44
|
+
part (`2.10.0` is after `2.9`).
|
|
45
|
+
|
|
46
|
+
Use `@splithub/react` in React apps and `@splithub/react-native` in React
|
|
47
|
+
Native and Expo apps. Native apps have their own SDKs for iOS (Swift) and
|
|
48
|
+
Android (Kotlin) in the [splithub-sdk repository](https://github.com/splithub-io/splithub-sdk).
|
|
49
|
+
Use this package directly for vanilla JS, other frameworks, server-side
|
|
50
|
+
assignment, or traffic simulation.
|