SDK reference

Configuration reference

This page documents all configuration options across the Databuddy SDK platforms: React, Vue, vanilla JavaScript, and Node.js.

React / Next.js

tsx
import { Databuddy } from "@databuddy/sdk/react";

<Databuddy
// Required
clientId="your-client-id"

// API endpoints
apiUrl="https://basket.databuddy.cc"

// Core tracking
trackWebVitals={true}   // opt in; default: false
trackErrors             // default: false
trackOutgoingLinks      // default: false
trackInteractions       // default: true
trackAttributes         // default: false
trackHashChanges        // default: false

// Batching
enableBatching          // default: true
batchSize={10}          // 1-50
batchTimeout={5000}     // ms

// Retries
enableRetries           // default: true
maxRetries={3}
initialRetryDelay={500} // ms

// Sampling
samplingRate={1.0}      // 0.0-1.0

// Privacy
skipPatterns={["/admin/**", "/private/*"]}
maskPatterns={["/users/*", "/orders/**"]}

// Control
disabled={false}
debug={false}
/>

React props reference

PropTypeDefaultDescription
clientIdstringAuto-detectClient ID (auto-detects from NEXT_PUBLIC_DATABUDDY_CLIENT_ID)
apiUrlstringhttps://basket.databuddy.ccEvent endpoint. Set it with scriptUrl to serve Databuddy from your own domain
scriptUrlstringSDK-pinned, date-versioned CDN URLCustom script URL
scriptIntegritystringSDK-pinned SHA-384 hashIntegrity hash for a custom scriptUrl
disabledbooleanfalseDisable all tracking
debugbooleanfalseEnable debug logging

SDK 3.4 and later embed a specific tracker URL and integrity hash, including debug and replay scripts. Leave scriptUrl unset to use these pins. Unexpected CDN changes are blocked without falling back to an unversioned URL. Upgrade the SDK to receive future tracker updates.

Custom script URLs retain self-hosting support. Supply scriptIntegrity to verify custom tracker bytes; a custom URL without a hash opts out of integrity verification.

Tracking features

PropTypeDefaultDescription
trackWebVitalsbooleanfalseFCP, LCP, INP, CLS, TTFB, and FPS
trackErrorsbooleanfalseJavaScript errors
trackOutgoingLinksbooleanfalseExternal link clicks
trackInteractionsbooleantrueRage clicks, dead clicks, and abandoned forms
trackAttributesbooleanfalseElements with data-track attributes
trackHashChangesbooleanfalseURL hash changes

Use trackWebVitals in React, Vue, and Nuxt, or data-track-web-vitals with the CDN script.

Batching and performance

PropTypeDefaultDescription
enableBatchingbooleantrueCompatibility option; browser pageviews still use the batch queue
batchSizenumber10Events per batch (1-50)
batchTimeoutnumber5000Batch timeout in ms
enableRetriesbooleantrueRetry failed requests
maxRetriesnumber3Maximum retry attempts
initialRetryDelaynumber500Initial retry delay in ms
samplingRatenumber1.0Event sampling rate (0.0-1.0)

When verifying browser pageviews, allow for the configured batchTimeout and retry behavior before declaring an event missing. Setting enableBatching=false does not bypass the pageview queue in the current browser tracker. Inspect actual requests and use an explicit batchTimeout when a test needs a shorter queue window; a sent request still does not establish hosted report visibility.

Privacy

PropTypeDescription
skipPatternsstring[]Paths to skip tracking entirely
maskPatternsstring[]Paths to mask in analytics

Session replay

PropTypeDescription
replayboolean | { maskText?: boolean; recordIframes?: boolean; scriptUrl?: string; integrity?: string }Load the session replay recorder.

Vue

html
<script setup>
import { Databuddy } from "@databuddy/sdk/vue";
</script>

<template>
<Databuddy
  :client-id="clientId"
  :track-web-vitals="true"
  :track-errors="true"
  :enable-batching="true"
  :batch-size="20"
  :disabled="isDevelopment"
/>
</template>

Vue uses the same props as React but with kebab-case naming:

  • clientId → :client-id
  • trackWebVitals → :track-web-vitals
  • enableBatching → :enable-batching

Vanilla JavaScript

html
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="your-client-id"
data-track-web-vitals
data-track-errors
data-track-outgoing-links
data-enable-batching
data-batch-size="20"
data-batch-timeout="5000"
data-sampling-rate="1.0"
data-skip-patterns='["/admin/**"]'
data-mask-patterns='["/users/*"]'
async
></script>

Data attributes reference

AttributeTypeDefaultDescription
data-client-idstringRequiredYour Client ID
data-track-web-vitalsflagfalseFCP, LCP, INP, CLS, TTFB, and FPS
data-track-errorsflagfalseTrack JavaScript errors
data-track-outgoing-linksflagfalseTrack external links
data-track-interactionsflagtrueRage clicks, dead clicks, and abandoned forms; set "false" to turn off
data-track-attributesflagfalseTrack data-track elements
data-track-hash-changesflagfalseTrack hash changes
data-enable-batchingflagtrueEnable event batching
data-batch-sizenumber10Batch size
data-batch-timeoutnumber5000Batch timeout (ms)
data-sampling-ratenumber1.0Sampling rate
data-skip-patternsJSON[]Paths to skip
data-mask-patternsJSON[]Paths to mask
data-disabledflagfalseDisable tracking

Boolean options: Vue templates use kebab-case props such as track-web-vitals; vanilla CDN installs use data-* attributes such as data-track-web-vitals.

Node.js

tsx
import { Databuddy } from "@databuddy/sdk/node";

const client = new Databuddy({
// Required
apiKey: process.env.DATABUDDY_API_KEY!,

// Optional: Scope events to a specific website
websiteId: process.env.DATABUDDY_WEBSITE_ID,

// Optional: Logical grouping (e.g. 'auth', 'api', 'jobs')
namespace: "api",

// Optional: Source identifier (e.g. 'backend', 'webhook', 'cli')
source: "backend",

// API
apiUrl: "https://basket.databuddy.cc",

// Batching
enableBatching: true,       // default: true
batchSize: 10,              // max: 100
batchTimeout: 2000,         // ms
maxQueueSize: 1000,

// Deduplication
enableDeduplication: true,  // default: true
maxDeduplicationCacheSize: 10_000,

// Middleware
middleware: [
  (event) => {
    event.properties = { ...event.properties, server: true };
    return event;
  }
],

// Logging
debug: false,
logger: customLogger
});

Node.js options reference

OptionTypeDefaultDescription
apiKeystringRequiredYour API key for authentication
websiteIdstring-Optional default Client ID to scope events
namespacestring-Optional default namespace for logical grouping
sourcestring-Optional default source identifier for events
apiUrlstringhttps://basket.databuddy.ccAPI endpoint
enableBatchingbooleantrueEnable event batching
batchSizenumber10Batch size (max 100)
batchTimeoutnumber2000Batch timeout in ms
maxQueueSizenumber1000Maximum queue size
enableDeduplicationbooleantrueDeduplicate events by ID
maxDeduplicationCacheSizenumber10000Dedup cache size
middlewareMiddleware[][]Event transform functions
debugbooleanfalseEnable debug logging
loggerLogger-Custom logger instance

Feature flags (client)

tsx
import { FlagsProvider } from "@databuddy/sdk/react";

<FlagsProvider
clientId="your-client-id"
apiUrl="https://api.databuddy.cc"
user={{
  userId: "user-123",
  email: "user@example.com",
  organizationId: "org-456",
  teamId: "team-789",
  properties: {
    plan: "premium",
    role: "admin"
  }
}}
isPending={isLoadingSession}
disabled={false}
skipStorage={false}
autoFetch={true}
environment="production"
cacheTtl={60_000}
staleTime={30_000}
maxCacheSize={5000}
>
<App />
</FlagsProvider>

Feature flags options reference

OptionTypeDefaultDescription
clientIdstringRequiredYour Client ID
apiUrlstringhttps://api.databuddy.ccAPI endpoint
userUserContext-User context for targeting
isPendingbooleanfalseDefer evaluation
disabledbooleanfalseDisable flag evaluation
skipStoragebooleanfalseSkip localStorage caching
autoFetchbooleantrueAuto-fetch on mount
environmentstring-Environment name
cacheTtlnumber60000Cache TTL (ms)
staleTimenumber30000Revalidate after (ms)
maxCacheSizenumber5000Maximum cached entries for other contexts; the configured context keeps every returned flag

User context

OptionTypeDescription
userIdstringUnique user identifier
emailstringUser email
organizationIdstringOrganization ID for group rollouts
teamIdstringTeam ID for group rollouts
propertiesobjectCustom targeting properties

Feature flags (server)

tsx
import { createServerFlagsManager } from "@databuddy/sdk/node";

const flags = createServerFlagsManager({
clientId: process.env.DATABUDDY_CLIENT_ID!,
apiUrl: "https://api.databuddy.cc",
user: {
  userId: "user-123"
},
environment: "production",
cacheTtl: 60_000,
staleTime: 30_000,
maxCacheSize: 5000,
autoFetch: false,
disabled: false
});

Server flags use the same options as client flags, but skipStorage is always true, autoFetch defaults to false, and maxCacheSize caps the entries kept for per-call users.

Environment variables

The browser SDK auto-detects the Client ID from NEXT_PUBLIC_DATABUDDY_CLIENT_ID, NUXT_PUBLIC_DATABUDDY_CLIENT_ID, VITE_DATABUDDY_CLIENT_ID, or REACT_APP_DATABUDDY_CLIENT_ID. Other variables must be wired in explicitly.

Next.js

.env.localbash
NEXT_PUBLIC_DATABUDDY_CLIENT_ID=your-client-id
DATABUDDY_API_KEY=your-api-key

Vue / Vite

.envbash
VITE_DATABUDDY_CLIENT_ID=your-client-id

Node.js / server

The Node client does not read environment variables on its own. Pass them through the constructor:

.envbash
DATABUDDY_API_KEY=your-api-key
DATABUDDY_WEBSITE_ID=your-client-id  # Optional default Client ID
DATABUDDY_API_URL=https://basket.databuddy.cc  # Optional
tsx
import { Databuddy } from "@databuddy/sdk/node";

const client = new Databuddy({
apiKey: process.env.DATABUDDY_API_KEY!,
websiteId: process.env.DATABUDDY_WEBSITE_ID,
apiUrl: process.env.DATABUDDY_API_URL
});

The cookieless analytics overview explains the collection choices behind these options. Before enabling diagnostics, review the privacy considerations in error tracking and check the actual payloads your application produces.

How is this guide?