Complete guide to configuring Dash0 Web SDK.
init({
serviceName: "my-website", // Required
endpoint: { // Required
url: "https://ingress.dash0.com",
authToken: "auth_your_token_here",
},
});init({
serviceName: "my-website",
serviceVersion: "1.2.3", // Optional: service version
environment: "production", // Optional: environment name
deploymentName: "prod-us", // Optional: deployment identifier
deploymentId: "deploy-123", // Optional: deployment ID
endpoint: { url: "...", authToken: "..." },
});Enable or disable specific instrumentations:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
enabledInstrumentations: [
"@dash0/navigation", // Page views and navigation timing
"@dash0/web-vitals", // Core Web Vitals (CLS, INP, LCP)
"@dash0/error", // Error tracking
"@dash0/fetch", // HTTP request instrumentation
],
});Default: All instrumentations are enabled if not specified.
Configure session lifecycle:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
sessionInactivityTimeoutMillis: 10800000, // 3 hours (default)
sessionTerminationTimeoutMillis: 21600000, // 6 hours (default)
});Maximum: 24 hours (86400000 ms) for both timeouts.
Configure distributed tracing headers:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
propagators: [
// W3C traceparent for internal APIs
{ type: "traceparent", match: [/.*\/api\/internal.*/] },
// AWS X-Ray for AWS services
{ type: "xray", match: [/.*\.amazonaws\.com.*/] },
],
});Filter out URLs from telemetry:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
ignoreUrls: [
/.*\/health$/,
/.*\/ping$/,
],
});Filter out error messages:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
ignoreErrorMessages: [
/Script error/i,
/Non-Error promise rejection/i,
],
});Remove sensitive data from URLs:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
urlAttributeScrubber: (attrs) => {
// Redact sensitive query parameters
if (attrs["url.query"]?.includes("token=")) {
attrs["url.query"] = attrs["url.query"].replace(
/token=[^&]+/,
"token=REDACTED"
);
}
return attrs;
},
});init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
wrapEventHandlers: true, // Wrap DOM event handlers (default: true)
wrapTimers: true, // Wrap setTimeout/setInterval (default: true)
});init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
maxWaitForResourceTimingsMillis: 10000, // 10 seconds (default)
maxToleranceForResourceTimingsMillis: 50, // 50ms (default)
headersToCapture: [/^X-.*/], // Capture matching headers
});Configure virtual page view tracking for SPAs:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
pageViewInstrumentation: {
trackVirtualPageViews: true,
includeParts: ["HASH", "SEARCH"], // Track hash/search changes
generateMetadata: (url) => {
if (url.pathname.startsWith("/product/")) {
return {
title: "Product Page",
attributes: {
"page.category": "product",
},
};
}
return undefined;
},
},
});Add attributes to all telemetry signals:
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
additionalSignalAttributes: {
"app.region": "us-east-1",
"app.tier": "premium",
"app.version": "1.2.3",
},
});Send telemetry to multiple endpoints:
init({
serviceName: "my-website",
endpoint: [
{
url: "https://primary.dash0.com",
authToken: "auth_primary_token",
dataset: "production",
},
{
url: "https://backup.monitoring.com",
authToken: "auth_backup_token",
},
],
});init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
enableTransportCompression: false, // Experimental: gzip compression
});The SDK can auto-detect configuration from Next.js environment variables:
| Config Key | Environment Variable |
|---|---|
environment | NEXT_PUBLIC_VERCEL_ENV |
deploymentName | NEXT_PUBLIC_VERCEL_TARGET_ENV |
deploymentId | NEXT_PUBLIC_VERCEL_BRANCH_URL |
Explicit configuration values override auto-detected values.
serviceName and endpointSee Initialization Reference for complete API documentation.