11import { ExperimentalFeature , isExperimentalFeatureEnabled , safeTruncate } from '@datadog/browser-core'
22import { getPrivacySelector , NodePrivacyLevel } from '../privacyConstants'
3- import { getNodePrivacyLevel , shouldMaskNode } from '../privacy'
3+ import { getNodePrivacyLevel , maskDisallowedTextContent , shouldMaskNode } from '../privacy'
44import type { NodePrivacyLevelCache } from '../privacy'
55import type { RumConfiguration } from '../configuration'
66import { isElementNode } from '../../browser/htmlDomUtils'
@@ -84,7 +84,7 @@ const priorityStrategies: NameStrategy[] = [
8484 return getActionNameFromTextualContent ( element , rumConfiguration )
8585 }
8686 } ,
87- ( element ) => getActionNameFromStandardAttribute ( element , 'aria-label' ) ,
87+ ( element , rumConfiguration ) => getActionNameFromStandardAttribute ( element , 'aria-label' , rumConfiguration ) ,
8888 // associated element text designated by the aria-labelledby attribute
8989 ( element , rumConfiguration ) => {
9090 const labelledByAttribute = element . getAttribute ( 'aria-labelledby' )
@@ -100,10 +100,10 @@ const priorityStrategies: NameStrategy[] = [
100100 }
101101 }
102102 } ,
103- ( element ) => getActionNameFromStandardAttribute ( element , 'alt' ) ,
104- ( element ) => getActionNameFromStandardAttribute ( element , 'name' ) ,
105- ( element ) => getActionNameFromStandardAttribute ( element , 'title' ) ,
106- ( element ) => getActionNameFromStandardAttribute ( element , 'placeholder' ) ,
103+ ( element , rumConfiguration ) => getActionNameFromStandardAttribute ( element , 'alt' , rumConfiguration ) ,
104+ ( element , rumConfiguration ) => getActionNameFromStandardAttribute ( element , 'name' , rumConfiguration ) ,
105+ ( element , rumConfiguration ) => getActionNameFromStandardAttribute ( element , 'title' , rumConfiguration ) ,
106+ ( element , rumConfiguration ) => getActionNameFromStandardAttribute ( element , 'placeholder' , rumConfiguration ) ,
107107 // SELECT first OPTION text
108108 ( element , rumConfiguration ) => {
109109 if ( 'options' in element && element . options . length > 0 ) {
@@ -169,9 +169,19 @@ function getElementById(refElement: Element, id: string) {
169169 return refElement . ownerDocument ? refElement . ownerDocument . getElementById ( id ) : null
170170}
171171
172- function getActionNameFromStandardAttribute ( element : Element | HTMLElement , attribute : string ) : ActionName {
172+ function getActionNameFromStandardAttribute (
173+ element : Element | HTMLElement ,
174+ attribute : string ,
175+ rumConfiguration : RumConfiguration
176+ ) : ActionName {
177+ const { enablePrivacyForActionName, defaultPrivacyLevel } = rumConfiguration
178+ const nodeSelfPrivacyLevel = getNodePrivacyLevel ( element , defaultPrivacyLevel )
179+ const attributeValue = element . getAttribute ( attribute )
173180 return {
174- name : element . getAttribute ( attribute ) || '' ,
181+ name :
182+ enablePrivacyForActionName && nodeSelfPrivacyLevel === NodePrivacyLevel . MASK_UNLESS_ALLOWLISTED
183+ ? maskDisallowedTextContent ( attributeValue || '' , ACTION_NAME_PLACEHOLDER )
184+ : attributeValue || '' ,
175185 nameSource : ActionNameSource . STANDARD_ATTRIBUTE ,
176186 }
177187}
0 commit comments