Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [RUM-6956] Add action name source #3115

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/tools/experimentalFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export enum ExperimentalFeature {
REMOTE_CONFIGURATION = 'remote_configuration',
UPDATE_VIEW_NAME = 'update_view_name',
LONG_ANIMATION_FRAME = 'long_animation_frame',
ACTION_NAME_MASKING = 'action_name_masking',
}

const enabledExperimentalFeatures: Set<ExperimentalFeature> = new Set()
Expand Down
10 changes: 7 additions & 3 deletions packages/rum-core/src/domain/action/actionCollection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Duration, RelativeTime, ServerDuration, TimeStamp } from '@datadog/browser-core'
import { Observable } from '@datadog/browser-core'
import { createNewEvent } from '@datadog/browser-core/test'
import { ExperimentalFeature, Observable } from '@datadog/browser-core'
import { createNewEvent, mockExperimentalFeatures } from '@datadog/browser-core/test'
import type { RawRumActionEvent, RawRumEventCollectedData } from '@datadog/browser-rum-core'
import { collectAndValidateRawRumEvents, mockPageStateHistory, mockRumConfiguration } from '../../../test'
import type { RawRumEvent } from '../../rawRumEvent.types'
Expand Down Expand Up @@ -28,7 +28,8 @@ describe('actionCollection', () => {
rawRumEvents = collectAndValidateRawRumEvents(lifeCycle)
})

it('should create action from auto action', () => {
it('should create action from auto action with name source', () => {
mockExperimentalFeatures([ExperimentalFeature.ACTION_NAME_MASKING])
const event = createNewEvent('pointerup', { target: document.createElement('button') })
lifeCycle.notify(LifeCycleEventType.AUTO_ACTION_COMPLETED, {
counts: {
Expand All @@ -40,6 +41,7 @@ describe('actionCollection', () => {
duration: 100 as Duration,
id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
name: 'foo',
nameSource: 'text_content',
startClocks: { relative: 1234 as RelativeTime, timeStamp: 123456789 as TimeStamp },
type: ActionType.CLICK,
event,
Expand Down Expand Up @@ -86,6 +88,7 @@ describe('actionCollection', () => {
width: 1,
height: 2,
},
name_source: 'text_content',
position: {
x: 1,
y: 2,
Expand Down Expand Up @@ -136,6 +139,7 @@ describe('actionCollection', () => {
frustrationTypes: [],
id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
name: 'foo',
nameSource: 'text_content',
startClocks: { relative: 0 as RelativeTime, timeStamp: 0 as TimeStamp },
type: ActionType.CLICK,
})
Expand Down
13 changes: 12 additions & 1 deletion packages/rum-core/src/domain/action/actionCollection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import type { ClocksState, Context, Observable } from '@datadog/browser-core'
import { noop, assign, combine, toServerDuration, generateUUID } from '@datadog/browser-core'
import {
noop,
assign,
combine,
toServerDuration,
generateUUID,
ExperimentalFeature,
isExperimentalFeatureEnabled,
} from '@datadog/browser-core'

import { discardNegativeDuration } from '../discardNegativeDuration'
import type { RawRumActionEvent } from '../../rawRumEvent.types'
Expand Down Expand Up @@ -83,6 +91,9 @@ function processAction(
action: {
target: action.target,
position: action.position,
name_source: isExperimentalFeatureEnabled(ExperimentalFeature.ACTION_NAME_MASKING)
? action.nameSource
: undefined,
},
},
}
Expand Down
Loading