Skip to content

Commit 4c2d9ec

Browse files
committed
Remove FF of use_treewalker_for_action_name and make it the default approach
1 parent a0e402e commit 4c2d9ec

File tree

4 files changed

+7
-52
lines changed

4 files changed

+7
-52
lines changed

packages/core/src/tools/experimentalFeatures.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { objectHasValue } from './utils/objectUtils'
1515
// eslint-disable-next-line no-restricted-syntax
1616
export enum ExperimentalFeature {
1717
TRACK_INTAKE_REQUESTS = 'track_intake_requests',
18-
USE_TREE_WALKER_FOR_ACTION_NAME = 'use_tree_walker_for_action_name',
1918
FEATURE_OPERATION_VITAL = 'feature_operation_vital',
2019
SHORT_SESSION_INVESTIGATION = 'short_session_investigation',
2120
AVOID_FETCH_KEEPALIVE = 'avoid_fetch_keepalive',

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ describe('getActionNameFromElement', () => {
115115
})
116116

117117
it('should introduce whitespace for block-level display values', () => {
118-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
119118
const testCases = [
120119
{ display: 'block', expected: 'space' },
121120
{ display: 'inline-block', expected: 'no-space' },
@@ -484,7 +483,6 @@ describe('getActionNameFromElement', () => {
484483
})
485484

486485
it('removes only the child with programmatic action name in textual content', () => {
487-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
488486
const { name, nameSource } = getActionNameFromElement(
489487
appendElement('<div>Foobar Baz<div data-dd-action-name="custom action">bar<div></div>'),
490488
defaultConfiguration
@@ -512,7 +510,6 @@ describe('getActionNameFromElement', () => {
512510
}
513511

514512
it('preserves privacy level of the element when defaultPrivacyLevel is mask-unless-allowlisted', () => {
515-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
516513
const { name, nameSource } = getActionNameFromElement(
517514
appendElement(`
518515
<div data-dd-privacy="mask">
@@ -666,7 +663,6 @@ describe('getActionNameFromElement', () => {
666663
},
667664
]
668665
testCases.forEach(({ html, defaultPrivacyLevel, allowlist, expectedName, expectedNameSource }) => {
669-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
670666
;(window as BrowserWindow).$DD_ALLOW = new Set(allowlist)
671667
const target = appendElement(html)
672668
const { name, nameSource } = getActionNameFromElement(
@@ -883,7 +879,6 @@ describe('getActionNameFromElement', () => {
883879
})
884880

885881
it('inherit privacy level and remove only the masked child', () => {
886-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
887882
expect(
888883
getActionNameFromElement(
889884
appendElement(`

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

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -228,50 +228,13 @@ function getTextualContent(
228228
defaultPrivacyLevel,
229229
} = rumConfiguration
230230

231-
if (isExperimentalFeatureEnabled(ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME)) {
232-
return getTextualContentWithTreeWalker(
233-
element,
234-
userProgrammaticAttribute,
235-
enablePrivacyForActionName,
236-
defaultPrivacyLevel,
237-
nodePrivacyLevelCache
238-
)
239-
}
240-
241-
if ('innerText' in element) {
242-
let text = (element as HTMLElement).innerText
243-
244-
const removeTextFromElements = (query: string) => {
245-
const list = element.querySelectorAll<Element | HTMLElement>(query)
246-
for (let index = 0; index < list.length; index += 1) {
247-
const element = list[index]
248-
if ('innerText' in element) {
249-
const textToReplace = element.innerText
250-
if (textToReplace && textToReplace.trim().length > 0) {
251-
text = text.replace(textToReplace, '')
252-
}
253-
}
254-
}
255-
}
256-
257-
// remove the text of elements with programmatic attribute value
258-
removeTextFromElements(`[${DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE}]`)
259-
260-
if (userProgrammaticAttribute) {
261-
removeTextFromElements(`[${userProgrammaticAttribute}]`)
262-
}
263-
264-
if (enablePrivacyForActionName) {
265-
// remove the text of elements with privacy override
266-
removeTextFromElements(
267-
`${getPrivacySelector(NodePrivacyLevel.HIDDEN)}, ${getPrivacySelector(NodePrivacyLevel.MASK)}`
268-
)
269-
}
270-
271-
return text
272-
}
273-
274-
return element.textContent
231+
return getTextualContentWithTreeWalker(
232+
element,
233+
userProgrammaticAttribute,
234+
enablePrivacyForActionName,
235+
defaultPrivacyLevel,
236+
nodePrivacyLevelCache
237+
)
275238
}
276239

277240
function getTextualContentWithTreeWalker(

packages/rum-core/src/domain/action/trackClickActions.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ describe('trackClickActions', () => {
460460
})
461461

462462
it('should mask action name when defaultPrivacyLevel is mask_unless_allowlisted and not in allowlist', () => {
463-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
464463
startClickActionsTracking({
465464
defaultPrivacyLevel: DefaultPrivacyLevel.MASK_UNLESS_ALLOWLISTED,
466465
enablePrivacyForActionName: true,
@@ -505,7 +504,6 @@ describe('trackClickActions', () => {
505504
})
506505

507506
it('should use allowlist masking when defaultPrivacyLevel is allow and node privacy level is mask-unless-allowlisted', () => {
508-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
509507
button.setAttribute('data-dd-privacy', 'mask-unless-allowlisted')
510508
startClickActionsTracking({
511509
defaultPrivacyLevel: DefaultPrivacyLevel.ALLOW,

0 commit comments

Comments
 (0)