Skip to content

Commit

Permalink
feat: allow session tracking across subdomains
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
deborahgu committed Aug 14, 2024
1 parent 6a7c530 commit 7c09c79
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DatadogLoggingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down

0 comments on commit 7c09c79

Please sign in to comment.