@thg-agentic/hyper-personalisation-web 3.28.1 → 3.30.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 +13 -5
- package/dist/hp.min.js +2 -2
- package/dist/onsite-answers.min.js +15 -1
- package/dist/onsite-products.min.js +9 -3
- package/dist/onsite-render.min.js +5 -6
- package/dist/onsite-wheel.min.js +1 -1
- package/dist/onsite.min.js +1 -1
- package/package.json +2 -2
- package/src/index.js +2 -0
- package/src/onsite/answers.js +84 -2
- package/src/onsite/api.js +16 -1
- package/src/onsite/countdown.js +35 -0
- package/src/onsite/index.js +238 -102
- package/src/onsite/preview.js +3 -2
- package/src/onsite/products.js +78 -21
- package/src/onsite/render.js +180 -84
- package/src/onsite/rules.js +35 -8
- package/src/onsite/styles.js +0 -1
- package/src/onsite-facade.js +8 -4
- package/src/spec-version.js +1 -1
- package/src/version.js +1 -1
- package/types/events.d.ts +3 -2
- package/types/onsite.d.ts +50 -1
package/src/onsite/styles.js
CHANGED
|
@@ -136,7 +136,6 @@ legend{padding:0;margin-bottom:8px;font-size:13px;font-weight:600}
|
|
|
136
136
|
.pg p{font-weight:600}
|
|
137
137
|
.tr{height:6px;border-radius:99px;background:color-mix(in srgb,var(--t) 18%,var(--b));overflow:hidden}
|
|
138
138
|
.tr i{display:block;height:100%;border-radius:inherit;background:var(--a);transform:scaleX(0);transform-origin:left;transition:transform .6s ${EASE}}
|
|
139
|
-
.tm{font-size:40px;line-height:1;font-weight:800;letter-spacing:.02em;font-variant-numeric:tabular-nums;text-align:center}
|
|
140
139
|
.bi{display:block;width:100%;height:auto}
|
|
141
140
|
.bl{display:block;border-radius:var(--br)}
|
|
142
141
|
hr{width:100%;margin:4px 0;border:0;border-top:1px solid var(--ln)}
|
package/src/onsite-facade.js
CHANGED
|
@@ -15,7 +15,7 @@ const LISTENERS = Symbol.for(
|
|
|
15
15
|
const SUPPRESSED = Symbol.for(
|
|
16
16
|
'@thg-agentic/hyper-personalisation-web.onsite.suppressed',
|
|
17
17
|
);
|
|
18
|
-
const EVENTS = ['shown', 'submitted', 'apply', 'closed', 'held'];
|
|
18
|
+
const EVENTS = ['shown', 'submitted', 'apply', 'closed', 'held', 'nothing'];
|
|
19
19
|
const MAX_PENDING = 10;
|
|
20
20
|
|
|
21
21
|
const page = () => (typeof window === 'undefined' ? null : window);
|
|
@@ -52,9 +52,13 @@ export const onsite = Object.freeze({
|
|
|
52
52
|
/**
|
|
53
53
|
* Listen to the forms: `shown`, `submitted` (`{ coupon }`: the claimed code for a form that
|
|
54
54
|
* spins, else null), `apply` (`{ coupon }`: a reminder's code to apply), `closed`
|
|
55
|
-
* (`{ reason }`)
|
|
56
|
-
* without HP)
|
|
57
|
-
*
|
|
55
|
+
* (`{ reason }`), `held` (a held-out visitor's trigger fired: the site shows what it shows
|
|
56
|
+
* without HP) and `nothing` (a covering form's trigger fired and HP will show nothing for it,
|
|
57
|
+
* at most 3.05 s later: `{ code }` says why; only the highest of the forms that fire together,
|
|
58
|
+
* and no other HP form shows after it on the page view; not for a form the site opened, a
|
|
59
|
+
* suppressed page, or one another form showed or a holdout replaced). Each detail carries the `slot` and
|
|
60
|
+
* `format`, and all but `nothing` the `arm`.
|
|
61
|
+
* Returns a function that stops listening.
|
|
58
62
|
*/
|
|
59
63
|
on(name, fn) {
|
|
60
64
|
try {
|
package/src/spec-version.js
CHANGED
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.
|
|
1
|
+
export const VERSION = '3.30.0';
|
|
2
2
|
export const LIB = '@thg-agentic/hyper-personalisation-web';
|
package/types/events.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated from spec/registry.json by scripts/generate-sdk-models.mjs.
|
|
2
2
|
// DO NOT EDIT. Change the schema and regenerate — the schema is the contract,
|
|
3
3
|
// and a hand-edit here is an SDK that disagrees with the ingest.
|
|
4
|
-
// Spec version: 1.
|
|
4
|
+
// Spec version: 1.22
|
|
5
5
|
|
|
6
6
|
/** context.source.environment. Environment the producer runs in. */
|
|
7
7
|
export type CdpSourceEnvironment = 'production' | 'staging' | 'development';
|
|
@@ -104,6 +104,7 @@ export interface RecommendationServed {
|
|
|
104
104
|
strategy?: string | null;
|
|
105
105
|
algorithm_version?: string | null;
|
|
106
106
|
candidate_algorithm_version?: string | null;
|
|
107
|
+
shadow_algorithm_version?: string | null;
|
|
107
108
|
ranked_by?: 'ranker' | 'blend' | 'session' | 'manual' | 'other' | null;
|
|
108
109
|
fusion?: string | null;
|
|
109
110
|
fast_weight?: number | null;
|
|
@@ -713,7 +714,7 @@ export interface SignUpRelayed {
|
|
|
713
714
|
}
|
|
714
715
|
|
|
715
716
|
/** The spec version these models implement. SDKs stamp it on context.spec.version. */
|
|
716
|
-
export const SPEC_VERSION = '1.
|
|
717
|
+
export const SPEC_VERSION = '1.22';
|
|
717
718
|
|
|
718
719
|
/** Every event name the registry accepts. Anything else is rejected at the ingest. */
|
|
719
720
|
export type CdpEventName =
|
package/types/onsite.d.ts
CHANGED
|
@@ -173,6 +173,43 @@ export interface OnsiteOptions {
|
|
|
173
173
|
fetch?: typeof fetch;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Why a form is in its state, stable across releases (`reasons` is for people and may be reworded).
|
|
178
|
+
* A form whose trigger fired and that HP has nothing to show for has an `OnsiteNothingCode`.
|
|
179
|
+
*/
|
|
180
|
+
export type OnsiteTraceCode =
|
|
181
|
+
| OnsiteNothingCode
|
|
182
|
+
| 'armed'
|
|
183
|
+
| 'waiting-for-open'
|
|
184
|
+
| 'deciding'
|
|
185
|
+
| 'shown'
|
|
186
|
+
| 'closed'
|
|
187
|
+
| 'held-out'
|
|
188
|
+
| 'invalid'
|
|
189
|
+
| 'not-eligible'
|
|
190
|
+
| 'overlay-gap'
|
|
191
|
+
| 'awaiting-consent'
|
|
192
|
+
| 'another-showing'
|
|
193
|
+
| 'allowance-spent'
|
|
194
|
+
| 'lower-priority'
|
|
195
|
+
| 'no-element'
|
|
196
|
+
| 'empty-basket'
|
|
197
|
+
| 'suppressed';
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Why HP shows nothing for a covering form whose trigger fired: the decision failed (a network
|
|
201
|
+
* error, any status but 200, a 200 without a list of decisions, or no answer within 3 s), the
|
|
202
|
+
* visitor has no creative, a reminder has no code, the renderer or a products block's chunk did not
|
|
203
|
+
* load within 3 s, or the form failed while it was being opened (`error`).
|
|
204
|
+
*/
|
|
205
|
+
export type OnsiteNothingCode =
|
|
206
|
+
| 'decision-failed'
|
|
207
|
+
| 'no-creative'
|
|
208
|
+
| 'no-code'
|
|
209
|
+
| 'renderer-failed'
|
|
210
|
+
| 'products-failed'
|
|
211
|
+
| 'error';
|
|
212
|
+
|
|
176
213
|
/** One form's state on this page, and why. */
|
|
177
214
|
export interface OnsiteTrace {
|
|
178
215
|
slot: string;
|
|
@@ -190,6 +227,8 @@ export interface OnsiteTrace {
|
|
|
190
227
|
| 'not eligible'
|
|
191
228
|
| 'not shown'
|
|
192
229
|
| 'invalid';
|
|
230
|
+
/** Since 3.29, always present. Match on this, not on `reasons`. */
|
|
231
|
+
code: OnsiteTraceCode;
|
|
193
232
|
reasons: string[];
|
|
194
233
|
}
|
|
195
234
|
|
|
@@ -198,7 +237,7 @@ export interface OnsiteController {
|
|
|
198
237
|
open(slot: string): Promise<boolean>;
|
|
199
238
|
/** Each form's state on this page, and why. */
|
|
200
239
|
debug(): OnsiteTrace[];
|
|
201
|
-
/** Stop watching every trigger. A form on screen stays until it is closed. */
|
|
240
|
+
/** Stop watching every trigger, and say no `nothing` after. A form on screen stays until it is closed. */
|
|
202
241
|
stop(): void;
|
|
203
242
|
/** Take every form off the screen, quietly (`hp.onsite.suppress` calls it). */
|
|
204
243
|
suppress(): void;
|
|
@@ -226,6 +265,16 @@ export interface OnsiteEvents {
|
|
|
226
265
|
closed: OnsiteEventDetail & { reason: string };
|
|
227
266
|
/** A held-out visitor's trigger fired (not a form the site opened, whose `open` resolves false): show what the site shows without HP. */
|
|
228
267
|
held: OnsiteEventDetail;
|
|
268
|
+
/**
|
|
269
|
+
* Since 3.29. A covering form's own trigger fired and HP will show nothing for it on this page
|
|
270
|
+
* view: show what the site shows without HP. At most 3.05 s after the trigger, and only for the
|
|
271
|
+
* highest of the forms that fire together. It spends the page view's allowance, as `held` does:
|
|
272
|
+
* no other HP covering form shows after it on that page view.
|
|
273
|
+
* Not said when another form that fired with it shows or the visitor is held out (`held`), for a
|
|
274
|
+
* form the site opened (`open` resolves false), on a suppressed page, or when its caps, the gap,
|
|
275
|
+
* the consent banner or a form on screen keep it away.
|
|
276
|
+
*/
|
|
277
|
+
nothing: { slot: string; format: string; code: OnsiteNothingCode };
|
|
229
278
|
}
|
|
230
279
|
|
|
231
280
|
/** `hp.onsite`, callable before the runtime has loaded. */
|