@splithub/core 0.4.3 → 0.5.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.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
- Use `@splithub/react` in React apps. Use this package directly for vanilla JS,
22
- other frameworks, server-side assignment, or traffic simulation.
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.