Skip to content

Commit 9fee568

Browse files
cy-moiBenoitZugmeyer
authored andcommitted
Remove FF of use_treewalker_for_action_name and make it the default approach
1 parent 4212054 commit 9fee568

File tree

4 files changed

+9
-57
lines changed

4 files changed

+9
-57
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
START_STOP_ACTION = 'start_stop_action',

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { addExperimentalFeatures, ExperimentalFeature } from '@datadog/browser-core'
21
import { appendElement, mockRumConfiguration } from '../../../test'
32
import { NodePrivacyLevel } from '../privacyConstants'
43
import { getNodeSelfPrivacyLevel } from '../privacy'
@@ -114,7 +113,6 @@ describe('getActionNameFromElement', () => {
114113
})
115114

116115
it('should introduce whitespace for block-level display values', () => {
117-
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
118116
const testCases = [
119117
{ display: 'block', expected: 'space' },
120118
{ display: 'inline-block', expected: 'no-space' },
@@ -483,7 +481,6 @@ describe('getActionNameFromElement', () => {
483481
})
484482

485483
it('removes only the child with programmatic action name in textual content', () => {
486-
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
487484
const { name, nameSource } = getActionNameFromElement(
488485
appendElement('<div>Foobar Baz<div data-dd-action-name="custom action">bar<div></div>'),
489486
defaultConfiguration
@@ -511,7 +508,6 @@ describe('getActionNameFromElement', () => {
511508
}
512509

513510
it('preserves privacy level of the element when defaultPrivacyLevel is mask-unless-allowlisted', () => {
514-
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
515511
const { name, nameSource } = getActionNameFromElement(
516512
appendElement(`
517513
<div data-dd-privacy="mask">
@@ -665,7 +661,6 @@ describe('getActionNameFromElement', () => {
665661
},
666662
]
667663
testCases.forEach(({ html, defaultPrivacyLevel, allowlist, expectedName, expectedNameSource }) => {
668-
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
669664
;(window as BrowserWindow).$DD_ALLOW = new Set(allowlist)
670665
const target = appendElement(html)
671666
const { name, nameSource } = getActionNameFromElement(
@@ -882,7 +877,6 @@ describe('getActionNameFromElement', () => {
882877
})
883878

884879
it('inherit privacy level and remove only the masked child', () => {
885-
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
886880
expect(
887881
getActionNameFromElement(
888882
appendElement(`

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

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ExperimentalFeature, isExperimentalFeatureEnabled, safeTruncate } from '@datadog/browser-core'
2-
import { getPrivacySelector, NodePrivacyLevel } from '../privacyConstants'
1+
import { safeTruncate } from '@datadog/browser-core'
2+
import { NodePrivacyLevel } from '../privacyConstants'
33
import { getNodePrivacyLevel, maskDisallowedTextContent, shouldMaskNode, shouldMaskAttribute } from '../privacy'
44
import type { NodePrivacyLevelCache } from '../privacy'
55
import type { RumConfiguration } from '../configuration'
@@ -247,50 +247,13 @@ function getTextualContent(
247247
defaultPrivacyLevel,
248248
} = rumConfiguration
249249

250-
if (isExperimentalFeatureEnabled(ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME)) {
251-
return getTextualContentWithTreeWalker(
252-
element,
253-
userProgrammaticAttribute,
254-
enablePrivacyForActionName,
255-
defaultPrivacyLevel,
256-
nodePrivacyLevelCache
257-
)
258-
}
259-
260-
if ('innerText' in element) {
261-
let text = (element as HTMLElement).innerText
262-
263-
const removeTextFromElements = (query: string) => {
264-
const list = element.querySelectorAll<Element | HTMLElement>(query)
265-
for (let index = 0; index < list.length; index += 1) {
266-
const element = list[index]
267-
if ('innerText' in element) {
268-
const textToReplace = element.innerText
269-
if (textToReplace && textToReplace.trim().length > 0) {
270-
text = text.replace(textToReplace, '')
271-
}
272-
}
273-
}
274-
}
275-
276-
// remove the text of elements with programmatic attribute value
277-
removeTextFromElements(`[${DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE}]`)
278-
279-
if (userProgrammaticAttribute) {
280-
removeTextFromElements(`[${userProgrammaticAttribute}]`)
281-
}
282-
283-
if (enablePrivacyForActionName) {
284-
// remove the text of elements with privacy override
285-
removeTextFromElements(
286-
`${getPrivacySelector(NodePrivacyLevel.HIDDEN)}, ${getPrivacySelector(NodePrivacyLevel.MASK)}`
287-
)
288-
}
289-
290-
return text
291-
}
292-
293-
return element.textContent
250+
return getTextualContentWithTreeWalker(
251+
element,
252+
userProgrammaticAttribute,
253+
enablePrivacyForActionName,
254+
defaultPrivacyLevel,
255+
nodePrivacyLevelCache
256+
)
294257
}
295258

296259
function getTextualContentWithTreeWalker(

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import {
66
relativeNow,
77
DefaultPrivacyLevel,
88
Observable,
9-
ExperimentalFeature,
109
PageExitReason,
11-
addExperimentalFeatures,
1210
} from '@datadog/browser-core'
1311
import type { Clock } from '@datadog/browser-core/test'
1412
import { createNewEvent, mockClock } from '@datadog/browser-core/test'
@@ -479,7 +477,6 @@ describe('trackClickActions', () => {
479477
})
480478

481479
it('should mask action name when defaultPrivacyLevel is mask_unless_allowlisted and not in allowlist', () => {
482-
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
483480
startClickActionsTracking({
484481
defaultPrivacyLevel: DefaultPrivacyLevel.MASK_UNLESS_ALLOWLISTED,
485482
enablePrivacyForActionName: true,
@@ -524,7 +521,6 @@ describe('trackClickActions', () => {
524521
})
525522

526523
it('should use allowlist masking when defaultPrivacyLevel is allow and node privacy level is mask-unless-allowlisted', () => {
527-
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
528524
button.setAttribute('data-dd-privacy', 'mask-unless-allowlisted')
529525
startClickActionsTracking({
530526
defaultPrivacyLevel: DefaultPrivacyLevel.ALLOW,

0 commit comments

Comments
 (0)