Skip to content

Commit

Permalink
Add feature flag and rephrase code
Browse files Browse the repository at this point in the history
  • Loading branch information
cy-moi committed Nov 14, 2024
1 parent 84a1fa1 commit ce77be2
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 77 deletions.
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',
namingSource: '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',
namingSource: '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.namingSource
: undefined,
},
},
}
Expand Down
Loading

0 comments on commit ce77be2

Please sign in to comment.