@drip-apex/sdk 0.1.0 → 0.2.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 +19262 -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 +19246 -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 +16621 -13539
- 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 +27 -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 +2070 -0
- package/src/consent-evaluation-cookiescript.test.ts +50 -0
- package/src/consent-evaluation.ts +138 -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,166 @@
|
|
|
1
|
+
import { type StorefrontVitalsContext } from "./storefront-vitals";
|
|
2
|
+
import { type ReplayController } from "./replay";
|
|
3
|
+
import type { PerfFlagState } from "./runtime";
|
|
4
|
+
import { Tracker } from "./track";
|
|
5
|
+
import { ActivationMode, Assignment, ActivationDiagnostics, InitConfig, PageTargetingRule, PageActivationDiagnostic, PageDeactivationMode, PageTriggerMode, PlatformHint, RouterMode, TrackEvent, TrackingStart } from "./types";
|
|
6
|
+
import type { HeatmapController, SemanticController, UrlDiffNeeds, PendingPerfEvent, ConfigSource, ResolvedRuntimeConfig, RouteDiagnostic, DataLayerDiagnostic, ShopifySyncDiagnostic, ShopifyAssignmentSyncDiagnostic, ExposureDestinationDiagnostic, PageRuleReconcileScope, RuntimeLoadDiagnostic, PageDetectorMode } from "./config-runtime";
|
|
7
|
+
export type OrderIdentityPlatform = "shopify" | "shopware" | "woocommerce" | "centra" | "custom";
|
|
8
|
+
export type SDKState = {
|
|
9
|
+
config: InitConfig | null;
|
|
10
|
+
userId: string | null;
|
|
11
|
+
tracker: Tracker | null;
|
|
12
|
+
assignments: Assignment[];
|
|
13
|
+
pageActivation: Map<string, PageActivationRuntimeState>;
|
|
14
|
+
stopObserver: (() => void) | null;
|
|
15
|
+
stopDomObserver: (() => void) | null;
|
|
16
|
+
stopHandover: (() => void) | null;
|
|
17
|
+
heatmapController: HeatmapController | null;
|
|
18
|
+
replayController: ReplayController | null;
|
|
19
|
+
replayStartPromise: Promise<void> | null;
|
|
20
|
+
replayGeneration: number;
|
|
21
|
+
semanticController: SemanticController | null;
|
|
22
|
+
forceMap: Record<string, string> | null;
|
|
23
|
+
forcedUnavailable: Array<{
|
|
24
|
+
experimentId: string;
|
|
25
|
+
reason: "archived" | "runtime_disabled" | "not_found" | "environment_mismatch" | "not_in_config";
|
|
26
|
+
}>;
|
|
27
|
+
edgeDeviceAudienceUnsupported: Array<{
|
|
28
|
+
experimentId: string;
|
|
29
|
+
audienceName: string;
|
|
30
|
+
}>;
|
|
31
|
+
analyticsStarted: boolean;
|
|
32
|
+
trackingStart: TrackingStart;
|
|
33
|
+
trackingIdleTimeoutMs: number;
|
|
34
|
+
consentRequired: boolean;
|
|
35
|
+
consentGranted: boolean;
|
|
36
|
+
consentModeEnabled: boolean;
|
|
37
|
+
trackingPrerequisiteMet: boolean;
|
|
38
|
+
variationPrerequisiteMet: boolean;
|
|
39
|
+
activationDiagnostics: ActivationDiagnostics;
|
|
40
|
+
trackingDisabledByDnt: boolean;
|
|
41
|
+
holdout: boolean;
|
|
42
|
+
analyticsTimeoutId: number | null;
|
|
43
|
+
analyticsIdleId: number | null;
|
|
44
|
+
qaMode: boolean;
|
|
45
|
+
qaSessionId: string;
|
|
46
|
+
screenshotMode: boolean;
|
|
47
|
+
platform: PlatformHint;
|
|
48
|
+
routerMode: RouterMode;
|
|
49
|
+
activationMode: ActivationMode;
|
|
50
|
+
perfFlags: PerfFlagState;
|
|
51
|
+
urlDiffNeeds: UrlDiffNeeds;
|
|
52
|
+
lastUrl: string;
|
|
53
|
+
lastAssignmentSignature: string;
|
|
54
|
+
wiredGoalKeys: Set<string>;
|
|
55
|
+
wiredGoalUrl: string | null;
|
|
56
|
+
pendingPerf: PendingPerfEvent | null;
|
|
57
|
+
configSource: ConfigSource;
|
|
58
|
+
runtimeConfig: ResolvedRuntimeConfig | null;
|
|
59
|
+
pageTriggerMode: PageTriggerMode;
|
|
60
|
+
stopSignalCaptures: (() => void) | null;
|
|
61
|
+
stopSurfaceSignals: (() => void) | null;
|
|
62
|
+
stopJsTriggerSignals: (() => void) | null;
|
|
63
|
+
stopDataLayerTriggers: (() => void) | null;
|
|
64
|
+
stopConsentListeners: (() => void) | null;
|
|
65
|
+
stopShopifyCartMutationSync: (() => void) | null;
|
|
66
|
+
lastRouteChange: RouteDiagnostic | null;
|
|
67
|
+
lastDataLayerTrigger: DataLayerDiagnostic | null;
|
|
68
|
+
observerErrors: {
|
|
69
|
+
count: number;
|
|
70
|
+
last?: {
|
|
71
|
+
source: "route" | "data_layer" | "dom";
|
|
72
|
+
message: string;
|
|
73
|
+
at: number;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
deferredRouteReevaluationTimer: number | null;
|
|
77
|
+
lastShopifyAssignmentSync: ShopifyAssignmentSyncDiagnostic | null;
|
|
78
|
+
lastShopifyCartSync: ShopifySyncDiagnostic | null;
|
|
79
|
+
shopifyCartToken: string | null;
|
|
80
|
+
shopwareAttributionEnvelope: string | null;
|
|
81
|
+
exposureDestinationDiagnostics: ExposureDestinationDiagnostic[];
|
|
82
|
+
exposedAssignmentKeys: Set<string>;
|
|
83
|
+
mutationPendingAssignmentKeys: Set<string>;
|
|
84
|
+
contaminatedAssignmentKeys: Set<string>;
|
|
85
|
+
authorizedPriceAssignmentKeys: Set<string> | null;
|
|
86
|
+
authorizedShippingAssignmentKeys: Set<string> | null;
|
|
87
|
+
authorizedOffersAssignmentKeys: Set<string> | null;
|
|
88
|
+
initializingAssignments: boolean;
|
|
89
|
+
pendingInitialApply: Promise<void> | null;
|
|
90
|
+
queuedRecheck: {
|
|
91
|
+
reason: "url" | "dom" | "manual" | "prerequisite";
|
|
92
|
+
forceReapply: boolean;
|
|
93
|
+
pageRuleScope?: PageRuleReconcileScope;
|
|
94
|
+
} | null;
|
|
95
|
+
redirectNavigationPending: boolean;
|
|
96
|
+
routeAnalyticsGeneration: number;
|
|
97
|
+
/** Re-entrancy guard and unwind-drain flag for `reevaluateAssignments`. */
|
|
98
|
+
reconcileInProgress: boolean;
|
|
99
|
+
reconcilePending: boolean;
|
|
100
|
+
pendingDeliveryHealth: TrackEvent[];
|
|
101
|
+
load: RuntimeLoadDiagnostic;
|
|
102
|
+
orderIdentityInFlight: Set<string>;
|
|
103
|
+
orderIdentityDetectionUrl: string;
|
|
104
|
+
orderIdentityDetection: {
|
|
105
|
+
platform: OrderIdentityPlatform;
|
|
106
|
+
platformOrderId: string | null;
|
|
107
|
+
orderNumber: string | null;
|
|
108
|
+
} | null | undefined;
|
|
109
|
+
carryImportedAssignmentKeys: Set<string>;
|
|
110
|
+
};
|
|
111
|
+
export type QaAssistantRuntimeSnapshot = {
|
|
112
|
+
config: InitConfig | null;
|
|
113
|
+
assignments: Assignment[];
|
|
114
|
+
activationDiagnostics: ActivationDiagnostics;
|
|
115
|
+
pageActivation: PageActivationDiagnostic[];
|
|
116
|
+
goalScopeUrl: string | null;
|
|
117
|
+
forceMap: Record<string, string> | null;
|
|
118
|
+
forcedUnavailable: Array<{
|
|
119
|
+
experimentId: string;
|
|
120
|
+
reason: "archived" | "runtime_disabled" | "not_found" | "environment_mismatch" | "not_in_config";
|
|
121
|
+
}>;
|
|
122
|
+
edgeDeviceAudienceUnsupported: Array<{
|
|
123
|
+
experimentId: string;
|
|
124
|
+
audienceName: string;
|
|
125
|
+
}>;
|
|
126
|
+
platform: PlatformHint;
|
|
127
|
+
qaMode: boolean;
|
|
128
|
+
orderIdentity: {
|
|
129
|
+
platform: OrderIdentityPlatform;
|
|
130
|
+
platformOrderId: string | null;
|
|
131
|
+
orderNumber: string | null;
|
|
132
|
+
} | null;
|
|
133
|
+
};
|
|
134
|
+
export type PageActivationRuntimeState = {
|
|
135
|
+
active: boolean;
|
|
136
|
+
appliedKeys: Set<string>;
|
|
137
|
+
/** Goal-scope state only; never participates in render transitions. */
|
|
138
|
+
scopeOnly?: boolean;
|
|
139
|
+
configuredMode?: PageDeactivationMode;
|
|
140
|
+
lastTransitionMode?: PageDeactivationMode;
|
|
141
|
+
isolationFallback?: "whole_experiment";
|
|
142
|
+
isolationFallbackExperimentId?: string;
|
|
143
|
+
triggerDetector?: PageDetectorMode;
|
|
144
|
+
triggerPollAttempts?: number;
|
|
145
|
+
triggerOutcome?: "activated" | "condition_failed" | "window_expired";
|
|
146
|
+
triggerElapsedMs?: number;
|
|
147
|
+
};
|
|
148
|
+
export type PageRulePollController = {
|
|
149
|
+
intervalId: number;
|
|
150
|
+
startedAt: number;
|
|
151
|
+
};
|
|
152
|
+
export declare const runtimeSharedState: {
|
|
153
|
+
runtimeBootedTooLateForAntiFlicker: boolean | null;
|
|
154
|
+
stopEarlyReassert: (() => void) | null;
|
|
155
|
+
earlyReassertTeardownTimer: ReturnType<typeof setTimeout> | null;
|
|
156
|
+
storefrontVitalsContext: StorefrontVitalsContext | null;
|
|
157
|
+
initialPredecidedByExperiment: Map<string, string> | null;
|
|
158
|
+
shopifyCartSyncGeneration: number;
|
|
159
|
+
pageDetectorRules: Map<PageDetectorMode, PageTargetingRule[]>;
|
|
160
|
+
pageDetectorLastUrls: Map<string, string>;
|
|
161
|
+
pageRulePollControllers: Map<string, PageRulePollController>;
|
|
162
|
+
qaAssistantRuntimeListeners: Set<() => void>;
|
|
163
|
+
clearingQaForceFromRoute: boolean;
|
|
164
|
+
attributionLedger: Map<string, Assignment>;
|
|
165
|
+
};
|
|
166
|
+
export declare const state: SDKState;
|
package/dist/types/sanitize.d.ts
CHANGED
|
@@ -3,9 +3,14 @@ export type CartAssignment = {
|
|
|
3
3
|
variationId: string;
|
|
4
4
|
assignmentEpoch?: number;
|
|
5
5
|
commercePriceOnly?: boolean;
|
|
6
|
+
pageActive?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export type CartAttributeSyncInput = {
|
|
8
9
|
assignments: CartAssignment[];
|
|
10
|
+
/** Allows an explicit empty control stamp to clear prior treatment attributes. */
|
|
11
|
+
controlStamp?: boolean;
|
|
12
|
+
/** Writes only storefront identity without disturbing existing treatment attributes. */
|
|
13
|
+
identityOnly?: boolean;
|
|
9
14
|
requiredAssignments?: CartAssignment[];
|
|
10
15
|
visitorId: string;
|
|
11
16
|
sessionId: string;
|
|
@@ -14,6 +19,8 @@ export type CartAttributeSyncInput = {
|
|
|
14
19
|
ingestSignature?: string;
|
|
15
20
|
url?: string;
|
|
16
21
|
environment?: string;
|
|
22
|
+
platform?: string;
|
|
23
|
+
onAttributionEnvelope?: (envelope: string) => void;
|
|
17
24
|
cartToken?: string;
|
|
18
25
|
offersAuthorizationRevision?: number;
|
|
19
26
|
offersExperimentIds?: string[];
|
|
@@ -30,6 +37,8 @@ export type CartAttributeSyncInput = {
|
|
|
30
37
|
authorizePriceDisplayAssignments?: (assignments: CartAssignment[]) => void;
|
|
31
38
|
authorizeShippingDisplayAssignments?: (assignments: CartAssignment[]) => void;
|
|
32
39
|
authorizeOffersDisplayAssignments?: (assignments: CartAssignment[]) => void;
|
|
40
|
+
/** Receives the normalized Shopify cart token already observed by this sync. */
|
|
41
|
+
onCartToken?: (cartToken: string) => void;
|
|
33
42
|
/** Receives the parsed /cart/update.js response body after a successful stamp write. */
|
|
34
43
|
onCartSnapshot?: (cart: unknown) => void;
|
|
35
44
|
exclusionGroupSelections?: Array<{
|
|
@@ -42,6 +51,18 @@ export type CartAttributeEntry = {
|
|
|
42
51
|
key: string;
|
|
43
52
|
value: string;
|
|
44
53
|
};
|
|
54
|
+
export type CartMetafieldInput = {
|
|
55
|
+
key: string;
|
|
56
|
+
type: string;
|
|
57
|
+
value: string;
|
|
58
|
+
};
|
|
59
|
+
export type CartMetafieldKeyInput = Pick<CartMetafieldInput, "key">;
|
|
60
|
+
/** Every Shopify cart attribute key owned and replaced by Apex. */
|
|
61
|
+
export declare const APEX_CART_ATTRIBUTE_KEYS: ReadonlySet<string>;
|
|
62
|
+
/** Normalize Shopify metafield namespaces accepted by the Apex cart mirror. */
|
|
63
|
+
export declare function normalizeCartMetafieldNamespace(namespace?: string): string;
|
|
64
|
+
/** Return every Apex cart-metafield key missing from the supplied mirror. */
|
|
65
|
+
export declare function getCartMetafieldStaleKeys(currentMetafields: readonly CartMetafieldKeyInput[], namespace?: string): string[];
|
|
45
66
|
export type CartAttributeSyncResult = {
|
|
46
67
|
status: "sent" | "skipped" | "failed";
|
|
47
68
|
reason?: string;
|
|
@@ -50,7 +71,7 @@ export type CartAttributeSyncOptions = {
|
|
|
50
71
|
/** Re-write after a real cart mutation even if this assignment was stamped earlier. */
|
|
51
72
|
force?: boolean;
|
|
52
73
|
};
|
|
53
|
-
/** Prevent an obsolete authorization response from reaching the cart
|
|
74
|
+
/** Prevent an obsolete authorization response or pending request from reaching the cart. */
|
|
54
75
|
export declare function invalidateShopifyCartAttributeSync(): void;
|
|
55
76
|
export declare function cannotRequestRequiredCommerceAuthorization(input: CartAttributeSyncInput): boolean;
|
|
56
77
|
export declare function isShopifyStorefront(): boolean;
|
|
@@ -58,5 +79,8 @@ export declare function isShopifyStorefront(): boolean;
|
|
|
58
79
|
export declare function shopifyRoutesRoot(): string;
|
|
59
80
|
export declare function shopifyCartPath(): string;
|
|
60
81
|
export declare function syncShopifyCartAttributes(input: CartAttributeSyncInput, options?: CartAttributeSyncOptions): Promise<CartAttributeSyncResult>;
|
|
82
|
+
export declare function mintShopwareAttributionEnvelope(input: CartAttributeSyncInput): Promise<void>;
|
|
61
83
|
export declare function buildSignedCartAttributeEntries(input: CartAttributeSyncInput): Promise<CartAttributeEntry[]>;
|
|
62
84
|
export declare function buildCartAttributeEntries(input: CartAttributeSyncInput, commerceAuthorization?: string | null): CartAttributeEntry[];
|
|
85
|
+
/** Build a Storefront API cart-metafield mirror of the canonical attribution stamp. */
|
|
86
|
+
export declare function buildCartMetafieldInputs(input: CartAttributeSyncInput, namespace?: string): CartMetafieldInput[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type StorefrontVitalsContext = {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
proxyEventDelivery?: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
path?: string;
|
|
6
|
+
};
|
|
7
|
+
shopId: string;
|
|
8
|
+
ingestShopId?: string;
|
|
9
|
+
ingestSignature?: string;
|
|
10
|
+
visitorId?: string;
|
|
11
|
+
sampleRate?: number;
|
|
12
|
+
experimentActive: boolean;
|
|
13
|
+
sdkBootToInitMs?: number;
|
|
14
|
+
getAntiFlickerInsertedToRevealMs?: () => number | undefined;
|
|
15
|
+
sdkInitStartToAssignmentReadyMs?: number;
|
|
16
|
+
};
|
|
17
|
+
export type VitalRating = "good" | "needs-improvement" | "poor";
|
|
18
|
+
declare const RATING_THRESHOLDS: Record<string, [number, number]>;
|
|
19
|
+
export declare function rateVital(metric: keyof typeof RATING_THRESHOLDS, value: number | undefined): VitalRating | undefined;
|
|
20
|
+
/** Starts one dependency-free, observer-only storefront vitals sample. */
|
|
21
|
+
export declare function startStorefrontVitals(context: StorefrontVitalsContext, random?: () => number): void;
|
|
22
|
+
export declare function stopStorefrontVitals(): void;
|
|
23
|
+
export declare function resetStorefrontVitalsForTest(): void;
|
|
24
|
+
export {};
|
|
@@ -2,4 +2,5 @@ import type { Targeting, TargetingDiagnostics } from "./types";
|
|
|
2
2
|
export declare function evaluateTargetingGatesWithConditionDiagnostics(targeting: Targeting | undefined, ctx: {
|
|
3
3
|
url: string;
|
|
4
4
|
attributes: Record<string, unknown>;
|
|
5
|
+
hostAgnosticIncludeOrigin?: string | string[];
|
|
5
6
|
}): TargetingDiagnostics;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AttributeRule, ActivationGateDiagnostic, Experiment, PageTargetingRule, SegmentCondition, Targeting, TargetingDiagnostics, UrlRule } from "./types";
|
|
2
|
-
|
|
2
|
+
import { evaluateUrlRule } from "@drip/event-schema/targeting-core";
|
|
3
|
+
export declare const evalUrlRule: typeof evaluateUrlRule;
|
|
3
4
|
export declare function normalizeRuntimeUrlRules(targeting: Targeting | undefined): UrlRule[];
|
|
4
|
-
export declare function matchUrlRules(url: string, rules: UrlRule[]): boolean;
|
|
5
|
+
export declare function matchUrlRules(url: string, rules: UrlRule[], hostAgnosticIncludeOrigin?: string | string[]): boolean;
|
|
6
|
+
export declare function evalUrlRuleForIncludeOrigin(url: string, rule: UrlRule, origins?: string | string[]): boolean;
|
|
5
7
|
type BooleanDiagnosticResult = {
|
|
6
8
|
matched: boolean;
|
|
7
9
|
reason?: string;
|
|
@@ -14,7 +16,16 @@ export declare function evaluatePageAdvancedConditionResult(rule: PageTargetingR
|
|
|
14
16
|
export declare function pageManualTriggerMatches(rule: PageTargetingRule, ctx: {
|
|
15
17
|
attributes: Record<string, unknown>;
|
|
16
18
|
}): boolean;
|
|
19
|
+
export declare function matchPageTargetingRule(rule: PageTargetingRule, ctx: {
|
|
20
|
+
url: string;
|
|
21
|
+
attributes: Record<string, unknown>;
|
|
22
|
+
}): boolean;
|
|
23
|
+
export declare function matchedPageRuleIds(rules: PageTargetingRule[], ctx: {
|
|
24
|
+
url: string;
|
|
25
|
+
attributes: Record<string, unknown>;
|
|
26
|
+
}): Set<string>;
|
|
17
27
|
export declare function matchAttributeRule(attrs: Record<string, unknown>, rule: AttributeRule): boolean;
|
|
28
|
+
export declare function readShopifySignal(signal: string): unknown;
|
|
18
29
|
export declare function buildTargetingAttributes(baseAttributes?: Record<string, unknown>, currentUrl?: string, options?: {
|
|
19
30
|
persistSignals?: boolean;
|
|
20
31
|
}): Record<string, unknown>;
|
|
@@ -34,15 +45,18 @@ export declare function matchSegmentConditionValues(condition: SegmentCondition,
|
|
|
34
45
|
export declare function matchesTargeting(targeting: Targeting | undefined, ctx: {
|
|
35
46
|
url: string;
|
|
36
47
|
attributes: Record<string, unknown>;
|
|
48
|
+
hostAgnosticIncludeOrigin?: string | string[];
|
|
37
49
|
}): boolean;
|
|
38
50
|
export declare function targetingHasJsTriggers(experiments: Experiment[]): boolean;
|
|
39
51
|
export declare function evaluateTargetingGatesDetailed(targeting: Targeting | undefined, ctx: {
|
|
40
52
|
url: string;
|
|
41
53
|
attributes: Record<string, unknown>;
|
|
54
|
+
hostAgnosticIncludeOrigin?: string | string[];
|
|
42
55
|
}): TargetingDiagnostics;
|
|
43
56
|
export declare function evaluateTargetingGates(targeting: Targeting | undefined, ctx: {
|
|
44
57
|
url: string;
|
|
45
58
|
attributes: Record<string, unknown>;
|
|
59
|
+
hostAgnosticIncludeOrigin?: string | string[];
|
|
46
60
|
}): {
|
|
47
61
|
matched: boolean;
|
|
48
62
|
gates: ActivationGateDiagnostic[];
|
package/dist/types/track.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { TrackEvent } from "./types";
|
|
2
2
|
type TrackerOptions = {
|
|
3
3
|
endpoint: string;
|
|
4
|
+
proxyEventDelivery?: {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
path?: string;
|
|
7
|
+
};
|
|
8
|
+
assetFallback?: boolean;
|
|
4
9
|
shopId?: string;
|
|
5
10
|
ingestShopId?: string;
|
|
6
11
|
ingestSignature?: string;
|
|
@@ -20,9 +25,16 @@ type TrackerOptions = {
|
|
|
20
25
|
qaSessionId?: string;
|
|
21
26
|
/** Active Apex environment stamped onto every outgoing event. */
|
|
22
27
|
environment?: string;
|
|
28
|
+
/** Global cohort stamped on every event while program holdout is enabled. */
|
|
29
|
+
cohort?: "holdout" | "active";
|
|
30
|
+
/** Reporting epoch of the configuration that produced the global cohort. */
|
|
31
|
+
holdoutConfigEpoch?: number;
|
|
23
32
|
};
|
|
33
|
+
export declare function getOrCreateSessionId(): string;
|
|
34
|
+
export declare function createEventId(): string;
|
|
24
35
|
export declare class Tracker {
|
|
25
36
|
private endpoint;
|
|
37
|
+
private proxyEndpoint;
|
|
26
38
|
private shopId;
|
|
27
39
|
private ingestShopId;
|
|
28
40
|
private ingestSignature;
|
|
@@ -44,6 +56,9 @@ export declare class Tracker {
|
|
|
44
56
|
private qaMode;
|
|
45
57
|
private qaSessionId;
|
|
46
58
|
private environment;
|
|
59
|
+
private cohort;
|
|
60
|
+
private holdoutConfigEpoch;
|
|
61
|
+
private assetFallback;
|
|
47
62
|
private pagehideHandler;
|
|
48
63
|
private beforeUnloadHandler;
|
|
49
64
|
private pageshowHandler;
|
|
@@ -52,7 +67,6 @@ export declare class Tracker {
|
|
|
52
67
|
private pageLifecycleFlushed;
|
|
53
68
|
private pageTeardownStarted;
|
|
54
69
|
constructor(options: TrackerOptions);
|
|
55
|
-
private getOrCreateSessionId;
|
|
56
70
|
/** Public accessor for the session ID (used by the Shopify pixel bridge). */
|
|
57
71
|
getSessionId(): string;
|
|
58
72
|
start(): void;
|