@widgetic/embed-sdk 2.0.14 → 2.0.16
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 +18 -0
- package/dist/browser/chunks/ABTestManager.js +1 -1
- package/dist/browser/chunks/advanced.js +1 -1
- package/dist/browser/chunks/api.js +1 -1
- package/dist/browser/chunks/core.js +1 -1
- package/dist/browser/chunks/display.js +1 -1
- package/dist/browser/chunks/media.js +1 -1
- package/dist/browser/chunks/messaging.js +1 -1
- package/dist/browser/chunks/renderers.js +1 -1
- package/dist/browser/chunks/scanner.js +1 -1
- package/dist/browser/chunks/security.js +1 -1
- package/dist/browser/embed-bootstrap.js +1 -1
- package/dist/browser/embed-sdk.js +1 -1
- package/dist/esm/chunks/ABTestManager.js +1 -1
- package/dist/esm/chunks/advanced.js +1 -1
- package/dist/esm/chunks/api.js +1 -1
- package/dist/esm/chunks/core.js +1 -1
- package/dist/esm/chunks/display.js +1 -1
- package/dist/esm/chunks/media.js +1 -1
- package/dist/esm/chunks/messaging.js +1 -1
- package/dist/esm/chunks/renderers.js +1 -1
- package/dist/esm/chunks/scanner.js +1 -1
- package/dist/esm/chunks/security.js +1 -1
- package/dist/esm/embed-bootstrap.js +1 -1
- package/dist/esm/embed-sdk.js +1 -1
- package/dist/esm/types/abTesting/ABTestElement.d.ts +10 -0
- package/dist/esm/types/abTesting/ABTestManager.d.ts +54 -12
- package/dist/esm/types/abTesting/abVisitor.d.ts +31 -0
- package/dist/esm/types/utils/declarative-embed-parser.d.ts +14 -0
- package/dist/esm/types/utils/image-delivery.d.ts +54 -0
- package/dist/esm/types/utils/lookup-cache.d.ts +34 -0
- package/dist/esm/types/utils/preload-content-images.d.ts +21 -0
- package/dist/esm/types/utils/public-embed-lookup.d.ts +3 -0
- package/dist/esm/types/utils/published-host-bridge.d.ts +16 -0
- package/dist/umd/embed-bootstrap.js +1 -1
- package/dist/umd/embed-sdk.js +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Handles variant selection, user assignment, and analytics tracking
|
|
4
4
|
*/
|
|
5
5
|
import { SimpleEventEmitter as EventEmitter } from '../utils/event-emitter.js';
|
|
6
|
-
import type { ABTestVariant } from '@widgetic/api-sdk';
|
|
7
6
|
export interface ABTestConfig {
|
|
8
7
|
experimentId: string;
|
|
9
8
|
isActive: boolean;
|
|
@@ -13,7 +12,10 @@ export interface ABTestConfig {
|
|
|
13
12
|
compositionId: string;
|
|
14
13
|
embedCode: string;
|
|
15
14
|
trafficPercentage: number;
|
|
15
|
+
/** The element inside the widget this version's goal is measured on (a CSS selector), if the test names one. */
|
|
16
|
+
goalTarget: string | null;
|
|
16
17
|
}>;
|
|
18
|
+
/** What the test measures: only the primary goal counts as a conversion. */
|
|
17
19
|
successMetrics: string[];
|
|
18
20
|
primaryMetric: string;
|
|
19
21
|
}
|
|
@@ -21,6 +23,15 @@ export interface ABTestAssignment {
|
|
|
21
23
|
variantId: string;
|
|
22
24
|
compositionId: string;
|
|
23
25
|
embedCode: string;
|
|
26
|
+
/** The element the goal is measured on in this version, if any. */
|
|
27
|
+
goalTarget?: string | null;
|
|
28
|
+
/** Whether the backend has been told about this assignment; false until `createAssignment` succeeds, so it is retried. */
|
|
29
|
+
recorded?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Who the visitor is: a user id when the page has one, and always the stable per-browser id. */
|
|
32
|
+
export interface ABTestVisitor {
|
|
33
|
+
userId?: string;
|
|
34
|
+
sessionId: string;
|
|
24
35
|
}
|
|
25
36
|
export interface ConversionTrackingSetup {
|
|
26
37
|
experimentId: string;
|
|
@@ -29,6 +40,12 @@ export interface ConversionTrackingSetup {
|
|
|
29
40
|
trackingTargets: {
|
|
30
41
|
[metric: string]: string[];
|
|
31
42
|
};
|
|
43
|
+
/** The goal that counts: every other metric is ignored. */
|
|
44
|
+
primaryMetric: string;
|
|
45
|
+
/** The element the goal is measured on in the assigned version, if any. */
|
|
46
|
+
goalTarget: string | null;
|
|
47
|
+
/** Whether the widget reports which element was used (`goal-reporter`); then only its reports count for an element goal. */
|
|
48
|
+
widgetReportsGoals: boolean;
|
|
32
49
|
}
|
|
33
50
|
/**
|
|
34
51
|
* A/B Testing Manager
|
|
@@ -43,6 +60,7 @@ export declare class ABTestManager extends EventEmitter {
|
|
|
43
60
|
private messenger;
|
|
44
61
|
private conversionSetups;
|
|
45
62
|
private trackedConversions;
|
|
63
|
+
private visitors;
|
|
46
64
|
private constructor();
|
|
47
65
|
/**
|
|
48
66
|
* Get singleton instance
|
|
@@ -58,17 +76,39 @@ export declare class ABTestManager extends EventEmitter {
|
|
|
58
76
|
*/
|
|
59
77
|
getTestConfig(experimentId: string): Promise<ABTestConfig | null>;
|
|
60
78
|
/**
|
|
61
|
-
*
|
|
79
|
+
* The identity of a visitor for a test: the user id when the page has one, and the stable per-browser id otherwise.
|
|
80
|
+
* Never "anonymous": that would put every visitor of every page in the same bucket.
|
|
81
|
+
*/
|
|
82
|
+
private resolveVisitor;
|
|
83
|
+
/** The visitor a test was assigned to, or the current browser's when the test has not been assigned yet. */
|
|
84
|
+
private visitorFor;
|
|
85
|
+
/** The assignment this browser stored for a test, if it is still one of the test's versions. */
|
|
86
|
+
private readStoredAssignment;
|
|
87
|
+
/** Keeps the visitor's assignment, so the next page load shows the same version. */
|
|
88
|
+
private storeAssignment;
|
|
89
|
+
/**
|
|
90
|
+
* Get the variant assignment of this visitor.
|
|
91
|
+
*
|
|
92
|
+
* The same visitor gets the same version every time: the stored assignment is read first, and only a visitor who has
|
|
93
|
+
* none is split by the traffic shares. A new assignment is recorded in the backend (`createAssignment`).
|
|
62
94
|
*/
|
|
63
95
|
getVariantAssignment(experimentId: string, userContext: {
|
|
64
96
|
userId?: string;
|
|
65
97
|
sessionId?: string;
|
|
66
98
|
attributes?: Record<string, any>;
|
|
67
|
-
}): Promise<
|
|
99
|
+
}): Promise<ABTestAssignment | null>;
|
|
68
100
|
/**
|
|
69
|
-
* Setup conversion tracking for the assigned variant
|
|
101
|
+
* Setup conversion tracking for the assigned variant.
|
|
102
|
+
* Only the primary goal is tracked: a test that measures clicks must not also count plays and submissions as wins.
|
|
70
103
|
*/
|
|
71
104
|
private setupConversionTracking;
|
|
105
|
+
/** The goal a test measures, once the visitor is assigned in this page. */
|
|
106
|
+
getPrimaryMetric(experimentId: string): string | null;
|
|
107
|
+
/**
|
|
108
|
+
* The widget says it reports which element was used (`goal-reporter`). From then on an element goal counts only
|
|
109
|
+
* when the widget reports it: a click somewhere else in the widget is not a conversion.
|
|
110
|
+
*/
|
|
111
|
+
setWidgetReportsGoals(experimentId: string, widgetReportsGoals: boolean): void;
|
|
72
112
|
/**
|
|
73
113
|
* Find tracking targets in composition content
|
|
74
114
|
*/
|
|
@@ -109,8 +149,13 @@ export declare class ABTestManager extends EventEmitter {
|
|
|
109
149
|
* Handle click events for conversion tracking
|
|
110
150
|
*/
|
|
111
151
|
private handleClickEvent;
|
|
152
|
+
/** The key a visitor's conversion is remembered under: one per visitor and test, whatever they did. */
|
|
153
|
+
private conversionKeyFor;
|
|
112
154
|
/**
|
|
113
|
-
* Track conversion
|
|
155
|
+
* Track a conversion: at most one per visitor and test, and only of the goal the test measures.
|
|
156
|
+
*
|
|
157
|
+
* A conversion of any other metric is ignored (a test on clicks is not won by plays). When the visitor's version names an
|
|
158
|
+
* element and the widget reports which element was used, the report must be for that element.
|
|
114
159
|
*/
|
|
115
160
|
trackConversion(experimentId: string, variantId: string, conversionType: string, data?: any, userContext?: {
|
|
116
161
|
userId?: string;
|
|
@@ -151,15 +196,12 @@ export declare class ABTestManager extends EventEmitter {
|
|
|
151
196
|
*/
|
|
152
197
|
private hasClickableCapabilities;
|
|
153
198
|
/**
|
|
154
|
-
* Select
|
|
199
|
+
* Select the version a new visitor gets, by the traffic shares.
|
|
200
|
+
* The visitor is hashed with the test id, so the split is stable for a visitor and independent between tests.
|
|
155
201
|
*/
|
|
156
202
|
private selectVariant;
|
|
157
203
|
/**
|
|
158
|
-
* Create
|
|
159
|
-
*/
|
|
160
|
-
private createDeterministicHash;
|
|
161
|
-
/**
|
|
162
|
-
* Create assignment in backend
|
|
204
|
+
* Create assignment in backend. Returns whether the backend has it, so a failure can be retried on the next load.
|
|
163
205
|
*/
|
|
164
206
|
private createAssignment;
|
|
165
207
|
/**
|
|
@@ -167,7 +209,7 @@ export declare class ABTestManager extends EventEmitter {
|
|
|
167
209
|
*/
|
|
168
210
|
private generateEmbedCode;
|
|
169
211
|
/**
|
|
170
|
-
*
|
|
212
|
+
* The stable id of this visitor (kept for callers that asked for the session id).
|
|
171
213
|
*/
|
|
172
214
|
private getSessionId;
|
|
173
215
|
/**
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who a visitor is for an A/B test, and which version they get.
|
|
3
|
+
*
|
|
4
|
+
* Kept free of the widget runtime so the rules that decide a test's fairness can be tested on their own:
|
|
5
|
+
* - a visitor id that stays the same across page loads (the split and the counts are per visitor),
|
|
6
|
+
* - a split that is stable for a visitor and independent between tests,
|
|
7
|
+
* - storage that survives a browser that refuses localStorage (private mode, blocked cookies).
|
|
8
|
+
*/
|
|
9
|
+
/** The key the visitor id lives under. It is the id the SDK has always used, so existing visitors keep their version. */
|
|
10
|
+
export declare const VISITOR_ID_STORAGE_KEY = "widgetic_session_id";
|
|
11
|
+
/** Forgets what was kept in memory. For tests only: a real page keeps it for as long as it lives. */
|
|
12
|
+
export declare function resetAbVisitorMemoryForTests(): void;
|
|
13
|
+
/** Reads a value from localStorage, falling back to memory when storage is blocked. */
|
|
14
|
+
export declare function readStoredValue(key: string): string | null;
|
|
15
|
+
/** Writes a value to localStorage and to memory, so a blocked storage still keeps it for this page. */
|
|
16
|
+
export declare function writeStoredValue(key: string, value: string): void;
|
|
17
|
+
/** The id of this visitor: created once, then read back on every page load. */
|
|
18
|
+
export declare function getVisitorId(): string;
|
|
19
|
+
/** FNV-1a, 32 bit: well spread over short strings, which the old shift-and-add hash was not. */
|
|
20
|
+
export declare function hashToUnsigned32(input: string): number;
|
|
21
|
+
/**
|
|
22
|
+
* The share of traffic (0 up to but not including 100) a visitor falls in for one test.
|
|
23
|
+
* The test id is part of the hash, so the same visitor lands independently in different tests.
|
|
24
|
+
*/
|
|
25
|
+
export declare function trafficBucketFor(visitorKey: string, experimentId: string): number;
|
|
26
|
+
/** Picks the version a visitor gets from the traffic shares: the same visitor always gets the same version. */
|
|
27
|
+
export declare function chooseVariant<TVariant extends {
|
|
28
|
+
trafficPercentage: number;
|
|
29
|
+
}>(variants: TVariant[], visitorKey: string, experimentId: string): TVariant | null;
|
|
30
|
+
/** Whether `element`, or something above it, matches a CSS selector. A selector the browser cannot parse never matches. */
|
|
31
|
+
export declare function elementMatchesGoalTarget(element: Element | null, goalTarget: string): boolean;
|
|
@@ -57,7 +57,21 @@ export declare function installHostPropertyBridge(host: HTMLElement): void;
|
|
|
57
57
|
* Returns the identifier used for state tracking (`composition-id` or `widget` / `widget-id`).
|
|
58
58
|
*/
|
|
59
59
|
export declare function getHostInstanceId(host: HTMLElement): string | null;
|
|
60
|
+
export declare function isDeclarativeJsonScript(element: Element): boolean;
|
|
60
61
|
export declare function isReservedHostAttribute(attrName: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Parses `<script type="application/json">` (or `application/ld+json`, `application/widgetic+json`,
|
|
64
|
+
* `data-widgetic-json`, `data-widgetic-config`) child blocks inside `<widgetic>`.
|
|
65
|
+
*
|
|
66
|
+
* Supports both:
|
|
67
|
+
* 1. Clean runtime structure: `{ design: {...}, content: {...}, contentItems: [...] }`
|
|
68
|
+
* 2. Raw `src/lib/meta/design.json` (`componentGroups`) and `src/lib/meta/content.json` (`genericContent`, `contentItems[*].properties`) schemas.
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseDeclarativeJsonScripts(host: HTMLElement, baseOverlay?: PublicEmbedOverlay | null): {
|
|
71
|
+
design: Record<string, string>;
|
|
72
|
+
content: Record<string, unknown>;
|
|
73
|
+
contentItems: DeclarativeContentItem[];
|
|
74
|
+
};
|
|
61
75
|
/**
|
|
62
76
|
* Parses declarative child elements (`<img>`, `<item>`, `<audio>`, `<div>`, etc.) inside `<widgetic>`
|
|
63
77
|
* into `contentItems`, hiding the raw declarative DOM nodes so they don't render visually alongside
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Right-sized delivery of an embed's content images.
|
|
3
|
+
*
|
|
4
|
+
* The lookup answer holds the content of a composition, and with it the URLs of the images the widget will show.
|
|
5
|
+
* Before the widget sees them, an image on Widgetic's own content host is pointed at Cloudflare Image
|
|
6
|
+
* Transformations (`/cdn-cgi/image/<options>/<source>`), which answers with a copy sized for the screen, in AVIF
|
|
7
|
+
* or WebP where the browser takes it, instead of the original (often several megapixels for a small widget).
|
|
8
|
+
*
|
|
9
|
+
* Bounded on purpose, because every unique transformation is billed:
|
|
10
|
+
* - three widths only (`IMAGE_WIDTH_LADDER`), chosen from the page's viewport, never from the image;
|
|
11
|
+
* - Widgetic's own hosts only (`IMAGE_DELIVERY_HOSTS`): a partner's bucket or a third-party image is never touched;
|
|
12
|
+
* - png, jpeg, webp and avif only: SVG is already small and a GIF may be animated;
|
|
13
|
+
* - `fit=scale-down`: a small original is never enlarged.
|
|
14
|
+
*
|
|
15
|
+
* Three independent switches, any of which serves the originals:
|
|
16
|
+
* - the owner's account setting, carried by the lookup answer (`media.optimize`; absent means off);
|
|
17
|
+
* - `window.WIDGETIC_IMAGE_OPTIMIZE = false`;
|
|
18
|
+
* - `data-image-optimize="off"` on the SDK's script tag.
|
|
19
|
+
*/
|
|
20
|
+
/** The widths a copy can have. Few, so a visitor of any screen lands on one of a handful of cached variants. */
|
|
21
|
+
export declare const IMAGE_WIDTH_LADDER: readonly number[];
|
|
22
|
+
/** The hosts whose images Widgetic's Cloudflare zone may be asked to transform. */
|
|
23
|
+
export declare const IMAGE_DELIVERY_HOSTS: readonly string[];
|
|
24
|
+
/** What the lookup answer says about the owner's choice, as the SDK reads it. */
|
|
25
|
+
export type PublicEmbedMedia = {
|
|
26
|
+
optimize: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Whether this page may have its images rewritten: the owner opted in (the answer says so) and nothing on the page
|
|
30
|
+
* switched it off. An answer without `media` comes from a gateway that does not know the setting: originals.
|
|
31
|
+
*/
|
|
32
|
+
export declare function imageDeliveryEnabled(media: PublicEmbedMedia | undefined): boolean;
|
|
33
|
+
/** The smallest width of the ladder that covers `neededPixels`; the largest when none does. */
|
|
34
|
+
export declare function widthFromLadder(neededPixels: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* The width to ask for on this page: the viewport, in device pixels (capped at 2x). An embed is never wider than
|
|
37
|
+
* the page that holds it, so this is a safe ceiling that needs no knowledge of the image or of the widget.
|
|
38
|
+
*/
|
|
39
|
+
export declare function viewportImageWidth(): number;
|
|
40
|
+
/** The transformed address of one image URL, or the URL itself when it is not one to transform. */
|
|
41
|
+
export declare function transformedImageUrl(url: string, width: number): string;
|
|
42
|
+
/**
|
|
43
|
+
* A copy of `value` with every transformable image URL rewritten. Strings, arrays and plain objects only, to a
|
|
44
|
+
* bounded depth and size; anything else is returned as it came.
|
|
45
|
+
*/
|
|
46
|
+
export declare function rewriteImageUrls<T>(value: T, width: number): T;
|
|
47
|
+
/**
|
|
48
|
+
* The content and items of a lookup answer, with their images delivered right-sized when the owner and the page
|
|
49
|
+
* both allow it. Never throws: a failure here serves the originals.
|
|
50
|
+
*/
|
|
51
|
+
export declare function deliverContentImages<C, I>(media: PublicEmbedMedia | undefined, content: C, contentItems: I): {
|
|
52
|
+
content: C;
|
|
53
|
+
contentItems: I;
|
|
54
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small persistent copy of the public embed lookup (`GET /embed/compositions/:id`), so a repeat view of a
|
|
3
|
+
* page paints from a local copy instead of waiting for the network, and refreshes it in the background
|
|
4
|
+
* (stale-while-revalidate).
|
|
5
|
+
*
|
|
6
|
+
* What it keeps, and what it never does:
|
|
7
|
+
* - Only a successful answer. A refusal (403 DOMAIN_NOT_ALLOWED), a failure (404, 410, 429...) and a payload the
|
|
8
|
+
* SDK could not read are never stored, so an embed whose owner just limited it to listed websites is refused
|
|
9
|
+
* on the next view, never "remembered" as served.
|
|
10
|
+
* - A copy is used for at most `LOOKUP_CACHE_MAX_AGE_MS` (30 s): the platform's promise is that an edit is
|
|
11
|
+
* visible within a few seconds, and this is the SDK's share of it. The gateway answers `private, max-age=5`
|
|
12
|
+
* and the browser's own HTTP cache does the `ETag` revalidation, so the SDK does not send `If-None-Match`
|
|
13
|
+
* itself (a cross-origin request with that header needs a preflight the lookup does not otherwise pay).
|
|
14
|
+
* - The signed entry write token is part of the copy; its 24 h lifetime is far beyond the copy's 30 s.
|
|
15
|
+
* - IndexedDB, not `localStorage`: a payload carries the whole content and its items. Where IndexedDB is not
|
|
16
|
+
* there (private modes, tests, an old browser), every function is a no-op and the lookup works as before.
|
|
17
|
+
*
|
|
18
|
+
* Off switch for a page: `window.WIDGETIC_EMBED_LOOKUP_CACHE = false`, or `data-lookup-cache="off"` on the SDK script.
|
|
19
|
+
*/
|
|
20
|
+
export declare const LOOKUP_CACHE_MAX_AGE_MS = 30000;
|
|
21
|
+
export type CachedLookup = {
|
|
22
|
+
json: Record<string, unknown>;
|
|
23
|
+
storedAtMs: number;
|
|
24
|
+
};
|
|
25
|
+
/** Whether this page may use the cache: IndexedDB is there and nothing switched it off. */
|
|
26
|
+
export declare function lookupCacheEnabled(): boolean;
|
|
27
|
+
/** The stored copy of one lookup address, or null. Never throws. */
|
|
28
|
+
export declare function readLookupCache(url: string): Promise<CachedLookup | null>;
|
|
29
|
+
/** Stores the answer of one lookup address. Never throws, never waits for the disk. */
|
|
30
|
+
export declare function writeLookupCache(url: string, json: Record<string, unknown>): Promise<void>;
|
|
31
|
+
/** Whether a stored copy may still paint a page. */
|
|
32
|
+
export declare function lookupCacheIsFresh(entry: CachedLookup, nowMs?: number): boolean;
|
|
33
|
+
/** For tests: forgets the open database handle so the next call opens it again. */
|
|
34
|
+
export declare function resetLookupCacheForTests(): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starts downloading the first images of an embed's content while its widget is still loading.
|
|
3
|
+
*
|
|
4
|
+
* The lookup answer already holds the content (and its items), so the first image URLs are known before
|
|
5
|
+
* `widget.html` has been fetched. A `<link rel="preload" as="image">` lets the browser fetch them in parallel
|
|
6
|
+
* with the widget, and the widget's own `<img>` later finds them in the HTTP cache.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately small: at most `MAX_PRELOADED_IMAGES` per embed, https only, only a URL that ends in an image
|
|
9
|
+
* extension, once per URL per page. A guess that is wrong costs one image; a wide net would cost a page its
|
|
10
|
+
* bandwidth.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MAX_PRELOADED_IMAGES = 2;
|
|
13
|
+
/** The first image URLs of a content object and its items, in document order, without repeats. */
|
|
14
|
+
export declare function firstContentImageUrls(content: unknown, contentItems: unknown, limit?: number): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Adds the preload hints. `mapUrl` lets the caller preload the address the widget will actually request
|
|
17
|
+
* (a resized copy, say), so the hint and the request are the same resource.
|
|
18
|
+
*/
|
|
19
|
+
export declare function preloadFirstContentImages(content: unknown, contentItems: unknown, mapUrl?: (url: string) => string): void;
|
|
20
|
+
/** For tests. */
|
|
21
|
+
export declare function resetPreloadedImagesForTests(): void;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* said no.
|
|
19
19
|
*/
|
|
20
20
|
import { type GatewayRefusalCode } from "./embed-gateway-codes.js";
|
|
21
|
+
import { type PublicEmbedMedia } from "./image-delivery.js";
|
|
21
22
|
/** The code the gateway puts on the 403 it sends to a website the embed's owner did not list. */
|
|
22
23
|
export declare const EMBED_DOMAIN_REFUSAL_CODE = "DOMAIN_NOT_ALLOWED";
|
|
23
24
|
/**
|
|
@@ -45,6 +46,8 @@ export type PublicEmbedPayload = PublicEmbedOverlay & {
|
|
|
45
46
|
url: string;
|
|
46
47
|
writeToken?: string;
|
|
47
48
|
};
|
|
49
|
+
/** The owner's choice for image delivery, from the lookup answer (see `image-delivery.ts`). */
|
|
50
|
+
media?: PublicEmbedMedia;
|
|
48
51
|
};
|
|
49
52
|
/** The gateway's refusal: the owner limited this embed to listed websites and this page is not listed. */
|
|
50
53
|
export type PublishedEmbedRefusal = {
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Relays `widgetic:host` into the gateway frame and wrapper events back to the page.
|
|
3
3
|
*/
|
|
4
|
+
/** What the page tells a widget about the A/B test it is part of. */
|
|
5
|
+
export interface AbGoalAssignment {
|
|
6
|
+
/** The goal the test measures (a metric id such as `clicks`). */
|
|
7
|
+
metric: string;
|
|
8
|
+
/** The element inside the widget that counts (a CSS selector), or null for any use of the goal. */
|
|
9
|
+
goalTarget: string | null;
|
|
10
|
+
}
|
|
11
|
+
/** The capability a widget lists in `widgetic:ready` when it reports which element of a goal was used. */
|
|
12
|
+
export declare const GOAL_REPORTER_CAPABILITY = "goal-reporter";
|
|
4
13
|
declare class PublishedHostBridge {
|
|
5
14
|
private readonly host;
|
|
6
15
|
private readonly iframe;
|
|
7
16
|
private readonly gatewayOrigin;
|
|
8
17
|
private readonly compositionId;
|
|
9
18
|
private readyDispatched;
|
|
19
|
+
private latestAbGoal;
|
|
10
20
|
private attributeFlushScheduled;
|
|
11
21
|
private attributeObserver;
|
|
12
22
|
private readonly onWindowMessage;
|
|
@@ -14,6 +24,12 @@ declare class PublishedHostBridge {
|
|
|
14
24
|
private observeHostAttributes;
|
|
15
25
|
private scheduleHostSnapshot;
|
|
16
26
|
postHostSnapshot(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Tells the widget which goal its A/B test measures and, when the version names one, the element that counts
|
|
29
|
+
* (`widgetic:ab-goal`, host bridge contract, player version 5). Kept, and sent again on every host snapshot.
|
|
30
|
+
*/
|
|
31
|
+
sendAbGoal(assignment: AbGoalAssignment): void;
|
|
32
|
+
private postAbGoal;
|
|
17
33
|
sendWidgetUpdate(payload: {
|
|
18
34
|
design?: Record<string, string>;
|
|
19
35
|
content?: Record<string, unknown>;
|