Configuration reference
This page documents all configuration options across the Databuddy SDK platforms: React, Vue, vanilla JavaScript, and Node.js.
React / Next.js
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
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
Batching and performance
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
Session replay
Vue
<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:
Vanilla JavaScript
<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
Node.js
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
Feature flags (client)
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
User context
Feature flags (server)
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
NEXT_PUBLIC_DATABUDDY_CLIENT_ID=your-client-id
DATABUDDY_API_KEY=your-api-keyVue / Vite
VITE_DATABUDDY_CLIENT_ID=your-client-idNode.js / server
The Node client does not read environment variables on its own. Pass them through the constructor:
DATABUDDY_API_KEY=your-api-key
DATABUDDY_WEBSITE_ID=your-client-id # Optional default Client ID
DATABUDDY_API_URL=https://basket.databuddy.cc # Optionalimport { 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.
Related
How is this guide?