DEV Community

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

Posted on

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!

Top comments (0)