@drip-apex/sdk 0.1.0 → 0.3.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 +5 -0
- package/dist/bundle-report.json +584 -226
- package/dist/define.cjs +123 -0
- package/dist/define.cjs.map +7 -0
- package/dist/define.mjs +102 -0
- package/dist/define.mjs.map +7 -0
- package/dist/drip.cjs +19283 -0
- package/dist/drip.cjs.map +7 -0
- package/dist/drip.debug.js +1 -1
- package/dist/drip.debug.js.map +1 -1
- package/dist/drip.heatmap.js +1 -1
- package/dist/drip.heatmap.js.map +1 -1
- package/dist/drip.js +1 -1
- package/dist/drip.js.map +1 -1
- package/dist/drip.live.js +1 -1
- package/dist/drip.live.js.map +1 -1
- package/dist/drip.mjs +19267 -0
- package/dist/drip.mjs.map +7 -0
- package/dist/drip.replay-recorder.js +2 -0
- package/dist/drip.replay-recorder.js.map +1 -0
- package/dist/editor.js +147 -142
- package/dist/editor.js.map +4 -4
- package/dist/flags.cjs +1788 -0
- package/dist/flags.cjs.map +7 -0
- package/dist/flags.mjs +1765 -0
- package/dist/flags.mjs.map +7 -0
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +2 -2
- package/dist/metafiles/define.cjs.meta.json +28 -0
- package/dist/metafiles/define.mjs.meta.json +32 -0
- package/dist/metafiles/drip.cjs.meta.json +3193 -0
- package/dist/metafiles/drip.debug.meta.json +2859 -574
- package/dist/metafiles/drip.heatmap.meta.json +2732 -460
- package/dist/metafiles/drip.live.meta.json +2732 -460
- package/dist/metafiles/drip.meta.json +2859 -574
- package/dist/metafiles/drip.mjs.meta.json +3235 -0
- package/dist/metafiles/drip.replay-recorder.meta.json +82 -0
- package/dist/metafiles/editor.meta.json +67 -27
- package/dist/metafiles/flags.cjs.meta.json +220 -0
- package/dist/metafiles/flags.mjs.meta.json +225 -0
- package/dist/metafiles/index.meta.json +2717 -491
- package/dist/metafiles/index.mjs.meta.json +14 -4
- package/dist/react/index.js +16636 -13533
- package/dist/react/index.js.map +4 -4
- package/dist/sri.json +20 -15
- package/dist/types/activation-runtime.d.ts +91 -0
- package/dist/types/analytics-runtime.d.ts +166 -0
- package/dist/types/antiflicker.d.ts +9 -3
- package/dist/types/assignment-cookie-sync.d.ts +31 -0
- package/dist/types/assignment-runtime.d.ts +257 -0
- package/dist/types/assignment-store.d.ts +4 -8
- package/dist/types/bucket.d.ts +1 -2
- package/dist/types/compact-store.d.ts +1 -0
- package/dist/types/config-runtime.d.ts +313 -0
- package/dist/types/consent-evaluation.d.ts +28 -0
- package/dist/types/css.d.ts +5 -3
- package/dist/types/debug-loader.d.ts +2 -0
- package/dist/types/decide-assignments.d.ts +31 -0
- package/dist/types/delivery-timing.d.ts +8 -0
- package/dist/types/early-interaction-capture.d.ts +79 -0
- package/dist/types/early-reassert.d.ts +32 -0
- package/dist/types/edge-runtime.d.ts +11 -0
- package/dist/types/editor/api.d.ts +3 -0
- package/dist/types/editor/controller.d.ts +3 -1
- package/dist/types/editor/publication-result.d.ts +11 -0
- package/dist/types/editor/types.d.ts +2 -1
- package/dist/types/editor/view-kit.d.ts +1 -1
- package/dist/types/endpoint.d.ts +8 -0
- package/dist/types/exclusion-groups.d.ts +4 -7
- package/dist/types/flags.d.ts +2 -0
- package/dist/types/goal-eligibility.d.ts +4 -0
- package/dist/types/goals.d.ts +10 -1
- package/dist/types/guards.d.ts +7 -7
- package/dist/types/handover.d.ts +12 -1
- package/dist/types/hash.d.ts +8 -4
- package/dist/types/hydration.d.ts +2 -1
- package/dist/types/index.d.ts +24 -128
- package/dist/types/init-test-helpers.d.ts +48 -0
- package/dist/types/inline-bootstrap.d.ts +26 -0
- package/dist/types/js.d.ts +3 -1
- package/dist/types/money.d.ts +12 -0
- package/dist/types/mutate.d.ts +45 -6
- package/dist/types/performance.d.ts +2 -0
- package/dist/types/persistence-decoders.d.ts +12 -0
- package/dist/types/public-api.d.ts +209 -0
- package/dist/types/qa-assistant-state.d.ts +34 -0
- package/dist/types/react/index.d.ts +28 -3
- package/dist/types/reassert-sentinel.d.ts +6 -0
- package/dist/types/redirect.d.ts +48 -0
- package/dist/types/replay-recorder-entry.d.ts +1 -0
- package/dist/types/replay-signal-state.d.ts +6 -0
- package/dist/types/replay-signals.d.ts +13 -0
- package/dist/types/replay.d.ts +110 -0
- package/dist/types/router.d.ts +12 -2
- package/dist/types/runtime-state.d.ts +166 -0
- package/dist/types/sanitize.d.ts +1 -0
- package/dist/types/shadow.d.ts +3 -0
- package/dist/types/shopify-cart.d.ts +25 -1
- package/dist/types/storefront-vitals.d.ts +24 -0
- package/dist/types/targeting-diagnostics.d.ts +1 -0
- package/dist/types/targeting.d.ts +16 -2
- package/dist/types/track.d.ts +15 -1
- package/dist/types/types.d.ts +115 -9
- package/dist/types/wait.d.ts +14 -1
- package/dist/types/weekday-schedule.d.ts +3 -0
- package/package.json +17 -8
- package/src/activation-runtime.ts +2737 -0
- package/src/analytics-runtime.ts +2175 -0
- package/src/antiflicker.test.ts +216 -44
- package/src/antiflicker.ts +103 -28
- package/src/artifact-concurrency.test.ts +1091 -0
- package/src/assignment-cookie-sync.test.ts +202 -0
- package/src/assignment-cookie-sync.ts +189 -0
- package/src/assignment-runtime.ts +3204 -0
- package/src/assignment-store.test.ts +56 -0
- package/src/assignment-store.ts +7 -38
- package/src/bucket.ts +3 -18
- package/src/commerce-analytics-lifecycle.test.ts +75 -15
- package/src/commerce-config-lifecycle.test.ts +81 -1
- package/src/commerce-price-preserve.test.ts +133 -0
- package/src/commerce-price.test.ts +97 -0
- package/src/commerce-price.ts +74 -20
- package/src/commerce-shipping.test.ts +53 -0
- package/src/commerce-shipping.ts +5 -11
- package/src/compact-store.ts +15 -0
- package/src/config-fetch.test.ts +480 -9
- package/src/config-runtime.ts +2071 -0
- package/src/consent-evaluation-borlabs.test.ts +41 -0
- package/src/consent-evaluation-cookiescript.test.ts +50 -0
- package/src/consent-evaluation.ts +151 -0
- package/src/css.test.ts +30 -0
- package/src/css.ts +120 -6
- package/src/cwv.test.ts +60 -77
- package/src/debug-loader.test.ts +214 -0
- package/src/debug-loader.ts +41 -0
- package/src/decide-assignments.test.ts +196 -0
- package/src/decide-assignments.ts +204 -0
- package/src/delivery-timing.test.ts +104 -0
- package/src/delivery-timing.ts +89 -0
- package/src/early-interaction-capture.test.ts +451 -0
- package/src/early-interaction-capture.ts +230 -0
- package/src/early-reassert.test.ts +207 -0
- package/src/early-reassert.ts +152 -0
- package/src/edge-adoption.test.ts +435 -0
- package/src/edge-runtime.ts +30 -0
- package/src/editor/api.test.ts +109 -0
- package/src/editor/api.ts +34 -3
- package/src/editor/controller.test.ts +297 -14
- package/src/editor/controller.ts +69 -5
- package/src/editor/index.test.ts +2 -0
- package/src/editor/index.ts +1 -0
- package/src/editor/publication-result.ts +58 -0
- package/src/editor/types.ts +10 -1
- package/src/editor/view-kit.ts +2 -1
- package/src/editor/view.test.ts +108 -0
- package/src/editor/view.ts +49 -7
- package/src/endpoint.test.ts +15 -0
- package/src/endpoint.ts +10 -0
- package/src/exclusion-groups.ts +8 -18
- package/src/flags.test.ts +88 -1
- package/src/flags.ts +29 -29
- package/src/global-runtime-reconciler.test.ts +271 -0
- package/src/goal-eligibility.test.ts +29 -0
- package/src/goal-eligibility.ts +17 -0
- package/src/goals.test.ts +144 -1
- package/src/goals.ts +97 -18
- package/src/guards.test.ts +99 -1
- package/src/guards.ts +34 -15
- package/src/handover-cache-order.test.ts +6 -3
- package/src/handover.test.ts +154 -8
- package/src/handover.ts +122 -12
- package/src/hash.ts +29 -54
- package/src/holdout.test.ts +26 -0
- package/src/hydration.test.ts +73 -2
- package/src/hydration.ts +18 -9
- package/src/index.ts +130 -7287
- package/src/init-analytics.test.ts +1694 -0
- package/src/init-anti-flicker.test.ts +1211 -0
- package/src/init-cart-attributes.test.ts +2003 -0
- package/src/init-config-resolution.test.ts +999 -0
- package/src/init-consent.test.ts +971 -0
- package/src/init-empty.test.ts +11 -5406
- package/src/init-integrations.test.ts +846 -0
- package/src/init-page-activation.test.ts +5064 -0
- package/src/init-qa-loading.test.ts +740 -0
- package/src/init-redirects.test.ts +2156 -0
- package/src/init-test-helpers.ts +287 -0
- package/src/inline-bootstrap.test.ts +184 -0
- package/src/inline-bootstrap.ts +73 -0
- package/src/js.test.ts +51 -1
- package/src/js.ts +86 -2
- package/src/money.test.ts +55 -1
- package/src/money.ts +104 -2
- package/src/money.web-parity.contract.test.ts +85 -0
- package/src/mutate.test.ts +474 -10
- package/src/mutate.ts +739 -230
- package/src/page-trigger.test.ts +218 -8
- package/src/performance.ts +10 -0
- package/src/persistence-decoders.ts +18 -0
- package/src/public-api.ts +1828 -0
- package/src/qa-assistant-state.test.ts +249 -3
- package/src/qa-assistant-state.ts +146 -6
- package/src/qa-assistant-view.test.ts +220 -2
- package/src/qa-assistant-view.ts +102 -5
- package/src/react/index.test.tsx +37 -0
- package/src/react/index.tsx +19 -3
- package/src/reassert-sentinel.test.ts +155 -1
- package/src/reassert-sentinel.ts +168 -8
- package/src/redirect.test.ts +541 -0
- package/src/redirect.ts +572 -0
- package/src/replay-recorder-entry.ts +115 -0
- package/src/replay-signal-state.ts +100 -0
- package/src/replay-signals.test.ts +249 -0
- package/src/replay-signals.ts +151 -0
- package/src/replay.test.ts +764 -0
- package/src/replay.ts +514 -0
- package/src/router.test.ts +61 -2
- package/src/router.ts +50 -12
- package/src/runtime-state.ts +507 -0
- package/src/runtime.test.ts +174 -7
- package/src/runtime.ts +88 -14
- package/src/sanitize.test.ts +34 -0
- package/src/sanitize.ts +23 -12
- package/src/shadow.test.ts +187 -0
- package/src/shadow.ts +99 -0
- package/src/shopify-cart.test.ts +733 -23
- package/src/shopify-cart.ts +402 -49
- package/src/storefront-vitals.test.ts +217 -0
- package/src/storefront-vitals.ts +206 -0
- package/src/surface-signals.ts +6 -0
- package/src/targeting-conformance.test.ts +9 -0
- package/src/targeting-diagnostics.ts +38 -8
- package/src/targeting-parity-corpus.json +559 -0
- package/src/targeting-parity-corpus.test.ts +18 -0
- package/src/targeting.detailed.test.ts +105 -0
- package/src/targeting.test.ts +211 -0
- package/src/targeting.ts +88 -207
- package/src/track.test.ts +147 -0
- package/src/track.ts +125 -26
- package/src/types.ts +120 -13
- package/src/wait.test.ts +23 -0
- package/src/wait.ts +129 -13
- package/src/weekday-delivery.test.ts +56 -0
- package/src/weekday-schedule-parity-corpus.json +92 -0
- package/src/weekday-schedule.test.ts +69 -0
- package/src/weekday-schedule.ts +20 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { type CartAttributeEntry, type CartMetafieldInput, type CartAttributeSyncInput } from "./shopify-cart";
|
|
2
|
+
import { getPendingGiftChoices, selectGiftOption } from "./commerce-gift";
|
|
3
|
+
import { type ApexRuntimeTools } from "./runtime-tools";
|
|
4
|
+
import { rememberProduct, setCartSignals, setSearchSignal } from "./signals";
|
|
5
|
+
import { Assignment, Experiment, Goal, InitConfig, SdkDiagnostics } from "./types";
|
|
6
|
+
import { setPublicSignal, getPublicSignals, triggerPage } from "./config-runtime";
|
|
7
|
+
import { evaluate } from "./assignment-runtime";
|
|
8
|
+
export declare function loadQaToolbar(experiments: Experiment[]): void;
|
|
9
|
+
export declare function loadQaAssistant(onUnavailable?: () => void): void;
|
|
10
|
+
export declare function loadDevtoolsIfEnabled(experiments: Experiment[]): void;
|
|
11
|
+
export declare function loadDevtools(experiments: Experiment[]): void;
|
|
12
|
+
export declare function init(config: InitConfig): Assignment[];
|
|
13
|
+
export declare function trackEvent(type: string, data?: Record<string, unknown>, experimentId?: string, variationId?: string, eventId?: string, forceUnassigned?: boolean, timestamp?: number): void;
|
|
14
|
+
export declare function track(type: string, data?: Record<string, unknown>, experimentId?: string, variationId?: string): void;
|
|
15
|
+
export declare function funnelStepStorageKey(stepName: string): string;
|
|
16
|
+
export declare function shouldTrackFunnelStep(stepName: string, oncePerSession: boolean): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Track a virtual funnel step that has no reliable browser event by default,
|
|
19
|
+
* such as a postcode form submit, embedded quiz step, or third-party handoff.
|
|
20
|
+
*/
|
|
21
|
+
export declare function trackStep(name: string, data?: Record<string, unknown>): void;
|
|
22
|
+
export declare function trackGoal(goalId: string, data?: Record<string, unknown>): void;
|
|
23
|
+
export declare function setConsent(granted: boolean): void;
|
|
24
|
+
export declare function hold(): number;
|
|
25
|
+
export declare function release(): number;
|
|
26
|
+
export declare function hydrated(): void;
|
|
27
|
+
export declare function recheckPrerequisites(): void;
|
|
28
|
+
export declare function reInit(forceReapply?: boolean): Assignment[];
|
|
29
|
+
/**
|
|
30
|
+
* Track a revenue/purchase event. Convenience method that fires a "purchase" event
|
|
31
|
+
* with revenue data for all active experiments.
|
|
32
|
+
*
|
|
33
|
+
* Usage: drip.trackRevenue(49.99) or drip.trackRevenue(49.99, { orderId: "123", currency: "EUR" })
|
|
34
|
+
*/
|
|
35
|
+
export type RevenueEventData = Record<string, unknown> & {
|
|
36
|
+
currency?: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function normalizeRevenueCurrency(value: unknown): string | undefined;
|
|
39
|
+
export declare function trackRevenue(revenue: number, data?: RevenueEventData): void;
|
|
40
|
+
export declare function flush(): Promise<void>;
|
|
41
|
+
export declare function getAssignments(): Assignment[];
|
|
42
|
+
export declare function buildCurrentCartAttributes(scopedInput: CartAttributeSyncInput | null): CartAttributeEntry[];
|
|
43
|
+
export declare function getCartAttributes(): CartAttributeEntry[];
|
|
44
|
+
export declare function getCartMetafields(options?: {
|
|
45
|
+
namespace?: string;
|
|
46
|
+
}): CartMetafieldInput[];
|
|
47
|
+
/** Return cart-metafield keys that must be deleted to clear the previous mirror. */
|
|
48
|
+
export declare function getCartMetafieldStaleKeys(options?: {
|
|
49
|
+
namespace?: string;
|
|
50
|
+
}): string[];
|
|
51
|
+
/** Replace entries supplied by the fresh Apex stamp while preserving valid cart attributes. */
|
|
52
|
+
export declare function mergeCartAttributes(existing: unknown): CartAttributeEntry[];
|
|
53
|
+
export declare function normalizedHeadlessCartToken(value: unknown): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Build cart attributes for a headless Shopify Storefront API cart.
|
|
56
|
+
*
|
|
57
|
+
* Integrator contract: pass the cart's full Storefront Cart GID (including its
|
|
58
|
+
* `?key=` secret), write every returned entry to that same cart, and verify the
|
|
59
|
+
* Storefront API mutation succeeded with no `userErrors`. Only then call
|
|
60
|
+
* {@link confirmCartAttributesWritten} with the same Cart GID. Returning signed
|
|
61
|
+
* attributes does not authorize treatment display or exposure by itself. An
|
|
62
|
+
* empty result is fail-closed and must not be replaced with unsigned attributes.
|
|
63
|
+
* Theme storefronts use the SDK-managed `/cart/update.js` path and do not call
|
|
64
|
+
* either headless API.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getSignedCartAttributes(cartToken?: string): Promise<CartAttributeEntry[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Acknowledge that the latest signed headless cart attributes were persisted.
|
|
69
|
+
*
|
|
70
|
+
* Call this only after the Storefront API cart-attributes mutation succeeded
|
|
71
|
+
* and returned no `userErrors`. The Cart GID must match the one passed to the
|
|
72
|
+
* latest {@link getSignedCartAttributes} call. Stale-generation, mismatched,
|
|
73
|
+
* or repeated acknowledgements are no-ops and cannot grant or change display
|
|
74
|
+
* and exposure authorization. When a staged offer adoption can no longer
|
|
75
|
+
* apply, the acknowledgement is rejected (`false`) with retryable pending
|
|
76
|
+
* state and no authorization is granted.
|
|
77
|
+
*
|
|
78
|
+
* @returns `true` only when the latest matching acknowledgement was accepted.
|
|
79
|
+
*/
|
|
80
|
+
export declare function confirmCartAttributesWritten(cartToken?: string): boolean;
|
|
81
|
+
export declare function getExperiments(): Experiment[];
|
|
82
|
+
export declare function getGoals(): Goal[];
|
|
83
|
+
export declare function getActiveExperimentIds(): Record<string, string>;
|
|
84
|
+
export declare function getRuntimeValue(key: string): unknown;
|
|
85
|
+
export declare function getRuntimeTools(): ApexRuntimeTools;
|
|
86
|
+
export declare function buildFlagContext(context?: {
|
|
87
|
+
url?: string;
|
|
88
|
+
attributes?: Record<string, unknown>;
|
|
89
|
+
userId?: string;
|
|
90
|
+
}): {
|
|
91
|
+
url: string;
|
|
92
|
+
attributes: Record<string, unknown>;
|
|
93
|
+
userId: string | undefined;
|
|
94
|
+
forceMap: Record<string, string> | undefined;
|
|
95
|
+
};
|
|
96
|
+
export declare function evaluateFlag(flagId: string, context?: {
|
|
97
|
+
url?: string;
|
|
98
|
+
attributes?: Record<string, unknown>;
|
|
99
|
+
userId?: string;
|
|
100
|
+
}): boolean;
|
|
101
|
+
export declare function evaluateFlagAssignment(flagId: string, context?: {
|
|
102
|
+
url?: string;
|
|
103
|
+
attributes?: Record<string, unknown>;
|
|
104
|
+
userId?: string;
|
|
105
|
+
}): Assignment | null;
|
|
106
|
+
export declare function evaluateFlagValue<T = unknown>(flagId: string, fallback?: T, context?: {
|
|
107
|
+
url?: string;
|
|
108
|
+
attributes?: Record<string, unknown>;
|
|
109
|
+
userId?: string;
|
|
110
|
+
}): T | unknown;
|
|
111
|
+
export declare function getDiagnostics(): SdkDiagnostics;
|
|
112
|
+
export type QueueCommand = {
|
|
113
|
+
type: "trackGoal";
|
|
114
|
+
goalId: string;
|
|
115
|
+
data?: Record<string, unknown>;
|
|
116
|
+
} | {
|
|
117
|
+
type: "trackRevenue";
|
|
118
|
+
revenue: number;
|
|
119
|
+
data?: RevenueEventData;
|
|
120
|
+
} | {
|
|
121
|
+
type: "track";
|
|
122
|
+
event: string;
|
|
123
|
+
data?: Record<string, unknown>;
|
|
124
|
+
} | {
|
|
125
|
+
type: "step";
|
|
126
|
+
name: string;
|
|
127
|
+
data?: Record<string, unknown>;
|
|
128
|
+
} | {
|
|
129
|
+
type: "signal";
|
|
130
|
+
key: string;
|
|
131
|
+
value: unknown;
|
|
132
|
+
ttlDays?: number;
|
|
133
|
+
} | {
|
|
134
|
+
type: "triggerPage";
|
|
135
|
+
apiName: string;
|
|
136
|
+
active?: unknown;
|
|
137
|
+
} | {
|
|
138
|
+
type: "rememberProduct";
|
|
139
|
+
product: Parameters<typeof rememberProduct>[0];
|
|
140
|
+
ttlDays?: number;
|
|
141
|
+
} | {
|
|
142
|
+
type: "setCart";
|
|
143
|
+
itemCount?: number;
|
|
144
|
+
productIds?: string[];
|
|
145
|
+
ttlDays?: number;
|
|
146
|
+
} | {
|
|
147
|
+
type: "setSearch";
|
|
148
|
+
query: string;
|
|
149
|
+
ttlDays?: number;
|
|
150
|
+
} | {
|
|
151
|
+
type: "setConsent";
|
|
152
|
+
granted: boolean;
|
|
153
|
+
} | {
|
|
154
|
+
type: "hold";
|
|
155
|
+
} | {
|
|
156
|
+
type: "release";
|
|
157
|
+
} | {
|
|
158
|
+
type: "hydrated";
|
|
159
|
+
} | {
|
|
160
|
+
type: "reInit";
|
|
161
|
+
force?: boolean;
|
|
162
|
+
} | {
|
|
163
|
+
type: "recheckPrerequisites";
|
|
164
|
+
} | {
|
|
165
|
+
type: "init";
|
|
166
|
+
config: InitConfig;
|
|
167
|
+
};
|
|
168
|
+
export declare function processCommand(cmd: QueueCommand): void;
|
|
169
|
+
export declare function processQueue(): void;
|
|
170
|
+
export declare let installedGlobalApi: ReturnType<typeof createGlobalApi> | undefined;
|
|
171
|
+
export declare function createGlobalApi(): ((command: string) => number | void) & {
|
|
172
|
+
init: typeof init;
|
|
173
|
+
track: typeof track;
|
|
174
|
+
step: typeof trackStep;
|
|
175
|
+
trackGoal: typeof trackGoal;
|
|
176
|
+
trackRevenue: typeof trackRevenue;
|
|
177
|
+
setConsent: typeof setConsent;
|
|
178
|
+
hold: typeof hold;
|
|
179
|
+
release: typeof release;
|
|
180
|
+
hydrated: typeof hydrated;
|
|
181
|
+
reInit: typeof reInit;
|
|
182
|
+
recheckPrerequisites: typeof recheckPrerequisites;
|
|
183
|
+
flush: typeof flush;
|
|
184
|
+
evaluate: typeof evaluate;
|
|
185
|
+
evaluateFlag: typeof evaluateFlag;
|
|
186
|
+
evaluateFlagAssignment: typeof evaluateFlagAssignment;
|
|
187
|
+
evaluateFlagValue: typeof evaluateFlagValue;
|
|
188
|
+
signal: typeof setPublicSignal;
|
|
189
|
+
triggerPage: typeof triggerPage;
|
|
190
|
+
rememberProduct: typeof rememberProduct;
|
|
191
|
+
setCart: typeof setCartSignals;
|
|
192
|
+
setSearch: typeof setSearchSignal;
|
|
193
|
+
getSignals: typeof getPublicSignals;
|
|
194
|
+
getAssignments: typeof getAssignments;
|
|
195
|
+
getCartAttributes: typeof getCartAttributes;
|
|
196
|
+
getCartMetafields: typeof getCartMetafields;
|
|
197
|
+
getCartMetafieldStaleKeys: typeof getCartMetafieldStaleKeys;
|
|
198
|
+
mergeCartAttributes: typeof mergeCartAttributes;
|
|
199
|
+
getSignedCartAttributes: typeof getSignedCartAttributes;
|
|
200
|
+
confirmCartAttributesWritten: typeof confirmCartAttributesWritten;
|
|
201
|
+
getExperiments: typeof getExperiments;
|
|
202
|
+
getTools: typeof getRuntimeTools;
|
|
203
|
+
get: typeof getRuntimeValue;
|
|
204
|
+
getDiagnostics: typeof getDiagnostics;
|
|
205
|
+
getPendingGiftChoices: typeof getPendingGiftChoices;
|
|
206
|
+
selectGiftOption: typeof selectGiftOption;
|
|
207
|
+
push(cmd: QueueCommand): void;
|
|
208
|
+
};
|
|
209
|
+
export declare function installGlobalApi(): void;
|
|
@@ -30,8 +30,18 @@ export type QaEventModel = {
|
|
|
30
30
|
type: "exposure" | "goal" | "revenue" | "pageview";
|
|
31
31
|
label: string;
|
|
32
32
|
value: string | null;
|
|
33
|
+
goalId?: string;
|
|
33
34
|
duplicateOf?: number;
|
|
34
35
|
};
|
|
36
|
+
export type QaGoalScopeModel = {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
pageId: string | null;
|
|
40
|
+
pageLabel: string | null;
|
|
41
|
+
urlPattern?: string | null;
|
|
42
|
+
status: "active" | "inactive" | "not_wired";
|
|
43
|
+
assignmentPageActive?: boolean | null;
|
|
44
|
+
};
|
|
35
45
|
export type QaTransactionsModel = {
|
|
36
46
|
kind: "unsupported";
|
|
37
47
|
} | {
|
|
@@ -52,11 +62,35 @@ export type QaTransactionsModel = {
|
|
|
52
62
|
}>;
|
|
53
63
|
serverReceipt: "pending" | "confirmed" | "unknown";
|
|
54
64
|
};
|
|
65
|
+
export type ForcedUnavailable = {
|
|
66
|
+
experimentId: string;
|
|
67
|
+
reason: "archived" | "runtime_disabled" | "not_found" | "environment_mismatch" | "not_in_config";
|
|
68
|
+
};
|
|
69
|
+
export type EdgeDeviceAudienceUnsupported = {
|
|
70
|
+
experimentId: string;
|
|
71
|
+
audienceName: string;
|
|
72
|
+
};
|
|
73
|
+
export type QaPageActivationModel = {
|
|
74
|
+
pageId: string;
|
|
75
|
+
pageName: string;
|
|
76
|
+
active: boolean;
|
|
77
|
+
lastTransitionMode: "reset" | "deactivate" | "force_reset" | "persistent" | null;
|
|
78
|
+
isolationFallback: "whole_experiment" | null;
|
|
79
|
+
triggerDetector?: "history" | "polling" | "dom" | null;
|
|
80
|
+
triggerPollAttempts?: number;
|
|
81
|
+
triggerOutcome?: "activated" | "condition_failed" | "window_expired" | null;
|
|
82
|
+
triggerElapsedMs?: number;
|
|
83
|
+
};
|
|
55
84
|
export type QaAssistantState = {
|
|
85
|
+
storeVersion: number;
|
|
56
86
|
experiments: QaExperimentModel[];
|
|
57
87
|
events: QaEventModel[];
|
|
88
|
+
goalScopes: QaGoalScopeModel[];
|
|
89
|
+
pageActivation: QaPageActivationModel[];
|
|
58
90
|
transactions: QaTransactionsModel;
|
|
59
91
|
forcedSummary: string | null;
|
|
92
|
+
forcedUnavailable: ForcedUnavailable[];
|
|
93
|
+
edgeDeviceAudienceUnsupported: EdgeDeviceAudienceUnsupported[];
|
|
60
94
|
};
|
|
61
95
|
export type QaAssistantStore = {
|
|
62
96
|
getState(): QaAssistantState;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* React bindings for Drip SDK.
|
|
3
3
|
*
|
|
4
4
|
* Usage:
|
|
5
|
-
* import { DripProvider, useExperiment, useVariation, useFeatureFlag, useFeatureFlagValue, useTrackGoal } from "@drip-apex/sdk/react";
|
|
5
|
+
* import { DripProvider, useExperiment, useVariation, useFeatureFlag, useFeatureFlagValue, useTrackGoal, useGetCartMetafields } from "@drip-apex/sdk/react";
|
|
6
6
|
*
|
|
7
7
|
* function App() {
|
|
8
8
|
* return (
|
|
@@ -28,7 +28,27 @@
|
|
|
28
28
|
* }
|
|
29
29
|
*/
|
|
30
30
|
import { type ReactNode } from "react";
|
|
31
|
-
import type { Assignment, InitConfig, Variation } from "../types";
|
|
31
|
+
import type { Assignment, Experiment, InitConfig, Variation } from "../types";
|
|
32
|
+
import type { RevenueEventData } from "../index";
|
|
33
|
+
import type { CartMetafieldInput } from "../shopify-cart";
|
|
34
|
+
interface DripContextValue {
|
|
35
|
+
/** Current experiment assignments. */
|
|
36
|
+
assignments: Assignment[];
|
|
37
|
+
/** Loaded experiment configs. */
|
|
38
|
+
experiments: Experiment[];
|
|
39
|
+
/** Whether the SDK is still loading config. */
|
|
40
|
+
loading: boolean;
|
|
41
|
+
/** Track a goal by goalId with optional data. */
|
|
42
|
+
trackGoal: (goalId: string, data?: Record<string, unknown>) => void;
|
|
43
|
+
/** Track a custom event. */
|
|
44
|
+
track: (type: string, data?: Record<string, unknown>) => void;
|
|
45
|
+
/** Track revenue. */
|
|
46
|
+
trackRevenue: (revenue: number, data?: RevenueEventData) => void;
|
|
47
|
+
/** Build headless Shopify cart metafields from the current attribution stamp. */
|
|
48
|
+
getCartMetafields: (options?: {
|
|
49
|
+
namespace?: string;
|
|
50
|
+
}) => Promise<CartMetafieldInput[]>;
|
|
51
|
+
}
|
|
32
52
|
export interface DripProviderProps extends Omit<InitConfig, "onExperimentViewed"> {
|
|
33
53
|
children: ReactNode;
|
|
34
54
|
/** Callback when an experiment is viewed (assignment applied). */
|
|
@@ -40,7 +60,7 @@ export interface DripProviderProps extends Omit<InitConfig, "onExperimentViewed"
|
|
|
40
60
|
* Initializes the SDK, fetches experiment config (if shopId provided),
|
|
41
61
|
* and provides assignment context to child components.
|
|
42
62
|
*/
|
|
43
|
-
export declare function DripProvider({ children, onExperimentViewed, ...config }: DripProviderProps): import("react
|
|
63
|
+
export declare function DripProvider({ children, onExperimentViewed, ...config }: DripProviderProps): import("react").JSX.Element;
|
|
44
64
|
/**
|
|
45
65
|
* Get the assignment for a specific experiment by ID or slug.
|
|
46
66
|
* Returns `null` if the user is not assigned to this experiment.
|
|
@@ -73,6 +93,10 @@ export declare function useTrack(): (type: string, data?: Record<string, unknown
|
|
|
73
93
|
* Returns a function to track revenue.
|
|
74
94
|
*/
|
|
75
95
|
export declare function useTrackRevenue(): (revenue: number, data?: Record<string, unknown>) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a function that builds the current Shopify cart-metafield mirror.
|
|
98
|
+
*/
|
|
99
|
+
export declare function useGetCartMetafields(): DripContextValue["getCartMetafields"];
|
|
76
100
|
/**
|
|
77
101
|
* Get all current assignments.
|
|
78
102
|
*/
|
|
@@ -82,3 +106,4 @@ export declare function useAssignments(): Assignment[];
|
|
|
82
106
|
*/
|
|
83
107
|
export declare function useLoading(): boolean;
|
|
84
108
|
export type { Assignment, Experiment, Variation, InitConfig } from "../types";
|
|
109
|
+
export type { CartMetafieldInput } from "../shopify-cart";
|
|
@@ -2,5 +2,11 @@ import type { Mutation } from "./types";
|
|
|
2
2
|
export declare function trackAppliedMutation(element: Element, mutation: Mutation, context: {
|
|
3
3
|
experimentId?: string;
|
|
4
4
|
variationId?: string;
|
|
5
|
+
journalSeq?: number;
|
|
6
|
+
artifactId?: string;
|
|
7
|
+
ownerKeys?: readonly string[];
|
|
5
8
|
}, apply: (element: Element, mutation: Mutation) => void): void;
|
|
9
|
+
export declare function addReassertSentinelOwners(existingOwnerKeys: ReadonlySet<string>, ownerKeys: readonly string[], artifactId?: string): void;
|
|
10
|
+
export declare function resetReassertSentinelForOwner(ownerKey: string, artifactId?: string): void;
|
|
11
|
+
export declare function replayReassertSentinelEntry(journalSeq: number, element: Element): void;
|
|
6
12
|
export declare function resetReassertSentinel(): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Assignment, Experiment } from "./types";
|
|
2
|
+
import type { ExternalTrackingSettings } from "./types";
|
|
3
|
+
export declare const REDIRECT_ASSIGNMENT_PARAM = "_apex_assignment";
|
|
4
|
+
export declare const REDIRECT_ASSIGNMENT_PENDING_KEY = "drip_redirect_assignment_pending_v1";
|
|
5
|
+
export type ParsedRedirectCarry = {
|
|
6
|
+
experimentId: string;
|
|
7
|
+
variationId: string;
|
|
8
|
+
assignmentEpoch: number;
|
|
9
|
+
handoverToken: string;
|
|
10
|
+
expiresAt: number;
|
|
11
|
+
exposureSent: boolean;
|
|
12
|
+
destinationPath?: string;
|
|
13
|
+
};
|
|
14
|
+
export type VerifiedRedirectCarry = ParsedRedirectCarry & {
|
|
15
|
+
visitorId: string;
|
|
16
|
+
attributionToken?: string;
|
|
17
|
+
attributionDestinationUrl?: string;
|
|
18
|
+
attributionIssuedAt?: number;
|
|
19
|
+
};
|
|
20
|
+
export type ImportedRedirectCarry = {
|
|
21
|
+
experiment: Experiment;
|
|
22
|
+
variationId: string;
|
|
23
|
+
visitorId: string;
|
|
24
|
+
exposureSent: boolean;
|
|
25
|
+
attributionToken?: string;
|
|
26
|
+
attributionDestinationUrl?: string;
|
|
27
|
+
attributionIssuedAt?: number;
|
|
28
|
+
};
|
|
29
|
+
export declare function hasGeneratedRedirectAssignmentCarry(destination: URL): boolean;
|
|
30
|
+
export declare function buildRedirectDestination(currentHref: string, redirectUrl: string, assignment: Pick<Assignment, "experimentId" | "variationId" | "assignmentEpoch">, visitorId?: string, handoverSettings?: ExternalTrackingSettings, includeAssignmentCarry?: boolean, exposureSent?: boolean): URL | null;
|
|
31
|
+
export declare function markRedirectAssignmentCarryExposed(destination: URL): void;
|
|
32
|
+
export declare function finalizeRedirectAssignmentCarryHandover(destination: URL, verifiedToken: string | null): void;
|
|
33
|
+
export declare function isRedirectLoop(currentHref: string, destination: URL): boolean;
|
|
34
|
+
export declare function filterUnsafeRedirectAssignments(experiments: Experiment[], assignments: Assignment[], currentHref: string, visitorId?: string, handoverSettings?: ExternalTrackingSettings, preserveAssignment?: (assignment: Assignment) => boolean, storeOrigin?: string | string[]): Assignment[];
|
|
35
|
+
export declare function redirectPlanForAssignment(experiments: Experiment[], assignments: Assignment[], currentHref: string, visitorId?: string, handoverSettings?: ExternalTrackingSettings, includeAssignmentCarry?: boolean, storeOrigin?: string | string[]): {
|
|
36
|
+
destination: URL;
|
|
37
|
+
assignment: Assignment;
|
|
38
|
+
} | null;
|
|
39
|
+
export declare function redirectForAssignment(experiments: Experiment[], assignments: Assignment[], currentHref: string, visitorId?: string, handoverSettings?: ExternalTrackingSettings, includeAssignmentCarry?: boolean, storeOrigin?: string | string[]): URL | null;
|
|
40
|
+
export declare function parseRedirectAssignmentCarry(href: string): ParsedRedirectCarry | null;
|
|
41
|
+
export declare function persistPendingRedirectAssignmentCarry(carry: ParsedRedirectCarry | null): void;
|
|
42
|
+
export declare function readPendingRedirectAssignmentCarry(): ParsedRedirectCarry | null;
|
|
43
|
+
export declare function clearPendingRedirectAssignmentCarry(): void;
|
|
44
|
+
export declare function verifyRedirectAssignmentCarry(carry: ParsedRedirectCarry | null, shopId: string, verifyToken: (token: string) => Promise<unknown>): Promise<VerifiedRedirectCarry | null>;
|
|
45
|
+
export declare function validateRedirectAssignmentCarry(experiments: Experiment[], carry: VerifiedRedirectCarry | null, href?: string): ImportedRedirectCarry | null;
|
|
46
|
+
export declare function readRedirectAssignmentCarry(experiments: Experiment[], href: string, shopId: string, verifyToken: (token: string) => Promise<unknown>): Promise<ImportedRedirectCarry | null>;
|
|
47
|
+
export declare function importRedirectAssignmentCarry(carry: ImportedRedirectCarry, href: string, persistAttribution?: boolean): void;
|
|
48
|
+
export declare function stripRedirectAssignmentCarry(href: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReplaySignals } from "./replay";
|
|
2
|
+
export declare const REPLAY_MAX_CLICK_SIGNALS = 100;
|
|
3
|
+
export declare const REPLAY_MAX_NAV_SIGNALS = 50;
|
|
4
|
+
export declare const REPLAY_MAX_ERROR_SIGNALS = 20;
|
|
5
|
+
export declare const REPLAY_MAX_FORM_SIGNALS = 20;
|
|
6
|
+
export declare function normalizeReplaySignalState(value: Partial<Record<keyof ReplaySignals, unknown>> | undefined): ReplaySignals;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReplaySignals } from "./replay";
|
|
2
|
+
type RrwebEvent = {
|
|
3
|
+
type?: number;
|
|
4
|
+
timestamp?: number;
|
|
5
|
+
data?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export declare function createReplaySignalDeriver(signalState?: ReplaySignals, captureStartedAt?: number): {
|
|
8
|
+
accept: (event: RrwebEvent, target: Element | null) => void;
|
|
9
|
+
error: (message: string, ts?: number) => void;
|
|
10
|
+
snapshot: (now?: number) => ReplaySignals;
|
|
11
|
+
submit: (target: Element | null, ts?: number) => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Assignment, Experiment } from "./types";
|
|
2
|
+
export declare const REPLAY_RECORDER_FILENAME = "drip.replay-recorder.js";
|
|
3
|
+
export declare const REPLAY_FLUSH_INTERVAL_MS = 10000;
|
|
4
|
+
export declare const REPLAY_UNCOMPRESSED_BLOCK_BYTES: number;
|
|
5
|
+
export declare const REPLAY_MAX_DURATION_MS: number;
|
|
6
|
+
export declare const REPLAY_MAX_COMPRESSED_BYTES: number;
|
|
7
|
+
export declare const REPLAY_SAMPLE_KEY_PREFIX = "drip_rp:";
|
|
8
|
+
export declare const REPLAY_PROGRESS_KEY_PREFIX = "drip_replay_progress:";
|
|
9
|
+
export declare const REPLAY_EXCLUDED_CHECKOUT_PATHS: readonly ["/checkout", "/checkouts/", "/cart/checkout"];
|
|
10
|
+
export type ReplayAssignment = {
|
|
11
|
+
experiment_id: string;
|
|
12
|
+
variation_id: string;
|
|
13
|
+
};
|
|
14
|
+
type ReplayEvent = {
|
|
15
|
+
type?: number;
|
|
16
|
+
timestamp?: number;
|
|
17
|
+
data?: Record<string, unknown>;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
export type ReplayRecorderEmission = {
|
|
21
|
+
event?: ReplayEvent;
|
|
22
|
+
};
|
|
23
|
+
export type ReplayRecorderApi = {
|
|
24
|
+
start: (options: {
|
|
25
|
+
emit: (emission: ReplayRecorderEmission) => void;
|
|
26
|
+
signalState?: ReplaySignals;
|
|
27
|
+
}) => () => void;
|
|
28
|
+
compress: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
29
|
+
compressSync: (bytes: Uint8Array) => Uint8Array;
|
|
30
|
+
takeSignals: () => ReplaySignals;
|
|
31
|
+
version: string;
|
|
32
|
+
};
|
|
33
|
+
type ReplayClickSignal = {
|
|
34
|
+
ts: number;
|
|
35
|
+
selector: string;
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
mut_ms?: number;
|
|
39
|
+
};
|
|
40
|
+
export type ReplaySignals = {
|
|
41
|
+
clicks: ReplayClickSignal[];
|
|
42
|
+
nav: Array<{
|
|
43
|
+
ts: number;
|
|
44
|
+
url: string;
|
|
45
|
+
}>;
|
|
46
|
+
errors: Array<{
|
|
47
|
+
ts: number;
|
|
48
|
+
message: string;
|
|
49
|
+
}>;
|
|
50
|
+
form_focus: Array<{
|
|
51
|
+
ts: number;
|
|
52
|
+
selector: string;
|
|
53
|
+
}>;
|
|
54
|
+
form_submit: Array<{
|
|
55
|
+
ts: number;
|
|
56
|
+
selector: string;
|
|
57
|
+
}>;
|
|
58
|
+
scroll_max_pct: number;
|
|
59
|
+
};
|
|
60
|
+
export type ReplayEnvelope = {
|
|
61
|
+
contract: 1;
|
|
62
|
+
shop_id: string;
|
|
63
|
+
visitor_id: string;
|
|
64
|
+
session_id: string;
|
|
65
|
+
seq: number;
|
|
66
|
+
first_ts: number;
|
|
67
|
+
last_ts: number;
|
|
68
|
+
event_count: number;
|
|
69
|
+
url: string;
|
|
70
|
+
environment: string;
|
|
71
|
+
qa_mode: 0 | 1;
|
|
72
|
+
qa_session_id?: string;
|
|
73
|
+
sdk_version: string;
|
|
74
|
+
assignments: ReplayAssignment[];
|
|
75
|
+
codec: "deflate";
|
|
76
|
+
payload_b64: string;
|
|
77
|
+
signals: ReplaySignals;
|
|
78
|
+
};
|
|
79
|
+
export type ReplayController = {
|
|
80
|
+
stop: (discard?: boolean) => void;
|
|
81
|
+
isStopped: () => boolean;
|
|
82
|
+
update: (assignments: Assignment[], experiments: Experiment[]) => void;
|
|
83
|
+
};
|
|
84
|
+
type ReplayControllerOptions = {
|
|
85
|
+
assignments: Assignment[];
|
|
86
|
+
experiments: Experiment[];
|
|
87
|
+
recorderUrl: string;
|
|
88
|
+
endpoint: string;
|
|
89
|
+
shopId: string;
|
|
90
|
+
visitorId: string;
|
|
91
|
+
sessionId: string;
|
|
92
|
+
environment: string;
|
|
93
|
+
qaMode: boolean;
|
|
94
|
+
qaSessionId?: string;
|
|
95
|
+
sdkVersion: string;
|
|
96
|
+
ingestSignature?: string;
|
|
97
|
+
isTrackingBlocked: () => boolean;
|
|
98
|
+
loadRecorder?: (url: string) => Promise<ReplayRecorderApi>;
|
|
99
|
+
};
|
|
100
|
+
export declare function normalizeReplaySampleRate(value: unknown): number;
|
|
101
|
+
export declare function resolveReplayAssignments(assignments: Assignment[], experiments: Experiment[]): ReplayAssignment[];
|
|
102
|
+
export declare function isReplayCheckoutPath(pathname: string): boolean;
|
|
103
|
+
export declare function resolveReplayRecorderUrl(input: {
|
|
104
|
+
configuredUrl?: string;
|
|
105
|
+
scriptSrc?: string;
|
|
106
|
+
pageUrl?: string;
|
|
107
|
+
}): string | null;
|
|
108
|
+
export declare function loadReplayRecorder(recorderUrl: string, documentLike?: Document): Promise<ReplayRecorderApi>;
|
|
109
|
+
export declare function startReplayCapture(options: ReplayControllerOptions): Promise<ReplayController | null>;
|
|
110
|
+
export {};
|
package/dist/types/router.d.ts
CHANGED
|
@@ -2,8 +2,18 @@ import { RouterMode } from "./types";
|
|
|
2
2
|
export type RouteChangeEvent = {
|
|
3
3
|
previousUrl: string;
|
|
4
4
|
nextUrl: string;
|
|
5
|
-
reason: "pushState" | "replaceState" | "popstate" | "hashchange" | "navigation";
|
|
5
|
+
reason: "pushState" | "replaceState" | "popstate" | "hashchange" | "navigation" | "polling";
|
|
6
6
|
};
|
|
7
7
|
type RouteObserver = (event: RouteChangeEvent) => void;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function notifyIfChanged(lastUrlRef: {
|
|
9
|
+
value: string;
|
|
10
|
+
}, reason: RouteChangeEvent["reason"], observer: RouteObserver, onObserverError?: (error: unknown) => void): void;
|
|
11
|
+
export declare const PAGE_URL_POLL_INTERVAL_MS = 250;
|
|
12
|
+
export declare function observePollingChanges(observer: RouteObserver, intervalMs?: number, lastUrlRef?: {
|
|
13
|
+
value: string;
|
|
14
|
+
}, onObserverError?: (error: unknown) => void): () => void;
|
|
15
|
+
export declare function observeRouteChanges(mode: RouterMode, observer: RouteObserver, options?: {
|
|
16
|
+
pollingIntervalMs?: number;
|
|
17
|
+
onObserverError?: (error: unknown) => void;
|
|
18
|
+
}): () => void;
|
|
9
19
|
export {};
|