diff --git a/packages/core/src/tools/experimentalFeatures.ts b/packages/core/src/tools/experimentalFeatures.ts index 9ef9342936..32c73de5f4 100644 --- a/packages/core/src/tools/experimentalFeatures.ts +++ b/packages/core/src/tools/experimentalFeatures.ts @@ -15,7 +15,6 @@ import { objectHasValue } from './utils/objectUtils' // eslint-disable-next-line no-restricted-syntax export enum ExperimentalFeature { TRACK_INTAKE_REQUESTS = 'track_intake_requests', - USE_TREE_WALKER_FOR_ACTION_NAME = 'use_tree_walker_for_action_name', FEATURE_OPERATION_VITAL = 'feature_operation_vital', SHORT_SESSION_INVESTIGATION = 'short_session_investigation', AVOID_FETCH_KEEPALIVE = 'avoid_fetch_keepalive', diff --git a/packages/rum-core/src/domain/action/getActionNameFromElement.spec.ts b/packages/rum-core/src/domain/action/getActionNameFromElement.spec.ts index 8a3c03b403..ef2542eeea 100644 --- a/packages/rum-core/src/domain/action/getActionNameFromElement.spec.ts +++ b/packages/rum-core/src/domain/action/getActionNameFromElement.spec.ts @@ -1,5 +1,3 @@ -import { ExperimentalFeature } from '@datadog/browser-core' -import { mockExperimentalFeatures } from '../../../../core/test' import { appendElement, mockRumConfiguration } from '../../../test' import { NodePrivacyLevel } from '../privacyConstants' import { getNodeSelfPrivacyLevel } from '../privacy' @@ -115,7 +113,6 @@ describe('getActionNameFromElement', () => { }) it('should introduce whitespace for block-level display values', () => { - mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME]) const testCases = [ { display: 'block', expected: 'space' }, { display: 'inline-block', expected: 'no-space' }, @@ -484,7 +481,6 @@ describe('getActionNameFromElement', () => { }) it('removes only the child with programmatic action name in textual content', () => { - mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME]) const { name, nameSource } = getActionNameFromElement( appendElement('
Foobar Baz
bar
'), defaultConfiguration @@ -512,7 +508,6 @@ describe('getActionNameFromElement', () => { } it('preserves privacy level of the element when defaultPrivacyLevel is mask-unless-allowlisted', () => { - mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME]) const { name, nameSource } = getActionNameFromElement( appendElement(`
@@ -666,7 +661,6 @@ describe('getActionNameFromElement', () => { }, ] testCases.forEach(({ html, defaultPrivacyLevel, allowlist, expectedName, expectedNameSource }) => { - mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME]) ;(window as BrowserWindow).$DD_ALLOW = new Set(allowlist) const target = appendElement(html) const { name, nameSource } = getActionNameFromElement( @@ -883,7 +877,6 @@ describe('getActionNameFromElement', () => { }) it('inherit privacy level and remove only the masked child', () => { - mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME]) expect( getActionNameFromElement( appendElement(` diff --git a/packages/rum-core/src/domain/action/getActionNameFromElement.ts b/packages/rum-core/src/domain/action/getActionNameFromElement.ts index 0c937cca65..6bddb042cc 100644 --- a/packages/rum-core/src/domain/action/getActionNameFromElement.ts +++ b/packages/rum-core/src/domain/action/getActionNameFromElement.ts @@ -1,5 +1,5 @@ -import { ExperimentalFeature, isExperimentalFeatureEnabled, safeTruncate } from '@datadog/browser-core' -import { getPrivacySelector, NodePrivacyLevel } from '../privacyConstants' +import { safeTruncate } from '@datadog/browser-core' +import { NodePrivacyLevel } from '../privacyConstants' import { getNodePrivacyLevel, maskDisallowedTextContent, shouldMaskNode, shouldMaskAttribute } from '../privacy' import type { NodePrivacyLevelCache } from '../privacy' import type { RumConfiguration } from '../configuration' @@ -228,50 +228,13 @@ function getTextualContent( defaultPrivacyLevel, } = rumConfiguration - if (isExperimentalFeatureEnabled(ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME)) { - return getTextualContentWithTreeWalker( - element, - userProgrammaticAttribute, - enablePrivacyForActionName, - defaultPrivacyLevel, - nodePrivacyLevelCache - ) - } - - if ('innerText' in element) { - let text = (element as HTMLElement).innerText - - const removeTextFromElements = (query: string) => { - const list = element.querySelectorAll(query) - for (let index = 0; index < list.length; index += 1) { - const element = list[index] - if ('innerText' in element) { - const textToReplace = element.innerText - if (textToReplace && textToReplace.trim().length > 0) { - text = text.replace(textToReplace, '') - } - } - } - } - - // remove the text of elements with programmatic attribute value - removeTextFromElements(`[${DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE}]`) - - if (userProgrammaticAttribute) { - removeTextFromElements(`[${userProgrammaticAttribute}]`) - } - - if (enablePrivacyForActionName) { - // remove the text of elements with privacy override - removeTextFromElements( - `${getPrivacySelector(NodePrivacyLevel.HIDDEN)}, ${getPrivacySelector(NodePrivacyLevel.MASK)}` - ) - } - - return text - } - - return element.textContent + return getTextualContentWithTreeWalker( + element, + userProgrammaticAttribute, + enablePrivacyForActionName, + defaultPrivacyLevel, + nodePrivacyLevelCache + ) } function getTextualContentWithTreeWalker( diff --git a/packages/rum-core/src/domain/action/trackClickActions.spec.ts b/packages/rum-core/src/domain/action/trackClickActions.spec.ts index 1df93934b4..d53faca5d9 100644 --- a/packages/rum-core/src/domain/action/trackClickActions.spec.ts +++ b/packages/rum-core/src/domain/action/trackClickActions.spec.ts @@ -6,10 +6,9 @@ import { relativeNow, DefaultPrivacyLevel, Observable, - ExperimentalFeature, } from '@datadog/browser-core' import type { Clock } from '@datadog/browser-core/test' -import { createNewEvent, mockClock, mockExperimentalFeatures } from '@datadog/browser-core/test' +import { createNewEvent, mockClock } from '@datadog/browser-core/test' import { createFakeClick, createMutationRecord, mockRumConfiguration } from '../../../test' import type { AssembledRumEvent } from '../../rawRumEvent.types' import { RumEventType, ActionType, FrustrationType } from '../../rawRumEvent.types' @@ -460,7 +459,6 @@ describe('trackClickActions', () => { }) it('should mask action name when defaultPrivacyLevel is mask_unless_allowlisted and not in allowlist', () => { - mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME]) startClickActionsTracking({ defaultPrivacyLevel: DefaultPrivacyLevel.MASK_UNLESS_ALLOWLISTED, enablePrivacyForActionName: true, @@ -505,7 +503,6 @@ describe('trackClickActions', () => { }) it('should use allowlist masking when defaultPrivacyLevel is allow and node privacy level is mask-unless-allowlisted', () => { - mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME]) button.setAttribute('data-dd-privacy', 'mask-unless-allowlisted') startClickActionsTracking({ defaultPrivacyLevel: DefaultPrivacyLevel.ALLOW,