@recapi/client 0.6.1 → 0.6.2

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
@@ -35,7 +35,7 @@ are, gzipped, and browsers cache them for a year:
35
35
 
36
36
  ```html
37
37
  <script type="module">
38
- import { createClient } from 'https://api.example.com/sdk/0.6.1/index.js';
38
+ import { createClient } from 'https://api.example.com/sdk/0.6.2/index.js';
39
39
 
40
40
  const recapi = createClient({ apiKey: 'rk_pub_…', baseUrl: 'https://api.example.com' });
41
41
  recapi.track('item-42', 'view'); // and the calls of the quick start below
@@ -778,9 +778,16 @@ const storage = {
778
778
  setItem: (k, v) => { cache.set(k, v); AsyncStorage.setItem(k, v); },
779
779
  removeItem: (k) => { cache.delete(k); AsyncStorage.removeItem(k); }
780
780
  };
781
- createClient({ apiKey, baseUrl, project: 'myproject', storage });
781
+ const client = createClient({ apiKey, baseUrl, project: 'myproject', storage });
782
782
  ```
783
783
 
784
+ React Native has no page-hide event, so send the queue when the app leaves
785
+ the screen: call `client.flush()` when `AppState` changes to `background`.
786
+ `popular()` and the fallback list work on React Native below 0.80 as well,
787
+ whose `URLSearchParams` has no working `set`. We read that class in React
788
+ Native's 0.79 and 0.80 sources and test against a copy of its behaviour; the
789
+ library has not been run on a device.
790
+
784
791
  Corrupt or unrecognised stored data is discarded. Bumping the `v1` in the
785
792
  key on a format change makes old data invisible.
786
793
 
@@ -795,6 +802,10 @@ minifier, to keep zero dev dependencies.
795
802
 
796
803
  ## Changes
797
804
 
805
+ - 2026-11-03: version 0.6.2. `popular()` and the fallback list of
806
+ `recommend()` no longer throw on React Native below 0.80, whose
807
+ `URLSearchParams.set` is not implemented. Query strings are unchanged
808
+ everywhere else.
798
809
  - 2026-11-02: version 0.6.1. The client draws its anonymous id at the
799
810
  first call instead of in `createClient`, so a back end on Cloudflare
800
811
  Workers may create it at module scope (it threw "Disallowed operation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recapi/client",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Browser and Node client for the recapi recommendation API: local decayed history, event batching, attribution.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/transport.js CHANGED
@@ -78,11 +78,12 @@ export function createTransport({ baseUrl, apiKey, fetch, timeoutMs: defaultTime
78
78
 
79
79
  /** @param {RequestOptions} options */
80
80
  async function request({ method, path, query, body, auth = 'header', keepalive = false, cache, timeoutMs }) {
81
+ // append, not set: React Native below 0.80 throws on set, and these names are unique.
81
82
  const params = new URLSearchParams();
82
83
  for (const [name, value] of Object.entries(query ?? {})) {
83
- if (value !== undefined) params.set(name, String(value));
84
+ if (value !== undefined) params.append(name, String(value));
84
85
  }
85
- if (auth === 'query') params.set('key', apiKey);
86
+ if (auth === 'query') params.append('key', apiKey);
86
87
  const qs = params.toString();
87
88
  const url = `${root}${path}${qs ? `?${qs}` : ''}`;
88
89