From 1adbbf27a15459f330f801a91b62a716e8732db8 Mon Sep 17 00:00:00 2001 From: cy-moi Date: Thu, 23 Oct 2025 17:31:53 +0200 Subject: [PATCH 1/2] Add RUM Privacy Plugin docs --- packages/plugins/rum/src/privacy/README.md | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 packages/plugins/rum/src/privacy/README.md diff --git a/packages/plugins/rum/src/privacy/README.md b/packages/plugins/rum/src/privacy/README.md new file mode 100644 index 000000000..b4380a52d --- /dev/null +++ b/packages/plugins/rum/src/privacy/README.md @@ -0,0 +1,89 @@ +# RUM Privacy Plugin + +The RUM Privacy Plugin provides action name and session replay masking capabilities for Real User Monitoring (RUM). This plugin helps protect sensitive data while maintaining observability. + +## Use Cases + +This plugin is particularly useful for: +- Masking sensitive data **before** sending them to Datadog +- Providing an out-of-the-box solution with minimal instrumentation overhead +- Maintaining observability while ensuring privacy compliance + +## Reserved Global Variables + +The following global variable is used by this plugin: +- `$DD_ALLOW` - Contains raw static strings from source code +- `$DD_A_Q` - Manage the queue of adding to allowlist at runtime + +## File Inclusion/Exclusion for String Literal Extraction + +### Default Settings + +Excludes: +- `node_modules` directories +- `.preval` files +- Files that start with special characters +Includes: +- files matching `/\.(?:c|m)?(?:j|t)sx?$/` + +### Overrides +You can override file inclusion/exclusion using regular expressions: + +```javascript +exclude: [/packages\/apps\/mocks/] +include: [/packages\/apps\/.*\.(?:c|m)?(?:j|t)sx?$/], +``` + +> Note: if you are overriding the default setting, please make sure that you are aligned with the default setting. + +### Excluding Code Blocks with Comments +#### Single Line + +```javascript + "exclude line 1", // datadog-privacy-allowlist-exclude-line + "exclude line 2", /* datadog-privacy-allowlist-exclude-line */ + + /* datadog-privacy-allowlist-exclude-line */ "exclude line 3", + + /* + datadog-privacy-allowlist-exclude-line + */ "exclude line 4", +``` + +#### Next Line +```javascript + // datadog-privacy-allowlist-exclude-next-line + "exclude next line 1", + + /* datadog-privacy-allowlist-exclude-next-line */ + "exclude next line 2", + + /* + datadog-privacy-allowlist-exclude-next-line + */ + `exclude next line 3`, +``` + +#### Multi-line/Blocks +```javascript + // datadog-privacy-allowlist-exclude-begin + "exclude range 1", + 'exclude range 2', + `exclude range 3`, + // datadog-privacy-allowlist-exclude-end + + /* datadog-privacy-allowlist-exclude-begin */ + "exclude range with block comment 1", + 'exclude range with block comment 2', + `exclude range with block comment 3`, + /* datadog-privacy-allowlist-exclude-end */ + + + // An unterminated 'exclude-begin' should cover the rest of the file. (And extra + // 'exclude-begins' after that point should be ignored.) + /* datadog-privacy-allowlist-exclude-begin */ + "exclude range with unterminated comment 1", + 'exclude range with unterminated comment 2', + /* datadog-privacy-allowlist-exclude-begin */ + `exclude range with unterminated comment 3`, +``` \ No newline at end of file From 7ff9deb179473e8f8cf13ac0c6eb2a22096a7686 Mon Sep 17 00:00:00 2001 From: cy-moi Date: Wed, 6 May 2026 13:11:23 +0200 Subject: [PATCH 2/2] Update with examples and doc links --- packages/plugins/rum/src/privacy/README.md | 45 +++++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/packages/plugins/rum/src/privacy/README.md b/packages/plugins/rum/src/privacy/README.md index b4380a52d..005098c2c 100644 --- a/packages/plugins/rum/src/privacy/README.md +++ b/packages/plugins/rum/src/privacy/README.md @@ -1,17 +1,19 @@ # RUM Privacy Plugin -The RUM Privacy Plugin provides action name and session replay masking capabilities for Real User Monitoring (RUM). This plugin helps protect sensitive data while maintaining observability. +The RUM Privacy Plugin provides action name and session replay masking capabilities for Real User Monitoring (RUM). This plugin helps protect sensitive data while maintaining observability. See [Action Name Deobfuscation](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/build_plugins/action_name_deobfuscation/). ## Use Cases This plugin is particularly useful for: + - Masking sensitive data **before** sending them to Datadog -- Providing an out-of-the-box solution with minimal instrumentation overhead +- Providing an out-of-the-box solution with minimal instrumentation overhead - Maintaining observability while ensuring privacy compliance ## Reserved Global Variables The following global variable is used by this plugin: + - `$DD_ALLOW` - Contains raw static strings from source code - `$DD_A_Q` - Manage the queue of adding to allowlist at runtime @@ -20,23 +22,52 @@ The following global variable is used by this plugin: ### Default Settings Excludes: + - `node_modules` directories - `.preval` files - Files that start with special characters Includes: -- files matching `/\.(?:c|m)?(?:j|t)sx?$/` +- files matching `/\.(?:c|m)?(?:j|t)sx?$/` + +To instantiate the plugin with default settings: + +```javascript +const { datadogWebpackPlugin } = require('@datadog/webpack-plugin'); + +module.exports = { + plugins: [ + datadogWebpackPlugin({ + rum: { + privacy: {}, + }, + }), + ], +}; +``` ### Overrides + You can override file inclusion/exclusion using regular expressions: ```javascript -exclude: [/packages\/apps\/mocks/] -include: [/packages\/apps\/.*\.(?:c|m)?(?:j|t)sx?$/], +module.exports = { + plugins: [ + datadogWebpackPlugin({ + rum: { + privacy: { + include: [/packages\/apps\/.*\.(?:c|m)?(?:j|t)sx?$/], + exclude: [/\/node_modules\//, /\/test\//], + }, + }, + }), + ], +}; ``` > Note: if you are overriding the default setting, please make sure that you are aligned with the default setting. ### Excluding Code Blocks with Comments + #### Single Line ```javascript @@ -51,6 +82,7 @@ include: [/packages\/apps\/.*\.(?:c|m)?(?:j|t)sx?$/], ``` #### Next Line + ```javascript // datadog-privacy-allowlist-exclude-next-line "exclude next line 1", @@ -65,6 +97,7 @@ include: [/packages\/apps\/.*\.(?:c|m)?(?:j|t)sx?$/], ``` #### Multi-line/Blocks + ```javascript // datadog-privacy-allowlist-exclude-begin "exclude range 1", @@ -86,4 +119,4 @@ include: [/packages\/apps\/.*\.(?:c|m)?(?:j|t)sx?$/], 'exclude range with unterminated comment 2', /* datadog-privacy-allowlist-exclude-begin */ `exclude range with unterminated comment 3`, -``` \ No newline at end of file +```