@drip-apex/sdk 0.1.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/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/_headers +3 -0
- package/dist/bundle-report.json +564 -0
- package/dist/drip.debug.js +2 -0
- package/dist/drip.debug.js.map +1 -0
- package/dist/drip.heatmap.js +2 -0
- package/dist/drip.heatmap.js.map +1 -0
- package/dist/drip.js +2 -0
- package/dist/drip.js.map +1 -0
- package/dist/drip.live.js +2 -0
- package/dist/drip.live.js.map +1 -0
- package/dist/editor.js +480 -0
- package/dist/editor.js.map +7 -0
- package/dist/index.mjs +645 -0
- package/dist/index.mjs.map +7 -0
- package/dist/metafiles/drip.debug.meta.json +973 -0
- package/dist/metafiles/drip.heatmap.meta.json +918 -0
- package/dist/metafiles/drip.live.meta.json +918 -0
- package/dist/metafiles/drip.meta.json +973 -0
- package/dist/metafiles/editor.meta.json +321 -0
- package/dist/metafiles/index.meta.json +1039 -0
- package/dist/metafiles/index.mjs.meta.json +78 -0
- package/dist/react/index.js +16973 -0
- package/dist/react/index.js.map +7 -0
- package/dist/sri.json +27 -0
- package/dist/types/analytics.d.ts +15 -0
- package/dist/types/antiflicker.d.ts +14 -0
- package/dist/types/assignment-store.d.ts +30 -0
- package/dist/types/audit.d.ts +9 -0
- package/dist/types/bucket.d.ts +2 -0
- package/dist/types/bucketing-cleanup.d.ts +5 -0
- package/dist/types/commerce-gift.d.ts +41 -0
- package/dist/types/commerce-price.d.ts +22 -0
- package/dist/types/commerce-shipping.d.ts +28 -0
- package/dist/types/css.d.ts +5 -0
- package/dist/types/cwv.d.ts +10 -0
- package/dist/types/data-layer-normalize.d.ts +1 -0
- package/dist/types/debug.d.ts +23 -0
- package/dist/types/define.d.ts +87 -0
- package/dist/types/devtools.d.ts +32 -0
- package/dist/types/dom-trigger.d.ts +3 -0
- package/dist/types/editor/api.d.ts +37 -0
- package/dist/types/editor/artifacts.d.ts +15 -0
- package/dist/types/editor/command-runtime.d.ts +48 -0
- package/dist/types/editor/controller.d.ts +97 -0
- package/dist/types/editor/device-preview.d.ts +23 -0
- package/dist/types/editor/index.d.ts +9 -0
- package/dist/types/editor/operator.d.ts +39 -0
- package/dist/types/editor/picker.d.ts +23 -0
- package/dist/types/editor/selector.d.ts +2 -0
- package/dist/types/editor/types.d.ts +55 -0
- package/dist/types/editor/view-kit.d.ts +33 -0
- package/dist/types/editor/view.d.ts +5 -0
- package/dist/types/editor-bootstrap.d.ts +37 -0
- package/dist/types/exclusion-groups.d.ts +59 -0
- package/dist/types/exposure-signals.d.ts +7 -0
- package/dist/types/flags.d.ts +65 -0
- package/dist/types/goals.d.ts +16 -0
- package/dist/types/guards.d.ts +39 -0
- package/dist/types/handover.d.ts +10 -0
- package/dist/types/hash.d.ts +19 -0
- package/dist/types/heatmap.d.ts +8 -0
- package/dist/types/hideflicker.d.ts +15 -0
- package/dist/types/hydration.d.ts +11 -0
- package/dist/types/index.d.ts +144 -0
- package/dist/types/js.d.ts +6 -0
- package/dist/types/module.d.ts +4 -0
- package/dist/types/money.d.ts +14 -0
- package/dist/types/mutate.d.ts +34 -0
- package/dist/types/observer-mute.d.ts +3 -0
- package/dist/types/pii-keys.d.ts +1 -0
- package/dist/types/prerequisites.d.ts +12 -0
- package/dist/types/qa-assistant-state.d.ts +68 -0
- package/dist/types/qa-assistant-view.d.ts +6 -0
- package/dist/types/qa-assistant.d.ts +9 -0
- package/dist/types/qa-toolbar.d.ts +19 -0
- package/dist/types/react/index.d.ts +84 -0
- package/dist/types/reassert-sentinel.d.ts +6 -0
- package/dist/types/router.d.ts +9 -0
- package/dist/types/runtime-tools.d.ts +50 -0
- package/dist/types/runtime.d.ts +22 -0
- package/dist/types/safe-regex.d.ts +6 -0
- package/dist/types/sanitize.d.ts +5 -0
- package/dist/types/semantic.d.ts +7 -0
- package/dist/types/shopify-cart-events.d.ts +7 -0
- package/dist/types/shopify-cart.d.ts +62 -0
- package/dist/types/signals.d.ts +31 -0
- package/dist/types/surface-signals.d.ts +6 -0
- package/dist/types/targeting-diagnostics.d.ts +5 -0
- package/dist/types/targeting.d.ts +50 -0
- package/dist/types/test-fixtures/commerce.d.ts +12 -0
- package/dist/types/track.d.ts +79 -0
- package/dist/types/types.d.ts +859 -0
- package/dist/types/wait.d.ts +7 -0
- package/package.json +74 -0
- package/src/analytics.ts +146 -0
- package/src/antiflicker.test.ts +127 -0
- package/src/antiflicker.ts +147 -0
- package/src/assignment-store.test.ts +171 -0
- package/src/assignment-store.ts +208 -0
- package/src/audit.test.ts +17 -0
- package/src/audit.ts +362 -0
- package/src/bucket.test.ts +65 -0
- package/src/bucket.ts +18 -0
- package/src/bucketing-cleanup.test.ts +30 -0
- package/src/bucketing-cleanup.ts +72 -0
- package/src/bucketing-parity.test.ts +41 -0
- package/src/commerce-analytics-lifecycle.test.ts +1416 -0
- package/src/commerce-config-lifecycle.test.ts +274 -0
- package/src/commerce-epoch-lifecycle.test.ts +62 -0
- package/src/commerce-gift.test.ts +1293 -0
- package/src/commerce-gift.ts +979 -0
- package/src/commerce-offers-display.test.ts +154 -0
- package/src/commerce-price.test.ts +1145 -0
- package/src/commerce-price.ts +941 -0
- package/src/commerce-revocation-lifecycle.test.ts +78 -0
- package/src/commerce-shipping.test.ts +630 -0
- package/src/commerce-shipping.ts +447 -0
- package/src/config-fetch.test.ts +325 -0
- package/src/css.ts +54 -0
- package/src/cwv.test.ts +95 -0
- package/src/cwv.ts +129 -0
- package/src/data-layer-normalize.ts +21 -0
- package/src/debug.test.ts +83 -0
- package/src/debug.ts +138 -0
- package/src/define.test.ts +327 -0
- package/src/define.ts +208 -0
- package/src/devtools.ts +582 -0
- package/src/dom-trigger.test.ts +70 -0
- package/src/dom-trigger.ts +55 -0
- package/src/editor/api.test.ts +154 -0
- package/src/editor/api.ts +185 -0
- package/src/editor/artifacts.test.ts +57 -0
- package/src/editor/artifacts.ts +115 -0
- package/src/editor/command-runtime.test.ts +225 -0
- package/src/editor/command-runtime.ts +572 -0
- package/src/editor/controller.test.ts +371 -0
- package/src/editor/controller.ts +596 -0
- package/src/editor/device-preview.test.ts +60 -0
- package/src/editor/device-preview.ts +120 -0
- package/src/editor/index.test.ts +161 -0
- package/src/editor/index.ts +169 -0
- package/src/editor/operator.test.ts +148 -0
- package/src/editor/operator.ts +256 -0
- package/src/editor/picker.test.ts +58 -0
- package/src/editor/picker.ts +152 -0
- package/src/editor/selector.test.ts +44 -0
- package/src/editor/selector.ts +110 -0
- package/src/editor/types.ts +92 -0
- package/src/editor/view-kit.ts +162 -0
- package/src/editor/view.test.ts +535 -0
- package/src/editor/view.ts +1395 -0
- package/src/editor-bootstrap.test.ts +116 -0
- package/src/editor-bootstrap.ts +213 -0
- package/src/event-schema-contract.test.ts +35 -0
- package/src/exclusion-groups.test.ts +383 -0
- package/src/exclusion-groups.ts +270 -0
- package/src/exposure-signals.test.ts +182 -0
- package/src/exposure-signals.ts +110 -0
- package/src/flags.test.ts +322 -0
- package/src/flags.ts +201 -0
- package/src/goals.test.ts +42 -0
- package/src/goals.ts +200 -0
- package/src/guards.test.ts +249 -0
- package/src/guards.ts +250 -0
- package/src/handover-cache-order.test.ts +32 -0
- package/src/handover.test.ts +349 -0
- package/src/handover.ts +309 -0
- package/src/hash.ts +214 -0
- package/src/heatmap.test.ts +305 -0
- package/src/heatmap.ts +373 -0
- package/src/hideflicker.ts +21 -0
- package/src/hydration.test.ts +252 -0
- package/src/hydration.ts +203 -0
- package/src/index.ts +7513 -0
- package/src/init-empty.test.ts +5572 -0
- package/src/js.test.ts +26 -0
- package/src/js.ts +61 -0
- package/src/module.ts +50 -0
- package/src/money.test.ts +35 -0
- package/src/money.ts +53 -0
- package/src/mutate.test.ts +304 -0
- package/src/mutate.ts +469 -0
- package/src/observer-mute.test.ts +88 -0
- package/src/observer-mute.ts +45 -0
- package/src/page-trigger.test.ts +84 -0
- package/src/personalization.test.ts +68 -0
- package/src/pii-keys.ts +17 -0
- package/src/prerequisites.test.ts +39 -0
- package/src/prerequisites.ts +94 -0
- package/src/qa-assistant-state.test.ts +471 -0
- package/src/qa-assistant-state.ts +505 -0
- package/src/qa-assistant-view.test.ts +185 -0
- package/src/qa-assistant-view.ts +768 -0
- package/src/qa-assistant.ts +40 -0
- package/src/qa-toolbar.ts +444 -0
- package/src/react/index.test.tsx +177 -0
- package/src/react/index.tsx +252 -0
- package/src/reassert-sentinel.test.ts +314 -0
- package/src/reassert-sentinel.ts +191 -0
- package/src/router.test.ts +78 -0
- package/src/router.ts +92 -0
- package/src/runtime-tools.test.ts +112 -0
- package/src/runtime-tools.ts +403 -0
- package/src/runtime.test.ts +217 -0
- package/src/runtime.ts +268 -0
- package/src/safe-regex.ts +35 -0
- package/src/sanitize.ts +34 -0
- package/src/semantic.ts +245 -0
- package/src/shopify-cart-events.test.ts +76 -0
- package/src/shopify-cart-events.ts +115 -0
- package/src/shopify-cart.test.ts +2823 -0
- package/src/shopify-cart.ts +1256 -0
- package/src/signals.ts +226 -0
- package/src/surface-signals.test.ts +83 -0
- package/src/surface-signals.ts +165 -0
- package/src/targeting-diagnostics.ts +560 -0
- package/src/targeting.detailed.test.ts +443 -0
- package/src/targeting.test.ts +1054 -0
- package/src/targeting.ts +1024 -0
- package/src/test-fixtures/commerce.ts +65 -0
- package/src/track.test.ts +817 -0
- package/src/track.ts +519 -0
- package/src/types.ts +991 -0
- package/src/wait.test.ts +96 -0
- package/src/wait.ts +238 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,991 @@
|
|
|
1
|
+
export type MutationAction =
|
|
2
|
+
| "html"
|
|
3
|
+
| "text"
|
|
4
|
+
| "setText"
|
|
5
|
+
| "attribute"
|
|
6
|
+
| "style"
|
|
7
|
+
| "setStyle"
|
|
8
|
+
| "remove"
|
|
9
|
+
| "insertBefore"
|
|
10
|
+
| "insertAfter";
|
|
11
|
+
|
|
12
|
+
export interface Mutation {
|
|
13
|
+
selector: string;
|
|
14
|
+
action: MutationAction;
|
|
15
|
+
html?: string;
|
|
16
|
+
text?: string;
|
|
17
|
+
attribute?: { name: string; value: string | null };
|
|
18
|
+
attributes?: Record<string, string | null>;
|
|
19
|
+
styles?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface UrlRule {
|
|
23
|
+
type: "regex" | "simple";
|
|
24
|
+
pattern: string;
|
|
25
|
+
include?: boolean;
|
|
26
|
+
matchType?: "exact" | "contains" | "wildcard" | "regex";
|
|
27
|
+
match_type?: "exact" | "contains" | "wildcard" | "regex";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AttributeRule {
|
|
31
|
+
attribute: string;
|
|
32
|
+
operator: "equals" | "contains" | "exists" | "in";
|
|
33
|
+
value?: string | string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type SegmentConditionOperator =
|
|
37
|
+
| "equals"
|
|
38
|
+
| "not_equals"
|
|
39
|
+
| "contains"
|
|
40
|
+
| "not_contains"
|
|
41
|
+
| "starts_with"
|
|
42
|
+
| "ends_with"
|
|
43
|
+
| "is_set"
|
|
44
|
+
| "is_empty"
|
|
45
|
+
| "in"
|
|
46
|
+
| "not_in"
|
|
47
|
+
| "matches_wildcard"
|
|
48
|
+
| "matches_regex"
|
|
49
|
+
| "greater_than"
|
|
50
|
+
| "greater_than_or_equal"
|
|
51
|
+
| "less_than"
|
|
52
|
+
| "less_than_or_equal";
|
|
53
|
+
|
|
54
|
+
export type SegmentSignal = string;
|
|
55
|
+
|
|
56
|
+
export type SegmentJsTriggerMode = "predicate" | "activate";
|
|
57
|
+
|
|
58
|
+
export interface SegmentJsTrigger {
|
|
59
|
+
code: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
mode?: SegmentJsTriggerMode;
|
|
62
|
+
resetCode?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface SegmentCondition {
|
|
66
|
+
signal: SegmentSignal;
|
|
67
|
+
operator: SegmentConditionOperator;
|
|
68
|
+
value?: string | number | boolean | string[];
|
|
69
|
+
js?: SegmentJsTrigger;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface SegmentRules {
|
|
73
|
+
version: 1;
|
|
74
|
+
operator: "and" | "or";
|
|
75
|
+
conditions: SegmentCondition[];
|
|
76
|
+
groups?: SegmentCondition[][];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface SegmentTargetingRule {
|
|
80
|
+
id: string;
|
|
81
|
+
name?: string;
|
|
82
|
+
type?: string;
|
|
83
|
+
include?: boolean;
|
|
84
|
+
rules: SegmentRules;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface PageTargetingRule {
|
|
88
|
+
id: string;
|
|
89
|
+
name?: string;
|
|
90
|
+
include?: boolean;
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
includeRules?: UrlRule[];
|
|
93
|
+
excludeRules?: UrlRule[];
|
|
94
|
+
advancedCondition?: {
|
|
95
|
+
code?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
pollOnRules?: boolean;
|
|
98
|
+
} | null;
|
|
99
|
+
trigger?: {
|
|
100
|
+
mode?:
|
|
101
|
+
| "immediate"
|
|
102
|
+
| "history"
|
|
103
|
+
| "polling"
|
|
104
|
+
| "dom"
|
|
105
|
+
| "manual-callback"
|
|
106
|
+
| "manual-api";
|
|
107
|
+
pollOnRules?: boolean;
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
alwaysEmbedInSnippet?: boolean;
|
|
110
|
+
deactivationMode?: "reset" | "deactivate" | "force-reset" | "persistent";
|
|
111
|
+
triggerJs?: string;
|
|
112
|
+
apiName?: string;
|
|
113
|
+
signal?: string;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface Targeting {
|
|
118
|
+
deviceType?: "all" | "desktop" | "mobile" | "tablet";
|
|
119
|
+
url?: UrlRule[];
|
|
120
|
+
attributes?: AttributeRule[];
|
|
121
|
+
pages?: Array<{
|
|
122
|
+
id: string;
|
|
123
|
+
include?: boolean;
|
|
124
|
+
}>;
|
|
125
|
+
pageRules?: PageTargetingRule[];
|
|
126
|
+
segments?: Array<{
|
|
127
|
+
id: string;
|
|
128
|
+
include?: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
segmentRules?: SegmentTargetingRule[];
|
|
131
|
+
lifecycle?: {
|
|
132
|
+
mode?: "reset" | "deactivate" | "force_reset" | "persistent";
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface CaptureRule {
|
|
137
|
+
/** Output key in the event data (e.g. "price", "product_id") */
|
|
138
|
+
property: string;
|
|
139
|
+
/** Where to read the value from */
|
|
140
|
+
source: "attribute" | "textContent" | "dataset";
|
|
141
|
+
/** Attribute name when source is "attribute" or "dataset" */
|
|
142
|
+
attribute?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface Goal {
|
|
146
|
+
id: string;
|
|
147
|
+
type: "click" | "pageview" | "custom" | "revenue";
|
|
148
|
+
selector?: string;
|
|
149
|
+
/** Case-insensitive text content match. When set, the clicked element's textContent must include this string. */
|
|
150
|
+
textMatch?: string;
|
|
151
|
+
urlPattern?: string;
|
|
152
|
+
/** Custom analytics event name that should count as this goal. */
|
|
153
|
+
eventName?: string;
|
|
154
|
+
countOnce?: boolean;
|
|
155
|
+
/** Value capture rules — extract element attribute values on goal fire */
|
|
156
|
+
capture?: CaptureRule[];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface SnippetDeliveryUrlRule {
|
|
160
|
+
type: "simple" | "regex";
|
|
161
|
+
pattern: string;
|
|
162
|
+
include?: boolean;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export type SnippetCriticalMutation = [string, MutationAction, unknown?];
|
|
166
|
+
|
|
167
|
+
export interface SnippetCriticalMutationPlanVariation {
|
|
168
|
+
id: string;
|
|
169
|
+
w: number;
|
|
170
|
+
c?: 1;
|
|
171
|
+
m: SnippetCriticalMutation[];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface SnippetCriticalMutationPlanItem {
|
|
175
|
+
e: string;
|
|
176
|
+
r: SnippetDeliveryUrlRule[];
|
|
177
|
+
v: SnippetCriticalMutationPlanVariation[];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface SnippetDeliveryManifest {
|
|
181
|
+
version?: 1;
|
|
182
|
+
revision?: number;
|
|
183
|
+
deliveryState?:
|
|
184
|
+
| "no_visual_tests"
|
|
185
|
+
| "non_critical_visual"
|
|
186
|
+
| "critical_visual"
|
|
187
|
+
| "edge_managed"
|
|
188
|
+
| string;
|
|
189
|
+
criticalMutationPlan?: SnippetCriticalMutationPlanItem[];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface Variation {
|
|
193
|
+
id: string;
|
|
194
|
+
name?: string;
|
|
195
|
+
weight: number;
|
|
196
|
+
mutations: Mutation[];
|
|
197
|
+
value?: unknown;
|
|
198
|
+
css?: string;
|
|
199
|
+
js?: string;
|
|
200
|
+
resetJs?: string;
|
|
201
|
+
antiFlickerSelectors?: string[];
|
|
202
|
+
externalCssUrl?: string;
|
|
203
|
+
externalJsUrl?: string;
|
|
204
|
+
harnessSession?: HarnessSessionInfo;
|
|
205
|
+
isControl?: boolean;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface HarnessSessionInfo {
|
|
209
|
+
token?: string;
|
|
210
|
+
version?: number;
|
|
211
|
+
expiresAt?: string;
|
|
212
|
+
manifestUrl?: string;
|
|
213
|
+
pollIntervalMs?: number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface Experiment {
|
|
217
|
+
id: string;
|
|
218
|
+
kind?: "experiment" | "feature_flag" | "personalization";
|
|
219
|
+
name?: string;
|
|
220
|
+
status?: string;
|
|
221
|
+
targeting?: Targeting;
|
|
222
|
+
trafficAllocation?: number;
|
|
223
|
+
assignmentEpoch?: number;
|
|
224
|
+
assignmentEpochStartedAt?: string | null;
|
|
225
|
+
css?: string;
|
|
226
|
+
js?: string;
|
|
227
|
+
resetJs?: string;
|
|
228
|
+
behaviorCapture?: {
|
|
229
|
+
enabled?: boolean;
|
|
230
|
+
clicks?: boolean;
|
|
231
|
+
scrolls?: boolean;
|
|
232
|
+
moves?: boolean;
|
|
233
|
+
sampleRate?: number;
|
|
234
|
+
};
|
|
235
|
+
variations: Variation[];
|
|
236
|
+
hashAttribute?: string;
|
|
237
|
+
goals?: Goal[];
|
|
238
|
+
featureFlag?: {
|
|
239
|
+
id?: string;
|
|
240
|
+
key: string;
|
|
241
|
+
sourceExperimentId?: string | null;
|
|
242
|
+
sourceVariationId?: string | null;
|
|
243
|
+
};
|
|
244
|
+
personalization?: {
|
|
245
|
+
id?: string;
|
|
246
|
+
key: string;
|
|
247
|
+
ruleId?: string | null;
|
|
248
|
+
experienceId?: string | null;
|
|
249
|
+
surface?: string;
|
|
250
|
+
templateKey?: string | null;
|
|
251
|
+
priority?: number;
|
|
252
|
+
stopAfterMatch?: boolean;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** A single experiment's membership + priority share inside an exclusion group. */
|
|
257
|
+
export interface ExclusionGroupMemberConfig {
|
|
258
|
+
experimentId: string;
|
|
259
|
+
/** Fractional priority weight used to pick the winner when members overlap (0..1). */
|
|
260
|
+
share: number;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** Server-authored group that resolves only experiments that overlap for a visitor. */
|
|
264
|
+
export interface ExclusionGroupConfig {
|
|
265
|
+
id: string;
|
|
266
|
+
name?: string;
|
|
267
|
+
/** Bumping the epoch resets group-sticky selections. */
|
|
268
|
+
epoch?: number;
|
|
269
|
+
members: ExclusionGroupMemberConfig[];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface Assignment {
|
|
273
|
+
experimentId: string;
|
|
274
|
+
experimentName?: string;
|
|
275
|
+
variationId: string;
|
|
276
|
+
index: number;
|
|
277
|
+
mutations: Mutation[];
|
|
278
|
+
value?: unknown;
|
|
279
|
+
featureFlag?: Experiment["featureFlag"];
|
|
280
|
+
personalization?: Experiment["personalization"];
|
|
281
|
+
kind?: Experiment["kind"];
|
|
282
|
+
experimentCss?: string;
|
|
283
|
+
experimentJs?: string;
|
|
284
|
+
experimentResetJs?: string;
|
|
285
|
+
css?: string;
|
|
286
|
+
js?: string;
|
|
287
|
+
resetJs?: string;
|
|
288
|
+
externalCssUrl?: string;
|
|
289
|
+
externalJsUrl?: string;
|
|
290
|
+
harnessSession?: HarnessSessionInfo;
|
|
291
|
+
isControl: boolean;
|
|
292
|
+
hashValue: string;
|
|
293
|
+
assignmentEpoch?: number;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export type ExecutionMode = "auto" | "edge" | "client";
|
|
297
|
+
export type AntiFlickerMode = "scoped" | "full" | "off" | "custom";
|
|
298
|
+
export type TrackingStart = "idle" | "immediate";
|
|
299
|
+
export type CustomJsPolicy = "strict" | "hybrid" | "flex";
|
|
300
|
+
export type PlatformHint = "auto" | "shopify" | "spa" | "shopware";
|
|
301
|
+
export type RouterMode = "auto" | "history" | "navigation" | "none";
|
|
302
|
+
export type ActivationMode = "auto" | "observer" | "manual";
|
|
303
|
+
export type PageTriggerMode = "direct" | "url_change" | "dom_change" | "manual";
|
|
304
|
+
export type PerfFeatureFlag =
|
|
305
|
+
| "perf_platform_router_v1"
|
|
306
|
+
| "perf_shopify_pixel_buffer_v1"
|
|
307
|
+
| "perf_spa_incremental_reapply_v1"
|
|
308
|
+
| "perf_empty_project_v1";
|
|
309
|
+
export type PerfFeatureFlags = Partial<Record<PerfFeatureFlag, boolean>>;
|
|
310
|
+
|
|
311
|
+
export interface ProjectPrerequisites {
|
|
312
|
+
showVariationsRule?: string;
|
|
313
|
+
startTrackingRule?: string;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface ConsentModeSettings {
|
|
317
|
+
enabled?: boolean;
|
|
318
|
+
provider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes";
|
|
319
|
+
getter?: string;
|
|
320
|
+
requiredGroup?: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface DebugSettings {
|
|
324
|
+
enabled?: boolean;
|
|
325
|
+
restrictMode?: "off" | "query_param" | "user_ids" | "always";
|
|
326
|
+
queryParam?: string;
|
|
327
|
+
token?: string;
|
|
328
|
+
allowedUserIds?: string[];
|
|
329
|
+
persist?: boolean;
|
|
330
|
+
disableCache?: boolean;
|
|
331
|
+
active?: boolean;
|
|
332
|
+
expiresAt?: string | null;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface SpaSettings {
|
|
336
|
+
routerMode?: RouterMode;
|
|
337
|
+
activationMode?: ActivationMode;
|
|
338
|
+
reinitOnly?: boolean;
|
|
339
|
+
/** Re-assert mutations after SPA DOM changes. Defaults on for url_change, dom_change, and platformHint: "spa"; set false to opt out. */
|
|
340
|
+
domChangeTrigger?: boolean;
|
|
341
|
+
debounceMs?: number;
|
|
342
|
+
allowIframes?: boolean;
|
|
343
|
+
applyTiming?: "immediate" | "after_hydration";
|
|
344
|
+
hydrationTimeoutMs?: number;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface PageTriggerSettings {
|
|
348
|
+
defaultMode?: PageTriggerMode;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface ExternalTrackingSettings {
|
|
352
|
+
domains?: string[];
|
|
353
|
+
handoverQueryParam?: string;
|
|
354
|
+
handoverTtlSeconds?: number;
|
|
355
|
+
handoverMintTimeoutMs?: number;
|
|
356
|
+
signed?: boolean;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export interface ProjectCodeSettings {
|
|
360
|
+
enabled?: boolean;
|
|
361
|
+
css?: string;
|
|
362
|
+
helperJs?: string;
|
|
363
|
+
js?: string;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export interface DataLayerSignalMapping {
|
|
367
|
+
from: string;
|
|
368
|
+
to: string;
|
|
369
|
+
valueType?: RuntimeSignalDefinition["valueType"];
|
|
370
|
+
ttlDays?: number;
|
|
371
|
+
persist?: boolean;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface DataLayerRevenuePropertyMapping {
|
|
375
|
+
from: string;
|
|
376
|
+
to: string;
|
|
377
|
+
valueType?: RuntimeSignalDefinition["valueType"];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export interface DataLayerRevenueTrackingSettings {
|
|
381
|
+
enabled?: boolean;
|
|
382
|
+
revenueFrom?: string;
|
|
383
|
+
orderIdFrom?: string;
|
|
384
|
+
currencyFrom?: string;
|
|
385
|
+
costFrom?: string;
|
|
386
|
+
profitFrom?: string;
|
|
387
|
+
properties?: DataLayerRevenuePropertyMapping[];
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export interface DataLayerTriggerSettings {
|
|
391
|
+
enabled?: boolean;
|
|
392
|
+
dataLayerName?: string;
|
|
393
|
+
eventName: string;
|
|
394
|
+
reEvaluate?: boolean;
|
|
395
|
+
trackPageview?: boolean;
|
|
396
|
+
trackEventName?: string;
|
|
397
|
+
trackRevenue?: DataLayerRevenueTrackingSettings;
|
|
398
|
+
mappings?: DataLayerSignalMapping[];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export interface ExposureDataLayerDestination {
|
|
402
|
+
enabled?: boolean;
|
|
403
|
+
dataLayerName?: string;
|
|
404
|
+
eventName?: string;
|
|
405
|
+
includeMetadata?: boolean;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface ExposureHotjarDestination {
|
|
409
|
+
enabled?: boolean;
|
|
410
|
+
mode?: "identify" | "event";
|
|
411
|
+
eventName?: string;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export interface ExposureClarityDestination {
|
|
415
|
+
enabled?: boolean;
|
|
416
|
+
/** "set" writes one custom tag per experiment (default); "event" fires a named event; "both" does both. */
|
|
417
|
+
mode?: "set" | "event" | "both";
|
|
418
|
+
/** Prefix for the custom tag key. Default "apex ". */
|
|
419
|
+
tagPrefix?: string;
|
|
420
|
+
eventName?: string;
|
|
421
|
+
/** When true, calls clarity("upgrade", ...) once per page so experiment sessions beat Clarity's recording sampling. */
|
|
422
|
+
upgrade?: boolean;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export interface ExposureContentsquareDestination {
|
|
426
|
+
enabled?: boolean;
|
|
427
|
+
/** Prefix for the dynamic variable key. Default "apex ". */
|
|
428
|
+
keyPrefix?: string;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface ExposurePostHogDestination {
|
|
432
|
+
enabled?: boolean;
|
|
433
|
+
/** "capture" fires an event per exposure; "register" sets super properties; "both" does both. */
|
|
434
|
+
mode?: "capture" | "register" | "both";
|
|
435
|
+
eventName?: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface ExposureQueueDestination {
|
|
439
|
+
enabled?: boolean;
|
|
440
|
+
globalName: string;
|
|
441
|
+
method?: string;
|
|
442
|
+
eventName?: string;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface ExposureDestinationsSettings {
|
|
446
|
+
dataLayer?: ExposureDataLayerDestination;
|
|
447
|
+
hotjar?: ExposureHotjarDestination;
|
|
448
|
+
clarity?: ExposureClarityDestination;
|
|
449
|
+
contentsquare?: ExposureContentsquareDestination;
|
|
450
|
+
posthog?: ExposurePostHogDestination;
|
|
451
|
+
queues?: ExposureQueueDestination[];
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface RuntimeEnvironmentSettings {
|
|
455
|
+
activeKey?: string;
|
|
456
|
+
items?: Array<{
|
|
457
|
+
key: string;
|
|
458
|
+
name: string;
|
|
459
|
+
isDefault?: boolean;
|
|
460
|
+
subSnippetEnabled?: boolean;
|
|
461
|
+
}>;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export interface BucketingCleanupSettings {
|
|
465
|
+
enabled?: boolean;
|
|
466
|
+
retentionDays?: number;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export interface DataProtectionSettings {
|
|
470
|
+
storageMode?: "localStorage" | "sessionStorage" | "cookie" | "memory";
|
|
471
|
+
encodeStorageValues?: boolean;
|
|
472
|
+
respectDoNotTrack?: boolean;
|
|
473
|
+
cookieDomain?: string;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export interface RuntimeControlSettings {
|
|
477
|
+
disabled?: boolean;
|
|
478
|
+
reason?: string;
|
|
479
|
+
disabledAt?: string | null;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export type ActivationGateStatus = "passed" | "failed" | "skipped";
|
|
483
|
+
|
|
484
|
+
export interface ActivationGateDiagnostic {
|
|
485
|
+
id: string;
|
|
486
|
+
label: string;
|
|
487
|
+
status: ActivationGateStatus;
|
|
488
|
+
reason?: string;
|
|
489
|
+
detail?: Record<string, unknown>;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export interface ConditionDiagnostic {
|
|
493
|
+
id: string;
|
|
494
|
+
label: string;
|
|
495
|
+
status: ActivationGateStatus;
|
|
496
|
+
reason?: string;
|
|
497
|
+
operator?: string;
|
|
498
|
+
signal?: string;
|
|
499
|
+
expected?: unknown;
|
|
500
|
+
actual?: unknown;
|
|
501
|
+
source?: string;
|
|
502
|
+
sourceType?: "js" | "url" | "attribute" | "page_rule" | "segment";
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export interface TargetingDiagnostics {
|
|
506
|
+
matched: boolean;
|
|
507
|
+
gates: ActivationGateDiagnostic[];
|
|
508
|
+
conditions: ConditionDiagnostic[];
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export interface ExperimentActivationDiagnostic {
|
|
512
|
+
experimentId: string;
|
|
513
|
+
experimentName?: string;
|
|
514
|
+
status: ActivationGateStatus;
|
|
515
|
+
reason?: string;
|
|
516
|
+
assignedVariationId?: string;
|
|
517
|
+
assignedVariationIndex?: number;
|
|
518
|
+
forced?: boolean;
|
|
519
|
+
gates: ActivationGateDiagnostic[];
|
|
520
|
+
targetingConditions?: ConditionDiagnostic[];
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export interface ActivationDiagnostics {
|
|
524
|
+
project: {
|
|
525
|
+
gates: ActivationGateDiagnostic[];
|
|
526
|
+
};
|
|
527
|
+
experiments: ExperimentActivationDiagnostic[];
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export interface SdkDiagnostics {
|
|
531
|
+
/** Public diagnostics redact consent and tracking-gate internals unless SDK debug mode is enabled. */
|
|
532
|
+
mode: "public" | "debug";
|
|
533
|
+
initialized: boolean;
|
|
534
|
+
shopId: string | null;
|
|
535
|
+
userIdPresent: boolean;
|
|
536
|
+
assignments: Array<{
|
|
537
|
+
experimentId: string;
|
|
538
|
+
variationId: string;
|
|
539
|
+
kind: Experiment["kind"];
|
|
540
|
+
isControl: boolean;
|
|
541
|
+
mutationCount: number;
|
|
542
|
+
featureFlagKey?: string;
|
|
543
|
+
personalizationKey?: string;
|
|
544
|
+
personalizationRuleId?: string | null;
|
|
545
|
+
personalizationExperienceId?: string | null;
|
|
546
|
+
personalizationSurface?: string;
|
|
547
|
+
personalizationTemplateKey?: string | null;
|
|
548
|
+
personalizationPriority?: number;
|
|
549
|
+
personalizationStopAfterMatch?: boolean;
|
|
550
|
+
value?: unknown;
|
|
551
|
+
}>;
|
|
552
|
+
experimentsLoaded: number;
|
|
553
|
+
analyticsStarted: boolean;
|
|
554
|
+
trackerStarted: boolean;
|
|
555
|
+
activation: ActivationDiagnostics;
|
|
556
|
+
trackingBlocked?: boolean;
|
|
557
|
+
trackingDisabledByDnt?: boolean;
|
|
558
|
+
trackingPrerequisiteMet?: boolean;
|
|
559
|
+
consentRequired?: boolean;
|
|
560
|
+
consentGranted?: boolean;
|
|
561
|
+
consentModeEnabled?: boolean;
|
|
562
|
+
qaMode: boolean;
|
|
563
|
+
qaSessionId: string;
|
|
564
|
+
screenshotMode: boolean;
|
|
565
|
+
configSource: "inline" | "cache" | "network" | "none";
|
|
566
|
+
load: {
|
|
567
|
+
stage: string;
|
|
568
|
+
startedAt?: number;
|
|
569
|
+
updatedAt?: number;
|
|
570
|
+
configFetchStartedAt?: number;
|
|
571
|
+
configFetchCompletedAt?: number;
|
|
572
|
+
configFetchMs?: number;
|
|
573
|
+
configFetchAttempts?: number;
|
|
574
|
+
configFetchStatus?:
|
|
575
|
+
| "idle"
|
|
576
|
+
| "loading"
|
|
577
|
+
| "slow"
|
|
578
|
+
| "ok"
|
|
579
|
+
| "failed"
|
|
580
|
+
| "timeout";
|
|
581
|
+
configFetchStatusCode?: number;
|
|
582
|
+
configFetchError?: string;
|
|
583
|
+
assignmentReadyAt?: number;
|
|
584
|
+
assignmentReadyMs?: number;
|
|
585
|
+
firstMutationAt?: number;
|
|
586
|
+
revealAt?: number;
|
|
587
|
+
pendingMutations?: number;
|
|
588
|
+
appliedMutations?: number;
|
|
589
|
+
missedMutations?: number;
|
|
590
|
+
};
|
|
591
|
+
platform: PlatformHint;
|
|
592
|
+
routerMode: RouterMode;
|
|
593
|
+
activationMode: ActivationMode;
|
|
594
|
+
storage: {
|
|
595
|
+
mode: DataProtectionSettings["storageMode"];
|
|
596
|
+
localStorageAvailable: boolean;
|
|
597
|
+
sessionStorageAvailable: boolean;
|
|
598
|
+
cookiesEnabled: boolean;
|
|
599
|
+
};
|
|
600
|
+
runtime: {
|
|
601
|
+
antiFlickerMode?: AntiFlickerMode;
|
|
602
|
+
antiFlickerTimeoutMs?: number;
|
|
603
|
+
trackingStart?: TrackingStart;
|
|
604
|
+
pageTriggerMode?: PageTriggerMode;
|
|
605
|
+
customJsPolicy?: CustomJsPolicy;
|
|
606
|
+
externalHandoverDomains: string[];
|
|
607
|
+
handoverQueryParam: string;
|
|
608
|
+
handoverMintTimeoutMs?: number;
|
|
609
|
+
runtimeDisabled?: boolean;
|
|
610
|
+
runtimeDisabledAt?: string | null;
|
|
611
|
+
};
|
|
612
|
+
spa: {
|
|
613
|
+
lastUrl: string;
|
|
614
|
+
lastRouteChange?: {
|
|
615
|
+
previousUrl: string;
|
|
616
|
+
nextUrl: string;
|
|
617
|
+
reason: string;
|
|
618
|
+
at: number;
|
|
619
|
+
reEvaluated: boolean;
|
|
620
|
+
};
|
|
621
|
+
lastDataLayerTrigger?: {
|
|
622
|
+
eventName: string;
|
|
623
|
+
dataLayerName: string;
|
|
624
|
+
at: number;
|
|
625
|
+
mappedSignals: string[];
|
|
626
|
+
gtagNormalized?: boolean;
|
|
627
|
+
};
|
|
628
|
+
lastShopifyAssignmentSync?: {
|
|
629
|
+
at: number;
|
|
630
|
+
status: "pending" | "sent" | "skipped" | "failed";
|
|
631
|
+
reason?: string;
|
|
632
|
+
assignmentCount: number;
|
|
633
|
+
};
|
|
634
|
+
lastShopifyCartSync?: {
|
|
635
|
+
at: number;
|
|
636
|
+
status: "pending" | "sent" | "skipped" | "failed";
|
|
637
|
+
reason?: string;
|
|
638
|
+
assignmentCount: number;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
signals: {
|
|
642
|
+
values: Record<string, unknown>;
|
|
643
|
+
sources: Record<string, string>;
|
|
644
|
+
};
|
|
645
|
+
integrations: {
|
|
646
|
+
exposureDestinations: Array<{
|
|
647
|
+
type: string;
|
|
648
|
+
status: "sent" | "skipped" | "failed";
|
|
649
|
+
at: number;
|
|
650
|
+
reason?: string;
|
|
651
|
+
}>;
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export interface ConfigProfile {
|
|
656
|
+
platform: PlatformHint;
|
|
657
|
+
version: 1;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export type SignalCaptureMode =
|
|
661
|
+
| "manual"
|
|
662
|
+
| "url_parameter"
|
|
663
|
+
| "dom_selector"
|
|
664
|
+
| "global"
|
|
665
|
+
| "data_layer"
|
|
666
|
+
| "event_property"
|
|
667
|
+
| "click_selector"
|
|
668
|
+
| "computed";
|
|
669
|
+
|
|
670
|
+
export interface SignalCaptureDefinition {
|
|
671
|
+
mode: SignalCaptureMode;
|
|
672
|
+
parameter?: string;
|
|
673
|
+
eventName?: string;
|
|
674
|
+
property?: string;
|
|
675
|
+
selector?: string;
|
|
676
|
+
source?: "text" | "attribute" | "dataset" | "constant";
|
|
677
|
+
attribute?: string;
|
|
678
|
+
value?: string | number | boolean;
|
|
679
|
+
path?: string;
|
|
680
|
+
persist?: boolean;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
export interface RuntimeSignalDefinition {
|
|
684
|
+
key: string;
|
|
685
|
+
label?: string;
|
|
686
|
+
valueType?: "string" | "number" | "boolean" | "string_array" | "json";
|
|
687
|
+
ttlDays?: number;
|
|
688
|
+
capture?: SignalCaptureDefinition;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface SemanticTrackingRule {
|
|
692
|
+
id: string;
|
|
693
|
+
eventType: string;
|
|
694
|
+
action: "visibility" | "click";
|
|
695
|
+
selector: string;
|
|
696
|
+
pageType?: string;
|
|
697
|
+
elementRole?: string;
|
|
698
|
+
label?: string;
|
|
699
|
+
labelSource?: "text" | "attribute" | "constant";
|
|
700
|
+
attribute?: string;
|
|
701
|
+
indexStrategy?: "dom_order" | "none";
|
|
702
|
+
pathPattern?: string;
|
|
703
|
+
oncePerSession?: boolean;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export interface SemanticTrackingSettings {
|
|
707
|
+
enabled?: boolean;
|
|
708
|
+
sampleRate?: number;
|
|
709
|
+
visibilityThreshold?: number;
|
|
710
|
+
minVisibleMs?: number;
|
|
711
|
+
maxEventsPerSession?: number;
|
|
712
|
+
rules?: SemanticTrackingRule[];
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export interface CommercePriceSettings {
|
|
716
|
+
revision: number;
|
|
717
|
+
checksum: string;
|
|
718
|
+
authorization?: {
|
|
719
|
+
version: 1;
|
|
720
|
+
revision: number;
|
|
721
|
+
checksum: string;
|
|
722
|
+
experimentIds: string[];
|
|
723
|
+
cartValidationShop?: string;
|
|
724
|
+
};
|
|
725
|
+
experiments: Array<{
|
|
726
|
+
experiment_id: string;
|
|
727
|
+
assignment_epoch?: number;
|
|
728
|
+
currency: string;
|
|
729
|
+
variants: Record<string, Array<{
|
|
730
|
+
variant_gid: string;
|
|
731
|
+
fixedPricePerUnit?: string;
|
|
732
|
+
compareAt?: { mode: "set"; amount: string } | { mode: "clear" };
|
|
733
|
+
}>>;
|
|
734
|
+
}>;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export interface CommerceShippingSettings {
|
|
738
|
+
authorization?: {
|
|
739
|
+
version: 1;
|
|
740
|
+
revision: number;
|
|
741
|
+
checksum: string;
|
|
742
|
+
experimentIds: string[];
|
|
743
|
+
};
|
|
744
|
+
experiments: Array<{
|
|
745
|
+
experiment_id: string;
|
|
746
|
+
assignment_epoch?: number;
|
|
747
|
+
currency: string;
|
|
748
|
+
variants: Record<
|
|
749
|
+
string,
|
|
750
|
+
{
|
|
751
|
+
threshold: string | null;
|
|
752
|
+
treatment:
|
|
753
|
+
| "progress_bar"
|
|
754
|
+
| "banner"
|
|
755
|
+
| "free_shipping"
|
|
756
|
+
| "flat_rate"
|
|
757
|
+
| "percent_off"
|
|
758
|
+
| "none";
|
|
759
|
+
progressCopy: string;
|
|
760
|
+
reachedCopy: string;
|
|
761
|
+
bannerCopy: string;
|
|
762
|
+
flatRate: string | null;
|
|
763
|
+
percentOff: number | null;
|
|
764
|
+
target: { productGids: string[]; variantGids: string[] };
|
|
765
|
+
}
|
|
766
|
+
>;
|
|
767
|
+
}>;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
export interface CommerceOffersSettings {
|
|
771
|
+
authorization?: {
|
|
772
|
+
version: 1;
|
|
773
|
+
revision: number;
|
|
774
|
+
checksum: string;
|
|
775
|
+
experimentIds: string[];
|
|
776
|
+
cartValidationShop?: string;
|
|
777
|
+
};
|
|
778
|
+
experiments: CommerceOfferExperiment[];
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
export interface CommerceOfferExperiment {
|
|
782
|
+
experiment_id: string;
|
|
783
|
+
assignment_epoch?: number;
|
|
784
|
+
currency: string;
|
|
785
|
+
variants: Record<string,
|
|
786
|
+
| { offer_type: "gwp_threshold"; threshold: string; gift_variant_gid: string; tiers?: Array<{ threshold: string; gift_variant_gid: string; gift_choice_variant_gids?: string[] }> }
|
|
787
|
+
| { offer_type: string; control: true }
|
|
788
|
+
| Record<string, unknown>
|
|
789
|
+
>;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
export interface InitConfig {
|
|
793
|
+
/** Provide experiments inline OR use shopId to auto-fetch from API. */
|
|
794
|
+
experiments?: Experiment[];
|
|
795
|
+
/** Request-scoped edge geography used for targeting. */
|
|
796
|
+
geo?: { country?: string };
|
|
797
|
+
/** Server-authored exclusion groups. Overlapping members never co-occur; one wins by share. */
|
|
798
|
+
exclusionGroups?: ExclusionGroupConfig[];
|
|
799
|
+
/** Active custom signal definitions that the runtime should capture for targeting. */
|
|
800
|
+
signals?: RuntimeSignalDefinition[];
|
|
801
|
+
/** Server-authored presentation-only commerce settings. */
|
|
802
|
+
commerce?: {
|
|
803
|
+
price?: CommercePriceSettings;
|
|
804
|
+
shipping?: CommerceShippingSettings;
|
|
805
|
+
offers?: CommerceOffersSettings;
|
|
806
|
+
};
|
|
807
|
+
/** Shop ID – when provided (without experiments), the SDK fetches running experiments from the API. */
|
|
808
|
+
shopId?: string;
|
|
809
|
+
/** Base URL for event tracking & config API (e.g. "https://events.drip-apex.com"). */
|
|
810
|
+
endpoint?: string;
|
|
811
|
+
/** Optional endpoint for signed storefront audit snapshots. Defaults to Apex production. */
|
|
812
|
+
auditEndpoint?: string;
|
|
813
|
+
/** Versioned editor bundle URL emitted by the Apex snippet. */
|
|
814
|
+
editorBundleUrl?: string;
|
|
815
|
+
ingestShopId?: string;
|
|
816
|
+
ingestSignature?: string;
|
|
817
|
+
attributes?: Record<string, unknown>;
|
|
818
|
+
userId?: string;
|
|
819
|
+
url?: string;
|
|
820
|
+
autoTrack?: boolean;
|
|
821
|
+
/** Persist fetched config in localStorage for faster repeat loads. Default: true. */
|
|
822
|
+
configCache?: boolean;
|
|
823
|
+
/** Fresh cache window in ms for local config cache. Default: 300000 (5m). */
|
|
824
|
+
configCacheTtlMs?: number;
|
|
825
|
+
/** Behavior when async config resolves after anti-flicker has already revealed. Default: "skip". */
|
|
826
|
+
lateConfigPolicy?: "skip" | "apply";
|
|
827
|
+
/**
|
|
828
|
+
* @deprecated Use `trackingStart`.
|
|
829
|
+
* Legacy compatibility: true -> "idle", false -> "immediate".
|
|
830
|
+
*/
|
|
831
|
+
deferTracking?: boolean;
|
|
832
|
+
/**
|
|
833
|
+
* @deprecated Use `antiFlickerMode`.
|
|
834
|
+
* Legacy compatibility: true -> "full", false -> "off".
|
|
835
|
+
*/
|
|
836
|
+
antiFlicker?: boolean;
|
|
837
|
+
/**
|
|
838
|
+
* @deprecated Use `antiFlickerTimeoutMs`.
|
|
839
|
+
* Legacy compatibility timeout in ms.
|
|
840
|
+
*/
|
|
841
|
+
antiFlickerTimeout?: number;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Execution mode. Default: "auto".
|
|
845
|
+
* - "auto": edge-first when proxied, client fallback otherwise.
|
|
846
|
+
* - "edge": force edge rewrite path only.
|
|
847
|
+
* - "client": force client-side SDK evaluation only.
|
|
848
|
+
*/
|
|
849
|
+
executionMode?: ExecutionMode;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Optional runtime platform hint.
|
|
853
|
+
* Priority order at runtime:
|
|
854
|
+
* 1) explicit platformHint
|
|
855
|
+
* 2) payload profile.platform
|
|
856
|
+
* 3) auto detection
|
|
857
|
+
*/
|
|
858
|
+
platformHint?: PlatformHint;
|
|
859
|
+
/** Optional config payload profile metadata. */
|
|
860
|
+
profile?: ConfigProfile;
|
|
861
|
+
/** Router observation mode. Default: auto. */
|
|
862
|
+
routerMode?: RouterMode;
|
|
863
|
+
/** Mutation activation mode. Default: auto (observer). */
|
|
864
|
+
activationMode?: ActivationMode;
|
|
865
|
+
/** Project-level prerequisite rules evaluated in the browser before variation display/tracking. */
|
|
866
|
+
projectPrerequisites?: ProjectPrerequisites;
|
|
867
|
+
/** Strict consent mode: render variants before consent, but avoid persistent storage and tracking until consent. */
|
|
868
|
+
consentMode?: ConsentModeSettings;
|
|
869
|
+
/** Restricted debug console settings. */
|
|
870
|
+
debug?: DebugSettings;
|
|
871
|
+
/** SPA and dynamic-site support settings. */
|
|
872
|
+
spa?: SpaSettings;
|
|
873
|
+
/** Default page activation trigger. "direct" preserves immediate snippet behavior. */
|
|
874
|
+
pageTrigger?: PageTriggerSettings;
|
|
875
|
+
/** Cross-domain bucket handover for external checkout, booking, or lead-flow domains. */
|
|
876
|
+
externalTracking?: ExternalTrackingSettings;
|
|
877
|
+
/** dataLayer/custom analytics event triggers for SPA storefronts. */
|
|
878
|
+
dataLayerTriggers?: DataLayerTriggerSettings[];
|
|
879
|
+
/** External analytics destinations for experiment exposure events. */
|
|
880
|
+
exposureDestinations?: ExposureDestinationsSettings;
|
|
881
|
+
/** Advanced project-level CSS and JavaScript. */
|
|
882
|
+
projectCode?: ProjectCodeSettings;
|
|
883
|
+
/** Environment metadata included in edge-delivered config. */
|
|
884
|
+
environments?: RuntimeEnvironmentSettings;
|
|
885
|
+
/** Browser storage cleanup for stale bucket/QA/config records. */
|
|
886
|
+
bucketingCleanup?: BucketingCleanupSettings;
|
|
887
|
+
/** Browser storage/privacy controls. */
|
|
888
|
+
dataProtection?: DataProtectionSettings;
|
|
889
|
+
/** Semantic interaction capture for PDP galleries, tabs, CTAs, and other named store behavior. */
|
|
890
|
+
semanticTracking?: SemanticTrackingSettings;
|
|
891
|
+
/** Server-authoritative runtime kill switch state. */
|
|
892
|
+
runtimeControl?: RuntimeControlSettings;
|
|
893
|
+
/** Snippet compiler delivery state for SDK performance telemetry. */
|
|
894
|
+
deliveryState?:
|
|
895
|
+
| "no_visual_tests"
|
|
896
|
+
| "non_critical_visual"
|
|
897
|
+
| "critical_visual"
|
|
898
|
+
| "edge_managed"
|
|
899
|
+
| string;
|
|
900
|
+
/** Worker/cache source label for SDK performance telemetry. */
|
|
901
|
+
scriptCacheSource?:
|
|
902
|
+
| "edge"
|
|
903
|
+
| "kv"
|
|
904
|
+
| "origin"
|
|
905
|
+
| "precompile"
|
|
906
|
+
| "precompiled"
|
|
907
|
+
| string;
|
|
908
|
+
/** Install surface that emitted this script. */
|
|
909
|
+
installSurface?:
|
|
910
|
+
| "direct_script"
|
|
911
|
+
| "shopify_app_embed"
|
|
912
|
+
| "legacy_shopify_redirect"
|
|
913
|
+
| string;
|
|
914
|
+
/** Immutable SDK artifact version selected by the Worker. */
|
|
915
|
+
sdkVersion?: string;
|
|
916
|
+
/** Resolved SDK policy mode selected by the Worker. */
|
|
917
|
+
sdkDeliveryMode?: "global" | "pinned" | "canary" | string;
|
|
918
|
+
/** Whether the selected SDK artifact is embedded in the snippet or loaded externally. */
|
|
919
|
+
sdkDeliverySource?: "embedded" | "external" | string;
|
|
920
|
+
/** Revision of the global SDK delivery policy used to compile the snippet. */
|
|
921
|
+
sdkPolicyRevision?: string;
|
|
922
|
+
/** Server-authoritative runtime profile. Unknown values must retain full behavior. */
|
|
923
|
+
runtimeProfile?: "full" | "empty_project" | "nonvisual_assignment" | string;
|
|
924
|
+
/** Precompiled delivery manifest emitted by the snippet compiler. */
|
|
925
|
+
delivery?: SnippetDeliveryManifest;
|
|
926
|
+
/** Compiled runtime feature profile selected by the Worker for this shop/revision. */
|
|
927
|
+
runtimeFeatures?: {
|
|
928
|
+
sdkVariant?: "live" | "heatmap" | "debug" | string;
|
|
929
|
+
heatmap?: boolean;
|
|
930
|
+
debug?: boolean;
|
|
931
|
+
qa?: boolean;
|
|
932
|
+
harness?: boolean;
|
|
933
|
+
audit?: boolean;
|
|
934
|
+
};
|
|
935
|
+
/** Runtime kill-switches for staged rollout features. */
|
|
936
|
+
perfFlags?: PerfFeatureFlags;
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Anti-flicker hiding strategy. Default: "scoped".
|
|
940
|
+
* - "scoped": hide only mutated selectors (lowest visual impact).
|
|
941
|
+
* - "full": hide entire page (legacy behavior).
|
|
942
|
+
* - "custom": use `antiFlickerCustomCss`.
|
|
943
|
+
* - "off": no anti-flicker hiding.
|
|
944
|
+
*/
|
|
945
|
+
antiFlickerMode?: AntiFlickerMode;
|
|
946
|
+
|
|
947
|
+
/** Anti-flicker auto-reveal timeout in ms. Default: 1200. */
|
|
948
|
+
antiFlickerTimeoutMs?: number;
|
|
949
|
+
/** CSS used when antiFlickerMode is "custom". */
|
|
950
|
+
antiFlickerCustomCss?: string;
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* When to start analytics/tracking. Default: "idle".
|
|
954
|
+
* - "idle": defer to requestIdleCallback / timeout (reduces startup cost).
|
|
955
|
+
* - "immediate": start analytics synchronously after init.
|
|
956
|
+
*/
|
|
957
|
+
trackingStart?: TrackingStart;
|
|
958
|
+
|
|
959
|
+
/** Idle timeout fallback in ms when trackingStart is "idle". Default: 2000. */
|
|
960
|
+
trackingIdleTimeoutMs?: number;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Custom JS execution policy. Default: "hybrid".
|
|
964
|
+
* - "strict": no custom JS execution in production.
|
|
965
|
+
* - "hybrid": custom JS allowed with safety guards (sourceURL, error isolation).
|
|
966
|
+
* - "flex": unrestricted custom JS (legacy behavior).
|
|
967
|
+
*/
|
|
968
|
+
customJsPolicy?: CustomJsPolicy;
|
|
969
|
+
|
|
970
|
+
/** If true, analytics/goal tracking starts only after consent is granted. */
|
|
971
|
+
requireConsent?: boolean;
|
|
972
|
+
/** Initial consent state when requireConsent is enabled. */
|
|
973
|
+
hasConsent?: boolean;
|
|
974
|
+
onExperimentViewed?: (assignment: Assignment) => void;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
export interface TrackEvent {
|
|
978
|
+
type: string;
|
|
979
|
+
data?: Record<string, unknown>;
|
|
980
|
+
experimentId?: string;
|
|
981
|
+
variationId?: string;
|
|
982
|
+
shopId?: string;
|
|
983
|
+
visitorId?: string;
|
|
984
|
+
sessionId?: string;
|
|
985
|
+
url?: string;
|
|
986
|
+
ts?: number;
|
|
987
|
+
event_id?: string;
|
|
988
|
+
environment?: string;
|
|
989
|
+
qa_mode?: boolean;
|
|
990
|
+
qa_session_id?: string;
|
|
991
|
+
}
|