Last updated: August 5, 2026
API Reference
The Dash0 Web SDK provides several API functions to help you customize telemetry collection and add contextual information to your signals.
Signal attributes
Functions for managing custom attributes that are included with all signals.
addSignalAttribute(name, value)
Adds a signal attribute to be transmitted with every signal.
Parameters:
name(string): The attribute namevalue(AttributeValueType | AnyValue): The attribute value
Example:
12345678// Moduleimport { addSignalAttribute } from "@dash0/sdk-web";addSignalAttribute("environment", "production");addSignalAttribute("version", "1.2.3");// Scriptdash0("addSignalAttribute", "environment", "production");
Note: If you need to ensure attributes are included with signals transmitted on initial page load, use the
additionalSignalAttributes property in the init() call instead.
removeSignalAttribute(name)
Removes a previously added signal attribute.
Parameters:
name(string): The attribute name to remove
Example:
1234567// Moduleimport { removeSignalAttribute } from "@dash0/sdk-web";removeSignalAttribute("environment");// Scriptdash0("removeSignalAttribute", "environment");
User identification
identify(id, opts)
Associates user information with telemetry signals. See OTEL User Attributes for the matching attributes
Parameters:
id(string, optional): User identifieropts(object, optional): Additional user informationname(string, optional): Short name or login/username of the userfullName(string, optional): User's full nameemail(string, optional): User email addresshash(string, optional): Unique user hash to correlate information for a user in anonymized form.roles(string[], optional): User roles
Example:
123456789101112// Moduleimport { identify } from "@dash0/sdk-web";identify("user123", {name: "johndoe",fullName: "John Doe",email: "john@example.com",roles: ["admin", "user"],});// Scriptdash0("identify", "user123", { name: "johndoe" });
Custom Events
sendEvent(name, opts)
Sends a custom event with optional data and attributes. Event name cannot be one of the event names internally used by the Dash0 Web SDK. See Event Names
Parameters:
name(string): Event nameopts(object, optional): Event optionstitle(string, optional): Human readable title for the event. Should summarize the event in a single short sentence.timestamp(number | Date, optional): Event timestampdata(AttributeValueType | AnyValue, optional): Event dataattributes(Record<string, AttributeValueType | AnyValue>, optional): Event attributesseverity(LOG_SEVERITY_TEXT, optional): Log severity level
Example:
1234567891011121314// Moduleimport { sendEvent } from "@dash0/sdk-web";sendEvent("user_action", {data: "button_clicked",attributes: {buttonId: "submit-form",page: "/checkout",},severity: "INFO",});// Scriptdash0("sendEvent", "user_action", { data: "button_clicked", severity: "INFO" });
Page Views
startView(name, opts)
Manually records a page view. Side-effect free: this never calls history.pushState /
history.replaceState and never mutates location. Use this for single-page applications that
own their own router and cannot let the SDK touch navigation state — for example, an Electron
app that serves the whole application from one root URL, where automatic page-view tracking
would report every screen as /.
The emitted page view is indistinguishable from an automatic virtual page view downstream (same
browser.page_view event, same type value), with two differences: it is never accompanied by
a change_state value, since no history mutation occurred, and the pageViewInstrumentation's
generateMetadata callback is not invoked for manual views — supply title and attributes
directly via the options object instead.
Parameters:
name(string): The name of the view, e.g./settings. Transmitted as the page view's title.opts(object, optional): Additional page view details:url(string, optional): Overrides the url reflected inpage.url.*attributes for this view. Accepts an absolute or relative url; relative urls are resolved against the currentlocation.href. Falls back to the reallocation.hrefif omitted or invalid. Display-only — never navigates or mutates history/location.attributes(Record<string, AttributeValueType | AnyValue>, optional): Additional attributes to include with the page view. Added after the SDK-generated attributes, so they can override them.
Example:
12345678910111213// Moduleimport { startView } from "@dash0/sdk-web";startView("/settings", {attributes: {"app.screen": "settings",},});startView("/checkout");// Scriptdash0("startView", "/settings", { attributes: { "app.screen": "settings" } });
Error Reporting
reportError(error, opts)
Manually reports an error to be tracked in telemetry.
Parameters:
error(string | ErrorLike): Error message or error objectopts(object, optional): Error reporting optionscomponentStack(string | null | undefined, optional): Component stack trace for React errorsattributes(Record<string, AttributeValueType | AnyValue>, optional): Additional attributes to include with the error report
Example:
123456789101112131415161718192021222324// Moduleimport { reportError } from "@dash0/sdk-web";// Report a string errorreportError("Something went wrong in user flow");// Report an Error objecttry {// Some operation} catch (error) {reportError(error);}reportError(error, {// Report with component stack (useful for React)componentStack: getComponentStack(),// Additional attributesattributes: {"user.id": "user123",},});// Scriptdash0("reportError", "Something went wrong in user flow");
Session Management
terminateSession()
Manually terminates the current user session.
Example:
1234567891011// Moduleimport { terminateSession } from "@dash0/sdk-web";// Terminate session on user logoutfunction handleLogout() {terminateSession();// Additional logout logic}// Scriptdash0("terminateSession");
Note: Sessions are automatically managed by the Dash0 Web SDK based on inactivity and termination timeouts configured during initialization. Manual termination is typically only needed for explicit user logout scenarios.
Internal Telemetry
setActiveLogLevel(logLevel)
Changes the active log level of this SDK. Defaults to warn.
Example:
1234567// Moduleimport { setActiveLogLevel } from "@dash0/sdk-web";setActiveLogLevel("debug");// Scriptdash0("setActiveLogLevel", "debug");