Skip to content

Commit 1c8ea2f

Browse files
feat: add beforeSend to RUM init (#33)
* feat: add beforeSend to RUM init --------- Co-authored-by: Adam Stankiewicz <[email protected]>
1 parent 8ff3807 commit 1c8ea2f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/DatadogLoggingService.js

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ class DatadogLoggingService extends NewRelicLoggingService {
2727
this.initialize();
2828
}
2929

30+
// to read more about the use cases for beforeSend, refer to the documentation:
31+
// https://docs.datadoghq.com/real_user_monitoring/guide/enrich-and-control-rum-data/?tab=event#event-and-context-structure
32+
// (e.g., discarding frontend errors matching the optional `IGNORED_ERROR_REGEX` configuration,
33+
// currently implemented in `logError` below).
34+
beforeSend() {
35+
// common/shared logic across all MFEs
36+
return true;
37+
}
38+
3039
initialize() {
3140
const requiredDatadogConfig = [
3241
process.env.DATADOG_APPLICATION_ID,
@@ -42,6 +51,7 @@ class DatadogLoggingService extends NewRelicLoggingService {
4251
const datadogVersion = process.env.DATADOG_VERSION || process.env.APP_VERSION || '1.0.0';
4352
datadogRum.init({
4453
applicationId: process.env.DATADOG_APPLICATION_ID,
54+
beforeSend: this.beforeSend,
4555
clientToken: process.env.DATADOG_CLIENT_TOKEN,
4656
site: process.env.DATADOG_SITE || '',
4757
service: process.env.DATADOG_SERVICE || '',

0 commit comments

Comments
 (0)