From 7c09c7943719bc276673ae7a0833eeb19489d16d Mon Sep 17 00:00:00 2001 From: Deborah Kaplan Date: Wed, 14 Aug 2024 15:05:44 +0000 Subject: [PATCH] feat: allow session tracking across subdomains In order to gain the ability to track our sessions, funnels, conversions, journeys, etc. across all of our various applications and subdomains, we need to add a couple of settings to RUM and Logs SDK setup. From [Datadog Browser Log Collection](https://docs.datadoghq.com/real_user_monitoring/browser/setup/#initialization-parameters) and [Datadog Log Collection initialization parameters](https://docs.datadoghq.com/logs/log_collection/javascript/#initialization-parameters): * `trackSessionAcrossSubdomains`: Preserve the session across subdomains for the same site. * `usePartitionedCrossSiteSessionCookie`: Use a partitioned secure cross-site session cookie. This allows the logs SDK to run when the site is loaded from another one (iframe). Implies `useSecureSessionCookie`. Per DD support: > The `useCrossSiteSessionCookie` parameter specifies the type of cookie the SDK will set, it's not a reference to cross-domain tracking. You would want this to be set to `true` to track events when the page is rendered as an iframe. Note: `useCrossSiteSessionCookie` is marked in the documents as a deprecated perimeter which we should replace with`usePartitionedCrossSiteSessionCookie`. --- src/DatadogLoggingService.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/DatadogLoggingService.js b/src/DatadogLoggingService.js index 41403ec..77f8ad4 100644 --- a/src/DatadogLoggingService.js +++ b/src/DatadogLoggingService.js @@ -60,6 +60,8 @@ class DatadogLoggingService extends NewRelicLoggingService { sessionSampleRate: parseInt(process.env.DATADOG_SESSION_SAMPLE_RATE || 0, 10), sessionReplaySampleRate: parseInt(process.env.DATADOG_SESSION_REPLAY_SAMPLE_RATE || 0, 10), trackUserInteractions: true, + trackSessionAcrossSubdomains: true, + usePartitionedCrossSiteSessionCookie: true, trackResources: true, trackLongTasks: true, defaultPrivacyLevel: process.env.DATADOG_PRIVACY_LEVEL || 'mask-user-input', @@ -69,6 +71,8 @@ class DatadogLoggingService extends NewRelicLoggingService { site: process.env.DATADOG_SITE || '', env: process.env.DATADOG_ENV || '', forwardErrorsToLogs: true, + trackSessionAcrossSubdomains: true, + usePartitionedCrossSiteSessionCookie: true, sessionSampleRate: parseInt(process.env.DATADOG_LOGS_SESSION_SAMPLE_RATE || 0, 10), service: process.env.DATADOG_SERVICE || '', version: datadogVersion,