DEV Community

Cover image for For those who have trouble setting up Datadog RUM
Masayoshi Haruta
Masayoshi Haruta

Posted on

5 2

For those who have trouble setting up Datadog RUM

Introduction

If anyone has trouble setting up Datadog RUM, I would like to tell them, "The setup code for JS/NPM version has some incorrect." I have previously texted Datadog support about the feedback, but it has not been fixed, so I wrote it.
Setting page

1. Typo in the snippet

As you can see in the screenshot, a snippet is provided as a sample, but unfortunately, a typo has.
Sample Snipet

Look at line 3, the curly bracket { has been used, datadogRum.init({.
But the } never has been stated in the snippet.

Here is the collect snippet.

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

datadogRum.init({
    applicationId: 'hoge-hoge-hoge',
    clientToken: 'hoge-hoge-hoge',
    site: 'datadoghq.com',
    service:'temp',

    // Specify a version number to identify the deployed version of your application in Datadog 
    // version: '1.0.0',
    sampleRate: 100,
    replaySampleRate: 100,
    trackInteractions: true,
    defaultPrivacyLevel:'mask-user-input',
});

datadogRum.startSessionReplayRecording();
Enter fullscreen mode Exit fullscreen mode

2. Disabled Session Replay

If you wanna disable session replay, you also have to be careful with this setup page. There is a toggle, Session Replay Enabled, which seems to allow the snippet to be edited to disable the function.
Image description

However, only this setting doesn't seem sufficient...😅 You also must set replaySampleRate: 0

References

Set replaySampleRate to 0 to stop collecting the RUM Session Replay plan which includes replays, resources, and long tasks.

That's why here is the collect snippet!

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

datadogRum.init({
    applicationId: 'hoge-hoge-hoge-b2e3-40e049c84c81',
    clientToken: 'hoge-hoge-hoge-881b380180c1171d17',
    site: 'datadoghq.com',
    service:'temp',

    // Specify a version number to identify the deployed version of your application in Datadog 
    // version: '1.0.0',
    sampleRate: 100,
    replaySampleRate: 0,
    trackInteractions: true,
);
Enter fullscreen mode Exit fullscreen mode

Happy Monitoring!

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook