|
1 |
| -import { ExperimentalFeature, isExperimentalFeatureEnabled, safeTruncate } from '@datadog/browser-core' |
| 1 | +import { |
| 2 | + addTelemetryDebug, |
| 3 | + ExperimentalFeature, |
| 4 | + isExperimentalFeatureEnabled, |
| 5 | + safeTruncate, |
| 6 | +} from '@datadog/browser-core' |
2 | 7 | import { getNodeSelfPrivacyLevel, getPrivacySelector, NodePrivacyLevel, shouldMaskNode } from '../privacy'
|
3 | 8 | import type { RumConfiguration } from '../configuration'
|
4 | 9 | import { isElementNode } from '../../browser/htmlDomUtils'
|
@@ -214,10 +219,6 @@ function getTextualContent(
|
214 | 219 | return
|
215 | 220 | }
|
216 | 221 |
|
217 |
| - if (isExperimentalFeatureEnabled(ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME)) { |
218 |
| - return getTextualContentWithTreeWalker(element, userProgrammaticAttribute, privacyEnabledActionName) |
219 |
| - } |
220 |
| - |
221 | 222 | if ('innerText' in element) {
|
222 | 223 | let text = (element as HTMLElement).innerText
|
223 | 224 |
|
@@ -248,6 +249,18 @@ function getTextualContent(
|
248 | 249 | )
|
249 | 250 | }
|
250 | 251 |
|
| 252 | + if (isExperimentalFeatureEnabled(ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME)) { |
| 253 | + const treeWalkerText = getTextualContentWithTreeWalker( |
| 254 | + element, |
| 255 | + userProgrammaticAttribute, |
| 256 | + privacyEnabledActionName |
| 257 | + ) |
| 258 | + if (treeWalkerText !== text.replace(/\s+/g, ' ').trim()) { |
| 259 | + addTelemetryDebug('tree-walker-text-diff', { text, treeWalkerText }) |
| 260 | + } |
| 261 | + return treeWalkerText |
| 262 | + } |
| 263 | + |
251 | 264 | return text
|
252 | 265 | }
|
253 | 266 |
|
|
0 commit comments