Skip to content

Commit 0913df3

Browse files
committed
Add mask-unless-allowlisted privacy level support for standard attributes action names
1 parent bc54e3d commit 0913df3

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/rum-core/src/domain/action/getActionNameFromElement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function getActionNameFromStandardAttribute(
179179
const attributeValue = element.getAttribute(attribute)
180180
return {
181181
name:
182-
enablePrivacyForActionName && shouldMaskNode(element, nodeSelfPrivacyLevel)
182+
enablePrivacyForActionName && nodeSelfPrivacyLevel && shouldMaskNode(element, nodeSelfPrivacyLevel, false)
183183
? maskDisallowedTextContent(attributeValue || '', ACTION_NAME_PLACEHOLDER)
184184
: attributeValue || '',
185185
nameSource: ActionNameSource.STANDARD_ATTRIBUTE,

packages/rum-core/src/domain/privacy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,14 @@ export function getNodeSelfPrivacyLevel(node: Node): NodePrivacyLevel | undefine
128128
* Other `shouldMaskNode` cases are edge cases that should not matter too much (ex: should we mask a
129129
* node if it is ignored or hidden? it doesn't matter since it won't be serialized).
130130
*/
131-
export function shouldMaskNode(node: Node, privacyLevel: NodePrivacyLevel) {
131+
export function shouldMaskNode(node: Node, privacyLevel: NodePrivacyLevel, isTextContent: boolean = true) {
132132
switch (privacyLevel) {
133133
case NodePrivacyLevel.MASK:
134134
case NodePrivacyLevel.HIDDEN:
135135
case NodePrivacyLevel.IGNORE:
136136
return true
137137
case NodePrivacyLevel.MASK_UNLESS_ALLOWLISTED:
138+
if (!isTextContent) return true
138139
if (isTextNode(node)) {
139140
// Always return true if our parent is a form element, like MASK_USER_INPUT.
140141
// Otherwise, decide whether to mask based on the allowlist.

0 commit comments

Comments
 (0)