DataDog send custom data from RUM

I need to send the screen resolution from the user's device through DataDog. As it is easy to get window.screen.width and window.screen.height values, I have no clear idea how to send the values. My idea is to send a custom action:

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

(function sendScreenSize() {
    datadogRum.addAction('screenSize', {
        'width': window.screen.width,
        'height': window.screen.height

Is there any cleaner solution?

1 answer

  • answered 2022-05-04 15:36 bwest

    You could consider using beforeSend to add the width and height to the event context for view events, then you will always have that data for each view.

    For your current approach, you'd want to call addAction() in response to a page load or window resize event.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum