이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Overview

Error Tracking processes errors collected from the browser by the Browser SDK. Whenever a source, custom, report, or console error containing a stack trace is collected, Error Tracking processes and groups it under an issue, or group of similar errors to be found in the Error Tracking Explorer.

Prerequisites

Download the latest version of the Browser SDK.

Setup

To start sending Error Tracking data from your browser application to Datadog, follow the in-app setup instructions or follow the steps below.

Step 1 - Create the application

  1. In Datadog, navigate to the Errors > Settings > Browser and Mobile > Add an Application page and select the JavaScript (JS) application type.
  2. Enter a name for your application, then click Create Application. This generates a clientToken and an applicationId for your application.

Step 2 - Choose the right installation method

Choose the installation type for the Browser SDK.

Installing through npm (Node Package Manager) is recommended for modern web applications. The Browser SDK is packaged with the rest of your frontend JavaScript code. It has no impact on page load performance. However, the SDK may miss errors, resources, and user actions triggered before the SDK is initialized. Datadog recommends using a matching version with the Browser Logs SDK.

Add @datadog/browser-rum to your package.json file, then initialize it with:

import { datadogRum } from '@datadog/browser-rum';

datadogRum.init({

   applicationId: '<APP_ID>',
   clientToken: '<CLIENT_TOKEN>',
   service: '<SERVICE>',
   env: '<ENV_NAME>',
   // site: '<SITE>',
   // version: '1.0.0',
   trackUserInteractions: true,
   trackResources: true
});

The trackUserInteractions parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained in your pages may be included to identify the elements interacted with.

Installing through CDN async is recommended for web applications with performance targets. The Browser SDK loads from Datadog’s CDN asynchronously, ensuring the SDK download does not impact page load performance. However, the SDK may miss errors, resources, and user actions triggered before the SDK is initialized.

Add the generated code snippet to the head tag of every HTML page you want to monitor in your application. For the site:

<script>
  (function(h,o,u,n,d) {
    h=h[d]=h[d]||{q:[],onReady:function(c){h.q.push(c)}}
    d=o.createElement(u);d.async=1;d.src=n
    n=o.getElementsByTagName(u)[0];n.parentNode.insertBefore(d,n)
  })(window,document,'script','https://www.datadoghq-browser-agent.com/us1/v6/datadog-rum.js','DD_RUM')
  window.DD_RUM.onReady(function() {
    window.DD_RUM.init({
      clientToken: '<CLIENT_TOKEN>',
      applicationId: '<APP_ID>',
      // site: '<SITE>',
      service: '<APP_ID>',
      env: '<ENV_NAME>',
      // version: '1.0.0'
    });
  })
</script>

The trackUserInteractions parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained in your pages may be included to identify the elements interacted with.

Installing through CDN sync is recommended for collecting all events. The Browser SDK loads from Datadog’s CDN synchronously, ensuring the SDK loads first and collects all errors, resources, and user actions. This method may impact page load performance.

Add the generated code snippet to the head tag (in front of any other script tags) of every HTML page you want to monitor in your application. Placing the script tag higher and loading it synchronously ensures Datadog RUM can collect all performance data and errors. For the site:

<script
    src="https://www.datadoghq-browser-agent.com/us1/v6/datadog-rum.js"
    type="text/javascript">
</script>
<script>
    window.DD_RUM && window.DD_RUM.init({
      clientToken: '<CLIENT_TOKEN>',
      applicationId: '<APP_ID>',
      // site: '<SITE>',
      service: '<APP_ID>',
      env: '<ENV_NAME>',
      // version: '1.0.0'
    });
</script>

The trackUserInteractions parameter enables the automatic collection of user clicks in your application. Sensitive and private data contained in your pages may be included to identify the elements interacted with.

TypeScript (optional)

If you are initializing the SDK in a TypeScript project, use the code snippet below. Types are compatible with TypeScript >= 3.8.2.

Note: For earlier versions of TypeScript, import JavaScript sources and use global variables to avoid any compilation issues.
import '@datadog/browser-rum/bundle/datadog-rum'

window.DD_RUM.init({
  applicationId: 'XXX',
  clientToken: 'XXX',
  site: 'datadoghq.com',
  trackUserInteractions: true,
  trackResources: true,
  ...
})

Step 3 - Configure environment and settings

  1. In the Environment field, define the environment (env) for your application to use unified service tagging.
  2. In the Service field, define the service (service) for your application to use unified service tagging.
  3. Set the privacy level for user input. See Session Replay Browser Privacy Options for more details.
  4. Set a version number (version) for your deployed application in the initialization snippet. For more information, see Tagging.
  5. Configure additional parameters as needed. See the Configuration reference section below for all available options.

Step 4 - Deploy your application

Deploy the changes to your application. After your deployment is live, Datadog collects events from your users’ browsers.

Upload your JavaScript source maps to access unminified stack traces. See the source map upload guide.

Step 6 - Visualize your data

Now that you’ve completed the basic setup for Browser Error Tracking, your application is collecting browser errors and you can start monitoring and debugging issues in real-time.

Visualize the data collected in dashboards or create a search query in Error Tracking.

Until Datadog starts receiving data, your application appears as pending on the Applications page.

In addition to sending source maps, the Datadog CLI reports Git information such as the commit hash, repository URL, and a list of tracked file paths in the code repository.

Error Tracking can use this information to correlate errors with your source code, allowing you to pivot from any stack trace frame to the related line of code in GitHub, GitLab and Bitbucket.

Linking from stack frames to source code is supported in the Datadog CLI version 0.12.0 and later.

For more information, see the Datadog Source Code Integration.

Tagging for Error Tracking

These tags (configured in step 3 above) power Error Tracking functionality:

  • Filtering and faceting issues by service and env
  • Cross-product correlation with RUM, Logs, and APM for the same service/env
  • Matching uploaded source maps through the same service and version you configure during upload

A service is an independent, deployable code repository that maps to a set of pages:

  • If your browser application was constructed as a monolith, your Datadog application has one service name for the application.
  • If your browser application was constructed as separate repositories for multiple pages, edit the default service names throughout the lifecycle of your application.

Learn more about tagging in Datadog.

Configuration reference

Call the initialization command to start tracking. The below parameters are available.

Required

These parameters are essential for the Browser SDK to function. You must provide both values to initialize Error Tracking.

ParameterTypeDefaultDescription
applicationIdString-The application ID.
clientTokenString-A Datadog client token.

Core configuration

These parameters define your application’s identity and environment. They’re used for unified service tagging and help organize your data across Datadog products.

ParameterTypeDefaultDescription
envString-The application’s environment (for example: prod, pre-prod, staging). Follows the tag syntax requirements.
serviceString-The service name for your application. Follows the tag syntax requirements.
siteStringdatadoghq.comThe Datadog site parameter of your organization.
versionString-The application’s version (for example: 1.2.3, 6c44da20). Follows the tag syntax requirements.

These parameters control how user data is collected and protected. Configure them based on your privacy requirements and compliance needs.

ParameterTypeDefaultDescription
defaultPrivacyLevelStringmaskSee Session Replay Privacy Options.
enablePrivacyForActionNameBooleanfalseSee Mask Action Names.
trackingConsent"granted" or "not-granted""granted"Set the initial user tracking consent state. See User Tracking Consent.

Tracking and collection

These parameters control what data is automatically collected from user interactions and pageviews. Enable them based on your monitoring needs.

ParameterTypeDefaultDescription
actionNameAttributeString-Specify your own attribute to be used to name actions.
sessionSampleRateNumber100The percentage of sessions to track: 100 for all, 0 for none. See sampling configuration.
trackResourcesBooleanfalseEnables collection of resource events.
trackUserInteractionsBooleanfalseEnables automatic collection of user actions.
trackViewsManuallyBooleanfalseAllows you to control views creation. See override default view names.

Advanced configuration

These parameters provide fine-grained control over SDK behavior, networking, and performance. Use them for advanced use cases and custom configurations.

ParameterTypeDefaultDescription
compressIntakeRequestsBooleanfalseCompresses intake requests to reduce bandwidth usage.
excludedActivityUrlsList-A list of request origins ignored when computing page activity. See How page activity is calculated.
proxyString-Optional proxy URL. See the full proxy setup guide.
silentMultipleInitBooleanfalseInitialization fails silently if the RUM Browser SDK is already initialized.
workerUrlString-URL pointing to the Datadog Browser SDK Worker JavaScript file. See Content Security Policy guidelines.

Context and storage

These parameters control how user context and application state are preserved across page navigation and browser sessions.

ParameterTypeDefaultDescription
allowUntrustedEventsBooleanfalseAllow capture of untrusted events, for example in automated UI tests.
storeContextsAcrossPagesBooleanfalseStore global context and user context in localStorage to preserve them along user navigation. See Contexts life cycle.

Logs Browser SDK compatibility options

These parameters ensure compatibility when using both the RUM Browser SDK and Logs Browser SDK together. They must have matching configuration values across both SDKs to maintain consistent session tracking and data correlation.

ParameterTypeDefaultDescription
allowFallbackToLocalStorageBooleanfalseDeprecated - Use sessionPersistence instead.
sessionPersistence"cookie" | "local-storage""cookie"Which storage strategy to use for persisting sessions. Can be either cookie or local-storage.
trackSessionAcrossSubdomainsBooleanfalsePreserve the session across subdomains for the same site.
usePartitionedCrossSiteSessionCookieBooleanfalseUse a partitioned secure cross-site session cookie. This allows the Browser SDK to run when the site is loaded from another one (iframe). Implies useSecureSessionCookie.
useSecureSessionCookieBooleanfalseUse a secure session cookie. This disables events sent on insecure (non-HTTPS) connections.

Advanced features (optional)

Manage uploaded source maps

See all uploaded symbols and manage your source maps on the Debug Symbols page.

Note: Source maps are limited in size to 500 MB each.

Next steps

You can monitor unhandled exceptions, unhandled promise rejections, handled exceptions, handled promise rejections, and other errors that the Browser SDK does not automatically track. Learn more about Collecting Browser Errors.

Further reading