diff --git a/src/DatadogLoggingService.js b/src/DatadogLoggingService.js index 8cf8701..f27f472 100644 --- a/src/DatadogLoggingService.js +++ b/src/DatadogLoggingService.js @@ -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, @@ -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 || '',