@recapi/client 0.34.0 → 0.35.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 +16 -3
- package/package.json +1 -1
- package/src/shops.js +9 -1
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.35.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).
|
|
@@ -392,6 +392,13 @@ every page from `wp_footer`. The product id is the item id. It tracks:
|
|
|
392
392
|
that brought this path (`recapi_orders_since` option), go from the server:
|
|
393
393
|
older ones are in the past-orders file, whose upload skips only purchases
|
|
394
394
|
already sent live, so completing one later would count it twice.
|
|
395
|
+
- the shop's staff left out: every admin page a user who may manage the
|
|
396
|
+
shop (`manage_woocommerce`) opens writes [the shop's own
|
|
397
|
+
mark](#the-shops-own-browser), so that browser's events and lists carry
|
|
398
|
+
`own: true`, and an order the server sends from it too (the
|
|
399
|
+
`recapi_own` cookie). *WooCommerce → recapi* says so in one line, or,
|
|
400
|
+
when the admin is on another origin than the shop, gives the quick
|
|
401
|
+
start's link instead.
|
|
395
402
|
|
|
396
403
|
The checkout is the shop's own origin, so the purchase reads the state the
|
|
397
404
|
product pages stored and is credited to the recommendation clicked: no
|
|
@@ -940,7 +947,7 @@ row, with nothing to set in the dashboard (`BOUGHT_TOGETHER` is the product
|
|
|
940
947
|
page's second row).
|
|
941
948
|
|
|
942
949
|
```js
|
|
943
|
-
import { RECENTLY_VIEWED } from 'https://api.example.com/sdk/0.
|
|
950
|
+
import { RECENTLY_VIEWED } from 'https://api.example.com/sdk/0.35.0/index.js';
|
|
944
951
|
|
|
945
952
|
const [home, recent] = await recapi.recommendLists({
|
|
946
953
|
lists: [{ placement: 'home', count: 4 }, { placement: RECENTLY_VIEWED, count: 4 }]
|
|
@@ -1303,7 +1310,9 @@ Under the first row it draws, a marked browser shows "This browser is
|
|
|
1303
1310
|
yours: its visits are not counted." and a "Count them again" button that
|
|
1304
1311
|
clears the mark. Shoppers never see it. `?recapi_own=0` clears it too.
|
|
1305
1312
|
Shopify's theme editor marks its lists, and a checkout started in a marked
|
|
1306
|
-
browser marks its purchase.
|
|
1313
|
+
browser marks its purchase. On WooCommerce and Magento the shop's admin
|
|
1314
|
+
writes the same mark, and the shop's script copies it to the `recapi_own`
|
|
1315
|
+
cookie, which marks the orders their server sends.
|
|
1307
1316
|
|
|
1308
1317
|
## Custom storage
|
|
1309
1318
|
|
|
@@ -1365,6 +1374,10 @@ in `server/` writes the files as served, for `scripts/e2e/chain.mjs /tmp/served`
|
|
|
1365
1374
|
|
|
1366
1375
|
## Changes
|
|
1367
1376
|
|
|
1377
|
+
- 2026-12-04: version 0.35.0. On WooCommerce and Magento a marked browser
|
|
1378
|
+
also gets the `recapi_own` cookie, so the orders the shop's server sends
|
|
1379
|
+
carry `own: true` (plugin 0.35.0, module 0.4.44, which mark staff
|
|
1380
|
+
browsers from their admin).
|
|
1368
1381
|
- 2026-12-03: version 0.34.0. A browser opened once with `?recapi_own=1`
|
|
1369
1382
|
is the shop's own: its events and lists carry `own: true`, which no
|
|
1370
1383
|
dashboard number counts, and a line under its row undoes it. The
|
package/package.json
CHANGED
package/src/shops.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module shops
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { REC_ID } from './client.js';
|
|
9
|
+
import { REC_ID, ownBrowser } from './client.js';
|
|
10
10
|
import { ROW, earlierFirst, hasEarlier, opened, openedOf } from './cards.js';
|
|
11
11
|
import { onReturn } from './page.js';
|
|
12
12
|
|
|
@@ -93,6 +93,7 @@ export function followReturns(recapi, row, contextItemId, cardsOf, put, hold) {
|
|
|
93
93
|
* browser's: each save (only with consent) also leaves in the "recapi"
|
|
94
94
|
* cookie the visitor's id and the list each clicked product came from, for
|
|
95
95
|
* a day, as long as a click is credited. Without consent the cookie goes.
|
|
96
|
+
* The shop's own browser also gets "recapi_own=1", which marks its orders.
|
|
96
97
|
*/
|
|
97
98
|
export function orderStorage(consent) {
|
|
98
99
|
const secure = location.protocol === 'https:' ? '; secure' : '';
|
|
@@ -100,6 +101,13 @@ export function orderStorage(consent) {
|
|
|
100
101
|
document.cookie = `recapi=${value}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
101
102
|
};
|
|
102
103
|
if (!consent && /(?:^|;\s*)recapi=/.test(document.cookie ?? '')) cookie('', 0);
|
|
104
|
+
// The shop's own browser (the quick start's link, or the shop's admin
|
|
105
|
+
// opened in it): its orders leave from the server, which reads the mark
|
|
106
|
+
// here. Kept as the mark is, consent or not: the shop's own choice.
|
|
107
|
+
const own = ownBrowser();
|
|
108
|
+
if (own !== /(?:^|;\s*)recapi_own=1/.test(document.cookie ?? '')) {
|
|
109
|
+
document.cookie = `recapi_own=${own ? 1 : ''}; path=/; max-age=${own ? 31536000 : 0}; samesite=lax${secure}`;
|
|
110
|
+
}
|
|
103
111
|
const mirror = (saved) => {
|
|
104
112
|
let state;
|
|
105
113
|
try {
|