Developer

`init()` and InitConfig reference

Reference every supported Apex SDK InitConfig field with its type, default, and intended use.

Call init(config) once per page load or app shell. The SDK accepts inline experiments through experiments, or it fetches running experiments when both shopId and endpoint are present.

ts
import { init } from "@drip-apex/sdk";
 
const assignments = init({
  shopId: "demo-shop",
  endpoint: "https://events.drip-apex.com",
  antiFlickerMode: "scoped",
  trackingStart: "idle"
});

init() returns the assignments available immediately. When the SDK fetches config asynchronously, the first return value can be an empty array; read later assignments with getAssignments() or listen for the drip_initialized browser event.

Core fields

FieldTypeDefaultWhen to use
experimentsExperiment[]Not setProvide inline, code-owned experiments instead of fetching by shopId. An empty array is valid and still initializes analytics.
signalsRuntimeSignalDefinition[][]Define custom runtime signals that targeting can capture from URLs, DOM, globals, data layer events, or SDK events.
shopIdstringNot setFetch published config from the Worker and attribute events to an Apex shop. Required for hosted config fetches.
endpointstringNot setBase Worker URL for /config, /events, handover minting, and order identity calls. A trailing /events is normalized away.
auditEndpointstringApex production audit endpointOverride signed storefront audit snapshots when using the audit build. Most installs leave this unset.
editorBundleUrlstringDerived from the installed SDK scriptVersioned URL for the lazy on-site editor bundle. Apex-hosted snippets provide this automatically; custom delivery setups can point it at their matching editor.js asset.
ingestShopIdstringshopIdSend a different shop identifier in event ingestion headers when Worker-delivered config needs a separate ingest identity.
ingestSignaturestringNot setSign event ingestion, handover minting, and order identity requests when the Worker provides a signature. Do not hardcode secrets in page code.
attributesRecord<string, unknown>&#123;&#125;Add targeting attributes for this page or visitor, merged with runtime signal-derived attributes.
userIdstringGenerated visitor IDOverride the visitor/bucketing identity, for example with a stable logged-in user identifier.
urlstringlocation.hrefEvaluate targeting against a supplied URL instead of the current browser location. Useful for tests and controlled rendering.
autoTrackbooleantrueSet to false when you do not want automatic assignment exposure events. Manual event calls still work when tracking is available.
configCachebooleantrueSet to false to disable localStorage config cache for fetched shop config. Cache is also disabled when storage is blocked.
configCacheTtlMsnumber300000Change the freshness window for cached fetched config. Values must be positive numbers.
lateConfigPolicy"skip" or "apply""skip"Choose whether fetched config that arrives after the anti-flicker reveal deadline should still apply. QA and screenshot forcing uses "apply".
onExperimentViewed(assignment: Assignment) => voidNot setRun a callback for each viewed assignment after the SDK has assigned and started exposure tracking.

Runtime modes

FieldTypeDefaultWhen to use
executionMode"auto", "edge", or "client""auto"Keep "auto" for edge-first delivery with client fallback. Use "edge" only when an edge runtime has already initialized the page.
platformHint"auto", "shopify", "spa", or "shopware"Auto-detectedHint platform-specific router and surface behavior when auto-detection cannot identify the storefront.
routerMode"auto", "history", "navigation", or "none""auto"Top-level SPA route observation mode. spa.routerMode takes priority when present.
activationMode"auto", "observer", or "manual""observer"Top-level mutation activation mode. spa.activationMode takes priority when present.
antiFlickerMode"scoped", "full", "custom", or "off""scoped"Control how Apex hides content before variants apply. Use custom with antiFlickerCustomCss.
antiFlickerTimeoutMsnumber1200Auto-reveal timeout for anti-flicker protection. Non-positive or invalid values fall back to 1200.
antiFlickerCustomCssstringNot setCSS injected only when antiFlickerMode is "custom".
trackingStart"idle" or "immediate""idle"Decide whether analytics setup waits for idle time or starts immediately after initialization.
trackingIdleTimeoutMsnumber2000Fallback timeout for trackingStart: "idle". Non-positive or invalid values fall back to 2000.
customJsPolicy"strict", "hybrid", or "flex""hybrid"Control variation and project custom JavaScript execution. Use "strict" to block custom JS in production-sensitive installs.
requireConsentbooleanfalseGate tracking and persistent storage until consent is granted. Variants can still render under strict consent mode.
hasConsentbooleanConsent cookie or provider stateSeed the initial consent state when using requireConsent or custom consent controls.
deferTrackingbooleanDeprecated aliasDeprecated. true maps to trackingStart: "idle" and false maps to "immediate".
antiFlickerbooleanDeprecated aliasDeprecated. true maps to antiFlickerMode: "full" and false maps to "off".
antiFlickerTimeoutnumberDeprecated aliasDeprecated. Maps to antiFlickerTimeoutMs.

Settings objects

FieldTypeDefaultWhen to use
profileConfigProfileNot setServer-provided profile metadata. The SDK currently reads profile.platform after platformHint.
projectPrerequisitesProjectPrerequisitesNo prerequisite rulesGate variation display and tracking with project-level showVariationsRule and startTrackingRule expressions.
consentModeConsentModeSettingsDisabledConfigure provider-backed consent detection for custom, OneTrust, Usercentrics, Cookiebot, or CCM19.
debugDebugSettingsDisabledEnable restricted SDK console diagnostics by query parameter, user ID, always-on mode, or active server state.
spaSpaSettingsAuto router, observer activationConfigure SPA router observation, DOM re-evaluation, debounce timing, iframe allowance, and reinit-only mode.
pageTriggerPageTriggerSettings&#123; defaultMode: "direct" &#125;Switch initial activation and route behavior to URL change, DOM change, or manual page triggers.
externalTrackingExternalTrackingSettingsDisabledPreserve bucketing across external checkout, booking, or lead-flow domains by rewriting configured links and forms.
dataLayerTriggersDataLayerTriggerSettings[][]Listen to data layer events, map event fields into runtime signals, re-evaluate assignments, and optionally track pageviews or revenue.
exposureDestinationsExposureDestinationsSettingsDisabledSend assignment exposure metadata to dataLayer, Hotjar, or custom queue globals.
projectCodeProjectCodeSettingsDisabledApply advanced project-level CSS, helper JS, or startup JS before or after assignments.
environmentsRuntimeEnvironmentSettingsProductionSelect an environment key for fetched config and config-cache isolation.
bucketingCleanupBucketingCleanupSettingsEnabled with 180 day retentionClean stale Apex goal and config-cache storage. Set enabled: false to opt out.
dataProtectionDataProtectionSettingslocalStorage, no encoding, DNT offChoose visitor storage mode, encoded storage values, Do Not Track behavior, and cookie domain.
semanticTrackingSemanticTrackingSettingsDisabledCapture sampled semantic visibility or click events for configured selectors.
runtimeControlRuntimeControlSettingsEnabled runtimeServer-authoritative kill-switch state. When disabled is true, runtime diagnostics show the disabled state.
deliveryState"no_visual_tests", "non_critical_visual", "critical_visual", "edge_managed", or stringNot setWorker/snippet metadata included in SDK performance telemetry.
scriptCacheSource"edge", "kv", "origin", "precompile", "precompiled", or stringNot setWorker/cache source label included in SDK performance telemetry.
installSurface"direct_script", "shopify_app_embed", "legacy_shopify_redirect", or stringNot setInstall surface label included in SDK performance telemetry.
sdkVersionstringNot setWorker-provided immutable SDK artifact version for release-attributed performance telemetry.
sdkDeliveryMode"global", "pinned", "canary", or stringNot setWorker-provided SDK policy mode for release-attributed performance telemetry.
sdkDeliverySource"embedded", "external", or stringNot setWorker-provided artifact source for distinguishing embedded and immutable external delivery.
sdkPolicyRevisionstringNot setWorker-provided global SDK delivery policy revision used to compile the snippet.
runtimeProfile"full", "empty_project", "nonvisual_assignment", or string"full"Server-authoritative runtime profile included in performance telemetry. Unknown profiles retain full behavior.
deliverySnippetDeliveryManifestNot setWorker-compiled delivery manifest for precompiled critical mutation delivery. Most hand-written installs omit it.
runtimeFeaturesRuntime feature profile objectNot setWorker-selected feature profile for live, heatmap, debug, QA, harness, or audit builds.
perfFlagsPerfFeatureFlagsAll current perf flags enabledRuntime kill-switch flags for staged performance features.