@recapi/client 0.36.1 → 0.38.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 +21 -12
- package/package.json +1 -1
- package/src/client.js +10 -1
- package/src/page.js +10 -2
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ are, gzipped, and browsers cache them:
|
|
|
54
54
|
|
|
55
55
|
```html
|
|
56
56
|
<script type="module">
|
|
57
|
-
import { createClient } from 'https://api.example.com/sdk/0.
|
|
57
|
+
import { createClient } from 'https://api.example.com/sdk/0.38.0/index.js';
|
|
58
58
|
|
|
59
59
|
const recapi = createClient({ apiKey: 'rk_pub_…', baseUrl: 'https://api.example.com', consent: false });
|
|
60
60
|
// From your cookie banner, once the visitor agrees: recapi.setConsent(true).
|
|
@@ -947,7 +947,7 @@ row, with nothing to set in the dashboard (`BOUGHT_TOGETHER` is the product
|
|
|
947
947
|
page's second row).
|
|
948
948
|
|
|
949
949
|
```js
|
|
950
|
-
import { RECENTLY_VIEWED } from 'https://api.example.com/sdk/0.
|
|
950
|
+
import { RECENTLY_VIEWED } from 'https://api.example.com/sdk/0.38.0/index.js';
|
|
951
951
|
|
|
952
952
|
const [home, recent] = await recapi.recommendLists({
|
|
953
953
|
lists: [{ placement: 'home', count: 4 }, { placement: RECENTLY_VIEWED, count: 4 }]
|
|
@@ -1279,11 +1279,13 @@ way only an id recapi makes (`rec_` and hex digits) is read: any other
|
|
|
1279
1279
|
Events are still sent, without `anon_id`. Don't call `track()` if you
|
|
1280
1280
|
need no network at all. Such an event may name the product page the
|
|
1281
1281
|
visitor came from on your shop: `track(itemId, 'view', { contextItemId })`.
|
|
1282
|
-
`track('view')
|
|
1283
|
-
browser's address of the page
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1282
|
+
`track('view')`, the Shopify snippet, the WooCommerce plugin and the
|
|
1283
|
+
Magento module fill it themselves from the browser's address of the page
|
|
1284
|
+
before; the pages never sent are listed under
|
|
1285
|
+
[Consent](https://recapi.io/docs/concepts#consent). It is sent only while
|
|
1286
|
+
the visitor has no id, read from no storage, and stands in the page's
|
|
1287
|
+
memory-only history, so the page's lists read where the visitor came
|
|
1288
|
+
from. Withdrawing consent deletes the stored data.
|
|
1287
1289
|
Granting it merges the in-memory history into storage.
|
|
1288
1290
|
|
|
1289
1291
|
The entry to paste into a cookie banner tool, and how to keep it from
|
|
@@ -1353,16 +1355,16 @@ key on a format change makes old data invisible.
|
|
|
1353
1355
|
## Size budget
|
|
1354
1356
|
|
|
1355
1357
|
What a first visit downloads before the library runs: each entry is one
|
|
1356
|
-
file, joined and gzipped as the API serves it (library 0.
|
|
1358
|
+
file, joined and gzipped as the API serves it (library 0.37.0). A test fails
|
|
1357
1359
|
when an entry passes its budget (`go test ./internal/jssdk -run SizeBudget -v`
|
|
1358
1360
|
in `server/` prints these):
|
|
1359
1361
|
|
|
1360
1362
|
| Entry | Bytes | Gzipped | Budget | Its files as they are |
|
|
1361
1363
|
|---|--:|--:|--:|--:|
|
|
1362
|
-
| `index.js` (the pasted tag) | 44,
|
|
1363
|
-
| `woocommerce.js` |
|
|
1364
|
-
| `shopify.js` |
|
|
1365
|
-
| `magento.js` | 53,
|
|
1364
|
+
| `index.js` (the pasted tag) | 44,616 | 17,927 | 18,250 | 6 files, 40,404 |
|
|
1365
|
+
| `woocommerce.js` | 54,497 | 21,464 | 21,700 | 9 files, 57,215 |
|
|
1366
|
+
| `shopify.js` | 57,209 | 22,530 | 22,800 | 9 files, 60,185 |
|
|
1367
|
+
| `magento.js` | 53,820 | 21,202 | 21,450 | 9 files, 56,847 |
|
|
1366
1368
|
|
|
1367
1369
|
`index.js` holds the row too, which it used to fetch at the first `row()`.
|
|
1368
1370
|
|
|
@@ -1380,6 +1382,13 @@ in `server/` writes the files as served, for `scripts/e2e/chain.mjs /tmp/served`
|
|
|
1380
1382
|
|
|
1381
1383
|
## Changes
|
|
1382
1384
|
|
|
1385
|
+
- 2026-12-04: version 0.38.0. The WooCommerce plugin pauses on a staging
|
|
1386
|
+
copy of the shop: no sync, no order and no page tag until its screen's
|
|
1387
|
+
button makes the copy's address the shop's. The library is unchanged.
|
|
1388
|
+
- 2026-12-04: version 0.37.0. Without consent, the product page a visitor
|
|
1389
|
+
came from stands in the page's memory-only history, so its lists read
|
|
1390
|
+
where they came from; search, cart and account pages in other languages
|
|
1391
|
+
are never sent as the page before.
|
|
1383
1392
|
- 2026-12-04: version 0.36.1. In a marked browser the line under the row
|
|
1384
1393
|
goes when its row hides, and comes back with the next row drawn.
|
|
1385
1394
|
- 2026-12-04: version 0.36.0. A visitor without consent can name the
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -825,7 +825,16 @@ export function createClient(options) {
|
|
|
825
825
|
if (quiet) return;
|
|
826
826
|
const t = now();
|
|
827
827
|
let attributed = recommendationId;
|
|
828
|
+
const before = pageBefore(itemId, options.contextItemId);
|
|
828
829
|
mutate(() => {
|
|
830
|
+
// Without consent each page starts with an empty history, kept in
|
|
831
|
+
// memory only: the page the visitor came from, which the event names
|
|
832
|
+
// anyway, stands in as a view a moment before, so this page's lists
|
|
833
|
+
// read where the visitor came from (AP-1067). An address id is read
|
|
834
|
+
// as the product it links by the API.
|
|
835
|
+
if (before !== undefined && level > 0 && !consent && !history.top.has(before)) {
|
|
836
|
+
history = applyEvent(history, { item: before, level: LEVEL_NAMES.view, t: t - 1 }, config);
|
|
837
|
+
}
|
|
829
838
|
if (level !== 0) history = applyEvent(history, { item: itemId, level, t }, config);
|
|
830
839
|
// An explicit id of the recommendation that showed the item is still
|
|
831
840
|
// the click on it; another id leaves the entry alone.
|
|
@@ -844,7 +853,7 @@ export function createClient(options) {
|
|
|
844
853
|
timestamp: new Date(t).toISOString(),
|
|
845
854
|
event_id: uuid(),
|
|
846
855
|
own: own(),
|
|
847
|
-
context_item_id:
|
|
856
|
+
context_item_id: before
|
|
848
857
|
}));
|
|
849
858
|
if (level === LEVEL_NAMES.view && describing) describePage(itemId);
|
|
850
859
|
},
|
package/src/page.js
CHANGED
|
@@ -157,10 +157,18 @@ const PRODUCT_KEYS = new Set(['p', 'id', 'pid', 'product', 'product_id', 'produc
|
|
|
157
157
|
|
|
158
158
|
// Path segments of pages that are no product's, and may name what a visitor
|
|
159
159
|
// searched, bought or is: search, cart, checkout and order, account and
|
|
160
|
-
// sign-in pages, and the shops' own category and tag lists.
|
|
160
|
+
// sign-in pages, and the shops' own category and tag lists. The server also
|
|
161
|
+
// drops a page before that links no product of a shop with links (AP-1067):
|
|
162
|
+
// this list is the guard where the catalog can't tell.
|
|
161
163
|
const NOT_PRODUCT = new Set(['search', 'catalogsearch', 'cart', 'basket', 'checkout', 'order', 'orders', 'order-received', 'order-pay', 'track-order', 'order-tracking',
|
|
162
164
|
'thank-you', 'thankyou', 'payment', 'invoice', 'account', 'my-account', 'customer', 'login', 'logout', 'signin', 'sign-in', 'register', 'password',
|
|
163
|
-
'lost-password', 'reset-password', 'wishlist', 'wp-admin', 'wp-login.php', 'wp-json', 'admin', 'product-category', 'product-tag'
|
|
165
|
+
'lost-password', 'reset-password', 'wishlist', 'wp-admin', 'wp-login.php', 'wp-json', 'admin', 'product-category', 'product-tag',
|
|
166
|
+
// The same pages in the shops' other languages: a path-style search
|
|
167
|
+
// names its words with no query (`/suche/rotes-kleid`).
|
|
168
|
+
'suche', 'recherche', 'buscar', 'busqueda', 'búsqueda', 'zoeken', 'ricerca', 'pesquisa', 'busca', 'szukaj', 'sok', 'sök', 'haku', 'hledat',
|
|
169
|
+
'warenkorb', 'kasse', 'panier', 'commande', 'carrito', 'winkelwagen', 'winkelmandje', 'afrekenen', 'carrello', 'cesta',
|
|
170
|
+
'mein-konto', 'kundenkonto', 'mon-compte', 'mi-cuenta', 'mijn-account', 'il-mio-account', 'minha-conta',
|
|
171
|
+
'produkt-kategorie', 'categorie-produit', 'categoria-producto', 'productcategorie', 'categoria-prodotto', 'categoria-produto']);
|
|
164
172
|
|
|
165
173
|
/**
|
|
166
174
|
* The page before's id for an event without consent (AP-1066), by
|