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?
You could consider using
beforeSend
to add the width and height to the event context forview
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.