Skip to main content

SDK Configuration

Pass a configuration object to DAP('init', config) to control SDK behavior. Only tenantKey is required.

Configuration Options

OptionTypeDefaultDescription
tenantKeystring(required)Your API key from Settings > API Keys in the dashboard.
baseUrlstringProduction API URLOverride the API endpoint. Useful for staging or self-hosted environments.
debugbooleanfalseEnable verbose console logging prefixed with [DAP].
autoTrackbooleantrueAutomatically track page views and click events. Set to false to track manually.
localestringBrowser defaultISO locale code (e.g., en, es, fr) for content localization. (Localization feature coming soon — this option is reserved for future use.)
journeysJourneyConfigundefinedConfigure journey behavior and lifecycle callbacks. See below.
onBeforeFlowStart(flowId: string) => void | Promise<void>undefinedCalled before any flow starts. Return a Promise to delay the flow until the host app is ready (e.g., navigate to the correct page).
contentRefreshIntervalnumber0 (disabled)Polling interval in milliseconds to auto-refresh content and flows. Minimum: 120000 (2 minutes).
initTimeoutMsnumber10000Maximum time in milliseconds to wait for SDK initialization before timing out.

Journey Configuration

The journeys object accepts the following options:

OptionTypeDefaultDescription
autoEnrollbooleantrueAutomatically enroll identified users in matching journeys.
onJourneyStart(journeyId: string, name: string) => voidundefinedCalled when a user starts a journey.
onStepComplete(journeyId: string, step: unknown, index: number) => voidundefinedCalled when a journey step is completed.
onJourneyComplete(journeyId: string) => voidundefinedCalled 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 (120000 ms), 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 tenantKey is the only required option. All other options have sensible defaults.
  • Set debug: true during development to see SDK lifecycle events, content fetches, and targeting evaluations in the console.
  • If autoTrack is set to false, you must manually call DAP('track', eventData) to record events.
  • The locale option controls which translation of your content is displayed. If omitted, the SDK falls back to the browser's language setting.