Dash0 acquires Polar Signals
Monitor web application performance, views, sessions, requests and more with dash0's website monitoring
Use the Dash0 web sdk to instrument your web application for our website monitoring features. It allows to observe end-user page loads, website performance, sessions, fetch requests and errors. And seamlessly integrates website monitoring with your existing telemetry signals. It is 100% open source and its code and detailed documentation is available on github.
Want AI to set this up for you? Install the Dash0 Agent Skills to let Claude Code, Cursor, or Windsurf instrument your application automatically with OpenTelemetry best practices.
You'll need a couple of prerequisites before you can start using the sdk:
OTLP via HTTP endpoint tab of the Endpoints settings page for your organizationDue to the nature of client monitoring the auth token used will be public. Please make sure to take the following
precautions: * Use a separate token, exclusively for web monitoring * Limit the tokens dataset to only the dataset you
want to ingest to * Limit the tokens permissions to Ingesting
Next we'll need to install the sdk's package
npm install --save @dash0/sdk-webFinally the sdk needs to be initialized. This should happen as early as possible in your applications lifecycle. If you are using Next.js you can use their instrumentation-client.js file, but initialization is generally framework agnostic.
Here is a simple example:
import { init } from "@dash0/sdk-web";
init({
serviceName: "my-website",
endpoint: {
// Replace this with the endpoint url identified during preparation
url: "http://example.com",
// Replace this with your auth token you created earlier
// Ideally inject the value at build time to not commit the token to git, even if its effectively public
authToken: "you-auth-token-goes-here",
},
});Most SDK features will work via auto instrumentation and do not require you to make any changes to your application beyond initializing the sdk. However these can be enhanced and extended with application specific data if you want. The following examples will give you a short overview on how to do this, please refer to the sdk's repository for additional details.
import { addSignalAttribute, removeSignalAttribute } from "@dash0/sdk-web";
addSignalAttribute("environment", "production");
addSignalAttribute("version", "1.2.3");
removeSignalAttribute("environment");import { identify } from "@dash0/sdk-web";
identify("user123", {
name: "johndoe",
fullName: "John Doe",
email: "john@example.com",
roles: ["admin", "user"],
});import { reportError } from "@dash0/sdk-web";
// Report a string error
reportError("Something went wrong in user flow");
// Report an Error object
try {
// Some operation
} catch (error) {
reportError(error);
}
// Report with component stack (useful for React)
reportError(error, {
componentStack: getComponentStack(),
});import { sendEvent } from "@dash0/sdk-web";
sendEvent("user_action", {
data: "button_clicked",
attributes: {
buttonId: "submit-form",
page: "/checkout",
},
severity: "INFO",
});Session replay records what your users see and do on your website, so you can watch a session back in Dash0 next to its page views, requests, errors and traces. The recorder is built on rrweb and ships as an optional, separate bundle: websites that do not record sessions do not download it.
Session replay requires @dash0/sdk-web version 0.25.0 or later.
Import the recorder and pass it to init:
import { init } from "@dash0/sdk-web";
import { recorder } from "@dash0/sdk-web/session-recording";
init({
serviceName: "my-website",
endpoint: {
url: "http://example.com",
authToken: "your-auth-token-goes-here",
},
sessionRecording: { recorder },
});If you load the SDK with a script tag, add the recorder script next to it. The order of the two scripts does not matter:
<script defer crossorigin="anonymous" src="https://unpkg.com/@dash0/sdk-web/dist/dash0.iife.js"></script>
<script
defer
crossorigin="anonymous"
src="https://unpkg.com/@dash0/sdk-web/dist/dash0-session-recording.iife.js"
></script>If your Content Security Policy allows a specific script URL or hash rather than all of https://unpkg.com, add an
entry for dash0-session-recording.iife.js as well. The recording is sent to the same endpoint as the rest of the
SDK's telemetry, so connect-src needs no change.
The recorder only records while the page is visible, and it needs Proxy and MutationObserver. In browsers that lack
them, the SDK keeps working and only skips session replay.
By default, the value of every visible input, textarea and select is replaced with asterisks before it leaves the browser. Page text and element attributes are recorded as they are. To keep more data out of the recording:
dash0-mask to an element to mask its text.dash0-block to an element to leave it out of the recording. The replay shows a placeholder of the
same size instead.maskTextSelector and blockSelector to mask or block elements by CSS selector.init({
// ...
sessionRecording: {
recorder,
// Mask all text on the page
maskTextSelector: "*",
// Leave hidden inputs, whose values are attributes and not masked, out of the recording
blockSelector: "input[type=hidden]",
},
});Values of <input type="hidden">, <meta content>, data-* attributes and value= attributes set in markup are not
masked. Use blockSelector or the dash0-block class for elements that carry sensitive data in their attributes.
Use samplingRate to record a percentage of sessions, between 0 and 100 (default 100). The decision is made per
session, and recorded sessions are always a subset of the sessions selected by sessionSamplingRate.
init({
// ...
sessionRecording: { recorder, samplingRate: 10 },
});To record only after a user gives consent, or to pause recording on a page, leave the recorder out of init and start
and stop the recording yourself:
import { startSessionRecording, stopSessionRecording } from "@dash0/sdk-web";
import { recorder } from "@dash0/sdk-web/session-recording";
startSessionRecording(recorder);
stopSessionRecording();stopSessionRecording sends any events the recorder has buffered before it stops.
In Dash0, open Websites, select your website and go to the Sessions tab. Sessions that have a recording show a replay button in the Replay column. Open a session to watch its replay alongside the session's page views, events and errors.
For all session replay options, such as canvas recording, font collection and custom masking functions, see the session replay configuration in the SDK's documentation.
Consult the Dash0 documentation to learn more about the website monitoring features, or visit the Dash0 SDK Web Repository to learn more about the sdk.