Skip to content

Commit

Permalink
feat: add beforeSend to RUM init (#33)
Browse files Browse the repository at this point in the history
* feat: add beforeSend to RUM init

---------

Co-authored-by: Adam Stankiewicz <[email protected]>
  • Loading branch information
jsnwesson and adamstankiewicz authored Jul 17, 2024
1 parent 8ff3807 commit 1c8ea2f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/DatadogLoggingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ class DatadogLoggingService extends NewRelicLoggingService {
this.initialize();
}

// to read more about the use cases for beforeSend, refer to the documentation:
// https://docs.datadoghq.com/real_user_monitoring/guide/enrich-and-control-rum-data/?tab=event#event-and-context-structure
// (e.g., discarding frontend errors matching the optional `IGNORED_ERROR_REGEX` configuration,
// currently implemented in `logError` below).
beforeSend() {
// common/shared logic across all MFEs
return true;
}

initialize() {
const requiredDatadogConfig = [
process.env.DATADOG_APPLICATION_ID,
Expand All @@ -42,6 +51,7 @@ 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,
clientToken: process.env.DATADOG_CLIENT_TOKEN,
site: process.env.DATADOG_SITE || '',
service: process.env.DATADOG_SERVICE || '',
Expand Down

0 comments on commit 1c8ea2f

Please sign in to comment.