Skip to content

Commit c6da46a

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

File tree

4 files changed

+10
-58
lines changed

4 files changed

+10
-58
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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { ExperimentalFeature } from '@datadog/browser-core'
2-
import { mockExperimentalFeatures } from '../../../../core/test'
31
import { appendElement, mockRumConfiguration } from '../../../test'
42
import { NodePrivacyLevel } from '../privacyConstants'
53
import { getNodeSelfPrivacyLevel } from '../privacy'
@@ -115,7 +113,6 @@ describe('getActionNameFromElement', () => {
115113
})
116114

117115
it('should introduce whitespace for block-level display values', () => {
118-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
119116
const testCases = [
120117
{ display: 'block', expected: 'space' },
121118
{ display: 'inline-block', expected: 'no-space' },
@@ -484,7 +481,6 @@ describe('getActionNameFromElement', () => {
484481
})
485482

486483
it('removes only the child with programmatic action name in textual content', () => {
487-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
488484
const { name, nameSource } = getActionNameFromElement(
489485
appendElement('<div>Foobar Baz<div data-dd-action-name="custom action">bar<div></div>'),
490486
defaultConfiguration
@@ -512,7 +508,6 @@ describe('getActionNameFromElement', () => {
512508
}
513509

514510
it('preserves privacy level of the element when defaultPrivacyLevel is mask-unless-allowlisted', () => {
515-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
516511
const { name, nameSource } = getActionNameFromElement(
517512
appendElement(`
518513
<div data-dd-privacy="mask">
@@ -666,7 +661,6 @@ describe('getActionNameFromElement', () => {
666661
},
667662
]
668663
testCases.forEach(({ html, defaultPrivacyLevel, allowlist, expectedName, expectedNameSource }) => {
669-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
670664
;(window as BrowserWindow).$DD_ALLOW = new Set(allowlist)
671665
const target = appendElement(html)
672666
const { name, nameSource } = getActionNameFromElement(
@@ -883,7 +877,6 @@ describe('getActionNameFromElement', () => {
883877
})
884878

885879
it('inherit privacy level and remove only the masked child', () => {
886-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
887880
expect(
888881
getActionNameFromElement(
889882
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'
@@ -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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import {
66
relativeNow,
77
DefaultPrivacyLevel,
88
Observable,
9-
ExperimentalFeature,
109
} from '@datadog/browser-core'
1110
import type { Clock } from '@datadog/browser-core/test'
12-
import { createNewEvent, mockClock, mockExperimentalFeatures } from '@datadog/browser-core/test'
11+
import { createNewEvent, mockClock } from '@datadog/browser-core/test'
1312
import { createFakeClick, createMutationRecord, mockRumConfiguration } from '../../../test'
1413
import type { AssembledRumEvent } from '../../rawRumEvent.types'
1514
import { RumEventType, ActionType, FrustrationType } from '../../rawRumEvent.types'
@@ -460,7 +459,6 @@ describe('trackClickActions', () => {
460459
})
461460

462461
it('should mask action name when defaultPrivacyLevel is mask_unless_allowlisted and not in allowlist', () => {
463-
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
464462
startClickActionsTracking({
465463
defaultPrivacyLevel: DefaultPrivacyLevel.MASK_UNLESS_ALLOWLISTED,
466464
enablePrivacyForActionName: true,
@@ -505,7 +503,6 @@ describe('trackClickActions', () => {
505503
})
506504

507505
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])
509506
button.setAttribute('data-dd-privacy', 'mask-unless-allowlisted')
510507
startClickActionsTracking({
511508
defaultPrivacyLevel: DefaultPrivacyLevel.ALLOW,

0 commit comments

Comments
 (0)