Skip to content

Commit

Permalink
feat: DRY and doc improvements
Browse files Browse the repository at this point in the history
Per code review suggestions,

* pulling common options out so we don't have repetition (that can get out of sync)
*  simplifying the documentation, since I hadn't realized we used semantic releases
  • Loading branch information
deborahgu committed Aug 14, 2024
1 parent 6bea23c commit 34af499
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ You can also add your own custom metrics as an additional argument, or see the c

General Logging service interface is defined in [frontend-platform](https://openedx.github.io/frontend-platform/module-Logging.LoggingService.html).

## Deployment

When you make changes, [draft a new release](https://github.com/edx/frontend-logging/releases) (and, if necessary, change the imported version number in importing packages).

## Usage

To install frontend-logging into your project::
Expand Down
23 changes: 10 additions & 13 deletions src/DatadogLoggingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,30 @@ class DatadogLoggingService extends NewRelicLoggingService {
}

const datadogVersion = process.env.DATADOG_VERSION || process.env.APP_VERSION || '1.0.0';
datadogRum.init({
applicationId: process.env.DATADOG_APPLICATION_ID,
beforeSend: this.beforeSend,
const commonInitOptions = {
clientToken: process.env.DATADOG_CLIENT_TOKEN,
site: process.env.DATADOG_SITE || '',
service: process.env.DATADOG_SERVICE || '',
env: process.env.DATADOG_ENV || '',
service: process.env.DATADOG_SERVICE || '',
version: datadogVersion,
trackSessionAcrossSubdomains: true,
usePartitionedCrossSiteSessionCookie: true,
};
datadogRum.init({
...commonInitOptions,
applicationId: process.env.DATADOG_APPLICATION_ID,
beforeSend: this.beforeSend,
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',
});
datadogLogs.init({
clientToken: process.env.DATADOG_CLIENT_TOKEN,
site: process.env.DATADOG_SITE || '',
env: process.env.DATADOG_ENV || '',
...commonInitOptions,
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 34af499

Please sign in to comment.