SDK Configuration
Pass a configuration object to DAP('init', config) to control SDK behavior. Only tenantKey is required.
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
tenantKey | string | (required) | Your API key from Settings > API Keys in the dashboard. |
baseUrl | string | Production API URL | Override the API endpoint. Useful for staging or self-hosted environments. |
debug | boolean | false | Enable verbose console logging prefixed with [DAP]. |
autoTrack | boolean | true | Automatically track page views and click events. Set to false to track manually. |
locale | string | Browser default | ISO locale code (e.g., en, es, fr) for content localization. (Localization feature coming soon — this option is reserved for future use.) |
journeys | JourneyConfig | undefined | Configure journey behavior and lifecycle callbacks. See below. |
onBeforeFlowStart | (flowId: string) => void | Promise<void> | undefined | Called before any flow starts. Return a Promise to delay the flow until the host app is ready (e.g., navigate to the correct page). |
contentRefreshInterval | number | 0 (disabled) | Polling interval in milliseconds to auto-refresh content and flows. Minimum: 120000 (2 minutes). |
initTimeoutMs | number | 10000 | Maximum time in milliseconds to wait for SDK initialization before timing out. |
Journey Configuration
The journeys object accepts the following options:
| Option | Type | Default | Description |
|---|---|---|---|
autoEnroll | boolean | true | Automatically enroll identified users in matching journeys. |
onJourneyStart | (journeyId: string, name: string) => void | undefined | Called when a user starts a journey. |
onStepComplete | (journeyId: string, step: unknown, index: number) => void | undefined | Called when a journey step is completed. |
onJourneyComplete | (journeyId: string) => void | undefined | Called when a journey is fully completed. |
Content Polling
When contentRefreshInterval is set, the SDK periodically re-fetches content items and flow definitions from the server. This ensures users see newly published or updated content without requiring a page reload.
- The minimum interval is 120 seconds (
120000ms), matching the server-side cache TTL. Values below this are clamped automatically. - Polling pauses when the browser tab is hidden and resumes with an immediate refresh when the tab becomes visible.
- Polling does not interfere with manual
DAP('refreshContent')calls. - Polling stops automatically when
DAP('destroy')is called.
DAP("init", {
tenantKey: "wfx_your_api_key_here",
contentRefreshInterval: 300000, // refresh every 5 minutes
});
Minimal Example
DAP("init", { tenantKey: "wfx_your_api_key_here" });
Full Configuration Example
DAP("init", {
tenantKey: "wfx_your_api_key_here",
baseUrl: "https://api.yourcompany.com",
debug: true,
autoTrack: true,
locale: "en",
journeys: {
autoEnroll: true,
onJourneyStart: function (journeyId, name) {
console.log("Journey started:", name);
},
onStepComplete: function (journeyId, step, index) {
console.log("Step completed:", index);
},
onJourneyComplete: function (journeyId) {
console.log("Journey complete:", journeyId);
},
},
onBeforeFlowStart: function (flowId) {
// Navigate to the correct page before the flow begins
return navigateToPage(flowId);
},
contentRefreshInterval: 300000, // auto-refresh every 5 minutes
initTimeoutMs: 15000, // wait up to 15 seconds for init
});
Notes
- The
tenantKeyis the only required option. All other options have sensible defaults. - Set
debug: trueduring development to see SDK lifecycle events, content fetches, and targeting evaluations in the console. - If
autoTrackis set tofalse, you must manually callDAP('track', eventData)to record events. - The
localeoption controls which translation of your content is displayed. If omitted, the SDK falls back to the browser's language setting.