11import type { Duration , ClocksState , TimeStamp } from '@datadog/browser-core'
2- import { timeStampNow , Observable , timeStampToClocks , relativeToClocks , generateUUID } from '@datadog/browser-core'
2+ import {
3+ timeStampNow ,
4+ Observable ,
5+ timeStampToClocks ,
6+ relativeToClocks ,
7+ generateUUID ,
8+ isExperimentalFeatureEnabled ,
9+ ExperimentalFeature ,
10+ } from '@datadog/browser-core'
311import { isNodeShadowHost } from '../../browser/htmlDomUtils'
412import type { FrustrationType } from '../../rawRumEvent.types'
513import { ActionType } from '../../rawRumEvent.types'
@@ -13,6 +21,7 @@ import type { RumConfiguration } from '../configuration'
1321import type { RumMutationRecord } from '../../browser/domMutationObservable'
1422import { startEventTracker } from '../eventTracker'
1523import type { StoppedEvent , DiscardedEvent , EventTracker } from '../eventTracker'
24+ import { getComposedPathSelector } from '../getComposedPathSelector'
1625import type { ClickChain } from './clickChain'
1726import { createClickChain } from './clickChain'
1827import { getActionNameFromElement } from './getActionNameFromElement'
@@ -36,6 +45,7 @@ export interface ClickAction {
3645 nameSource : ActionNameSource
3746 target ?: {
3847 selector : string | undefined
48+ composed_path_selector ?: string
3949 width : number
4050 height : number
4151 }
@@ -231,9 +241,14 @@ function computeClickActionBase(
231241 nodePrivacyLevel : NodePrivacyLevel ,
232242 configuration : RumConfiguration
233243) : ClickActionBase {
244+ const eventPath = event . composedPath ( )
245+
234246 const selectorTarget = event . target
235247 const rect = selectorTarget . getBoundingClientRect ( )
236248 const selector = getSelectorFromElement ( selectorTarget , configuration . actionNameAttribute )
249+ const composedPathSelector = isExperimentalFeatureEnabled ( ExperimentalFeature . COMPOSED_PATH_SELECTOR )
250+ ? getComposedPathSelector ( eventPath , configuration . actionNameAttribute , configuration . allowedHtmlAttributes || [ ] )
251+ : undefined
237252
238253 if ( selector ) {
239254 updateInteractionSelector ( event . timeStamp , selector )
@@ -248,6 +263,7 @@ function computeClickActionBase(
248263 width : Math . round ( rect . width ) ,
249264 height : Math . round ( rect . height ) ,
250265 selector,
266+ composed_path_selector : composedPathSelector ?? undefined ,
251267 } ,
252268 position : {
253269 // Use clientX and Y because for SVG element offsetX and Y are relatives to the <svg> element
0 commit comments