Skip to content
Merged
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
10 changes: 1 addition & 9 deletions packages/core/src/domain/configuration/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import type { RumEvent } from '../../../../rum-core/src'
import { EXHAUSTIVE_INIT_CONFIGURATION, SERIALIZED_EXHAUSTIVE_INIT_CONFIGURATION } from '../../../test'
import type { ExtractTelemetryConfiguration, MapInitConfigurationKey } from '../../../test'
import { DOCS_ORIGIN, MORE_DETAILS, display } from '../../tools/display'
import {
ExperimentalFeature,
isExperimentalFeatureEnabled,
resetExperimentalFeatures,
} from '../../tools/experimentalFeatures'
import { ExperimentalFeature, isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures'
import { SessionPersistence } from '../session/sessionConstants'
import { TrackingConsent } from '../trackingConsent'
import type { InitConfiguration } from './configuration'
Expand All @@ -21,10 +17,6 @@ describe('validateAndBuildConfiguration', () => {
displaySpy = spyOn(display, 'error')
})

afterEach(() => {
resetExperimentalFeatures()
})

describe('experimentalFeatures', () => {
const TEST_FEATURE_FLAG = 'foo' as ExperimentalFeature

Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/domain/telemetry/telemetry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { TimeStamp } from '@datadog/browser-rum/internal'
import { NO_ERROR_STACK_PRESENT_MESSAGE } from '../error/error'
import { callMonitored } from '../../tools/monitor'
import type { ExperimentalFeature } from '../../tools/experimentalFeatures'
import { resetExperimentalFeatures, addExperimentalFeatures } from '../../tools/experimentalFeatures'
import { addExperimentalFeatures } from '../../tools/experimentalFeatures'
import { validateAndBuildConfiguration, type Configuration } from '../configuration'
import { INTAKE_SITE_US1_FED, INTAKE_SITE_US1 } from '../intakeSites'
import {
Expand Down Expand Up @@ -87,10 +87,6 @@ describe('telemetry', () => {
})

describe('addTelemetryConfiguration', () => {
afterEach(() => {
resetExperimentalFeatures()
})

it('should collects configuration when sampled', async () => {
const { getTelemetryEvents } = startAndSpyTelemetry({
telemetrySampleRate: 100,
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export { TrackingConsent, createTrackingConsentState } from './domain/trackingCo
export {
isExperimentalFeatureEnabled,
addExperimentalFeatures,
resetExperimentalFeatures,
getExperimentalFeatures,
initFeatureFlags,
ExperimentalFeature,
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/tools/experimentalFeatures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ import {
addExperimentalFeatures,
initFeatureFlags,
isExperimentalFeatureEnabled,
resetExperimentalFeatures,
} from './experimentalFeatures'

const TEST_FEATURE_FLAG_ONE = 'foo' as ExperimentalFeature
const TEST_FEATURE_FLAG_TWO = 'bar' as ExperimentalFeature

describe('experimentalFeatures', () => {
afterEach(() => {
resetExperimentalFeatures()
})

it('initial state is empty', () => {
expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_ONE)).toBeFalse()
expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_TWO)).toBeFalse()
Expand Down Expand Up @@ -41,7 +36,6 @@ describe('initFeatureFlags', () => {

afterEach(() => {
delete (ExperimentalFeature as any).FOO
resetExperimentalFeatures()
})

it('ignores unknown experimental features', () => {
Expand Down
11 changes: 0 additions & 11 deletions packages/core/test/emulate/mockExperimentalFeatures.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/core/test/forEach.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { resetExperimentalFeatures } from '../src/tools/experimentalFeatures'
import { resetValueHistoryGlobals } from '../src/tools/valueHistory'
import { resetFetchObservable } from '../src/browser/fetchObservable'
import { resetConsoleObservable } from '../src/domain/console/consoleObservable'
Expand Down Expand Up @@ -35,6 +36,7 @@ afterEach(() => {
resetMonitor()
resetTelemetry()
resetInteractionCountPolyfill()
resetExperimentalFeatures()
})

function clearAllCookies() {
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export * from './emulate/mockVisibilityState'
export * from './emulate/mockNavigator'
export * from './emulate/mockEventBridge'
export * from './emulate/mockFlushController'
export * from './emulate/mockExperimentalFeatures'
export * from './emulate/mockFetch'
export * from './emulate/mockXhr'
export * from './emulate/mockEventTarget'
Expand Down
4 changes: 2 additions & 2 deletions packages/rum-core/src/boot/preStartRum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DefaultPrivacyLevel,
ExperimentalFeature,
startTelemetry,
addExperimentalFeatures,
} from '@datadog/browser-core'
import type { Clock } from '@datadog/browser-core/test'
import {
Expand All @@ -18,7 +19,6 @@ import {
mockClock,
mockEventBridge,
mockSyntheticsWorkerValues,
mockExperimentalFeatures,
createFakeTelemetryObject,
replaceMockableWithSpy,
} from '@datadog/browser-core/test'
Expand Down Expand Up @@ -686,7 +686,7 @@ describe('preStartRum', () => {
})

it('startAction / stopAction', () => {
mockExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])

const startActionSpy = jasmine.createSpy()
const stopActionSpy = jasmine.createSpy()
Expand Down
16 changes: 6 additions & 10 deletions packages/rum-core/src/boot/rumPublicApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ import {
ExperimentalFeature,
ResourceType,
startTelemetry,
addExperimentalFeatures,
} from '@datadog/browser-core'
import type { Clock } from '@datadog/browser-core/test'
import {
createFakeTelemetryObject,
mockClock,
mockExperimentalFeatures,
replaceMockableWithSpy,
} from '@datadog/browser-core/test'
import { createFakeTelemetryObject, mockClock, replaceMockableWithSpy } from '@datadog/browser-core/test'
import { noopRecorderApi, noopProfilerApi } from '../../test'
import { ActionType, VitalType } from '../rawRumEvent.types'
import type { DurationVitalReference } from '../domain/vital/vitalCollection'
Expand Down Expand Up @@ -742,7 +738,7 @@ describe('rum public api', () => {

describe('startAction / stopAction', () => {
it('should call startAction and stopAction on the strategy', () => {
mockExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])

const startActionSpy = jasmine.createSpy()
const stopActionSpy = jasmine.createSpy()
Expand Down Expand Up @@ -778,7 +774,7 @@ describe('rum public api', () => {
})

it('should sanitize startAction and stopAction inputs', () => {
mockExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])

const startActionSpy = jasmine.createSpy()
const { rumPublicApi } = makeRumPublicApiWithDefaults({
Expand Down Expand Up @@ -824,7 +820,7 @@ describe('rum public api', () => {

describe('startResource / stopResource', () => {
it('should call startResource and stopResource on the strategy', () => {
mockExperimentalFeatures([ExperimentalFeature.START_STOP_RESOURCE])
addExperimentalFeatures([ExperimentalFeature.START_STOP_RESOURCE])

const startResourceSpy = jasmine.createSpy()
const stopResourceSpy = jasmine.createSpy()
Expand Down Expand Up @@ -864,7 +860,7 @@ describe('rum public api', () => {
})

it('should sanitize startResource and stopResource inputs', () => {
mockExperimentalFeatures([ExperimentalFeature.START_STOP_RESOURCE])
addExperimentalFeatures([ExperimentalFeature.START_STOP_RESOURCE])

const startResourceSpy = jasmine.createSpy()
const { rumPublicApi } = makeRumPublicApiWithDefaults({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExperimentalFeature } from '@datadog/browser-core'
import { mockExperimentalFeatures } from '../../../../core/test'
import { addExperimentalFeatures, ExperimentalFeature } from '@datadog/browser-core'
import { appendElement, mockRumConfiguration } from '../../../test'
import { NodePrivacyLevel } from '../privacyConstants'
import { getNodeSelfPrivacyLevel } from '../privacy'
Expand Down Expand Up @@ -115,7 +114,7 @@ describe('getActionNameFromElement', () => {
})

it('should introduce whitespace for block-level display values', () => {
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
const testCases = [
{ display: 'block', expected: 'space' },
{ display: 'inline-block', expected: 'no-space' },
Expand Down Expand Up @@ -484,7 +483,7 @@ describe('getActionNameFromElement', () => {
})

it('removes only the child with programmatic action name in textual content', () => {
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
const { name, nameSource } = getActionNameFromElement(
appendElement('<div>Foobar Baz<div data-dd-action-name="custom action">bar<div></div>'),
defaultConfiguration
Expand Down Expand Up @@ -512,7 +511,7 @@ describe('getActionNameFromElement', () => {
}

it('preserves privacy level of the element when defaultPrivacyLevel is mask-unless-allowlisted', () => {
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
const { name, nameSource } = getActionNameFromElement(
appendElement(`
<div data-dd-privacy="mask">
Expand Down Expand Up @@ -666,7 +665,7 @@ describe('getActionNameFromElement', () => {
},
]
testCases.forEach(({ html, defaultPrivacyLevel, allowlist, expectedName, expectedNameSource }) => {
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
;(window as BrowserWindow).$DD_ALLOW = new Set(allowlist)
const target = appendElement(html)
const { name, nameSource } = getActionNameFromElement(
Expand Down Expand Up @@ -883,7 +882,7 @@ describe('getActionNameFromElement', () => {
})

it('inherit privacy level and remove only the masked child', () => {
mockExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
expect(
getActionNameFromElement(
appendElement(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
Observable,
ExperimentalFeature,
PageExitReason,
addExperimentalFeatures,
} 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'
Expand Down Expand Up @@ -478,7 +479,7 @@ 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])
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
startClickActionsTracking({
defaultPrivacyLevel: DefaultPrivacyLevel.MASK_UNLESS_ALLOWLISTED,
enablePrivacyForActionName: true,
Expand Down Expand Up @@ -523,7 +524,7 @@ 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])
addExperimentalFeatures([ExperimentalFeature.USE_TREE_WALKER_FOR_ACTION_NAME])
button.setAttribute('data-dd-privacy', 'mask-unless-allowlisted')
startClickActionsTracking({
defaultPrivacyLevel: DefaultPrivacyLevel.ALLOW,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Duration, ServerDuration } from '@datadog/browser-core'
import { ExperimentalFeature, Observable } from '@datadog/browser-core'
import { addExperimentalFeatures, ExperimentalFeature, Observable } from '@datadog/browser-core'
import type { Clock } from '@datadog/browser-core/test'
import { mockClock, mockExperimentalFeatures, registerCleanupTask } from '@datadog/browser-core/test'
import { mockClock, registerCleanupTask } from '@datadog/browser-core/test'
import { collectAndValidateRawRumEvents, mockRumConfiguration } from '../../../test'
import type { RawRumActionEvent, RawRumEvent } from '../../rawRumEvent.types'
import { RumEventType, ActionType, FrustrationType } from '../../rawRumEvent.types'
Expand All @@ -21,7 +21,7 @@ describe('trackManualActions', () => {

beforeEach(() => {
clock = mockClock()
mockExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])

const domMutationObservable = new Observable<RumMutationRecord[]>()
const windowOpenObservable = new Observable<void>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ExperimentalFeature, HookNames } from '@datadog/browser-core'
import { addExperimentalFeatures, ExperimentalFeature, HookNames } from '@datadog/browser-core'
import type { RelativeTime } from '@datadog/browser-core'
import type { AssembleHookParams, Hooks } from '../hooks'
import { createHooks } from '../hooks'
import { mockExperimentalFeatures, registerCleanupTask } from '../../../../core/test'
import { registerCleanupTask } from '../../../../core/test'
import type { RawRumLongAnimationFrameEvent } from '../../rawRumEvent.types'
import type { BrowserWindow } from './sourceCodeContext'
import { startSourceCodeContext } from './sourceCodeContext'
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('sourceCodeContext', () => {

describe('assemble hook when FF enabled', () => {
beforeEach(() => {
mockExperimentalFeatures([ExperimentalFeature.SOURCE_CODE_CONTEXT])
addExperimentalFeatures([ExperimentalFeature.SOURCE_CODE_CONTEXT])
})

it('should add source code context matching the error stack first frame URL', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/rum-core/src/domain/resource/resourceUtils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type Duration, type RelativeTime, type ServerDuration } from '@datadog/browser-core'
import { addExperimentalFeatures, type Duration, type RelativeTime, type ServerDuration } from '@datadog/browser-core'
import { ExperimentalFeature } from '@datadog/browser-core'
import { mockExperimentalFeatures } from '@datadog/browser-core/test'
import { RumPerformanceEntryType, type RumPerformanceResourceTiming } from '../../browser/performanceObservable'
import {
MAX_RESOURCE_VALUE_CHAR_LENGTH,
Expand Down Expand Up @@ -296,7 +295,7 @@ describe('shouldTrackResource', () => {
})

it('should allow requests on intake endpoints when TRACK_INTAKE_REQUESTS is enabled', () => {
mockExperimentalFeatures([ExperimentalFeature.TRACK_INTAKE_REQUESTS])
addExperimentalFeatures([ExperimentalFeature.TRACK_INTAKE_REQUESTS])
expect(isAllowedRequestUrl(`https://rum-intake.com/v1/input/abcde?${intakeParameters}`)).toBe(true)
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FlushEvent, Context, Telemetry } from '@datadog/browser-core'
import { Observable, resetExperimentalFeatures } from '@datadog/browser-core'
import { Observable } from '@datadog/browser-core'
import type { Clock, MockTelemetry } from '@datadog/browser-core/test'
import { mockClock, startMockTelemetry } from '@datadog/browser-core/test'
import type { AssembledRumEvent } from '../rawRumEvent.types'
Expand Down Expand Up @@ -52,10 +52,6 @@ describe('customerDataTelemetry', () => {
clock = mockClock()
})

afterEach(() => {
resetExperimentalFeatures()
})

it('should collect customer data telemetry', async () => {
setupCustomerTelemetryCollection()

Expand Down
4 changes: 0 additions & 4 deletions packages/rum-core/src/domain/view/trackViews.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
display,
relativeToClocks,
relativeNow,
resetExperimentalFeatures,
addExperimentalFeatures,
ExperimentalFeature,
} from '@datadog/browser-core'
Expand Down Expand Up @@ -432,7 +431,6 @@ describe('view metrics', () => {

beforeEach(() => {
addExperimentalFeatures([ExperimentalFeature.LCP_SUBPARTS])
registerCleanupTask(resetExperimentalFeatures)

clock = mockClock()
;({ notifyPerformanceEntries } = mockPerformanceObserver())
Expand Down Expand Up @@ -899,7 +897,6 @@ describe('view event count', () => {

registerCleanupTask(() => {
viewTest.stop()
resetExperimentalFeatures()
})
})

Expand Down Expand Up @@ -1057,7 +1054,6 @@ describe('service and version', () => {

registerCleanupTask(() => {
viewTest.stop()
resetExperimentalFeatures()
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RelativeTime } from '@datadog/browser-core'
import { registerCleanupTask } from '@datadog/browser-core/test'
import { resetExperimentalFeatures, elapsed, ONE_SECOND } from '@datadog/browser-core'
import { elapsed, ONE_SECOND } from '@datadog/browser-core'
import {
appendElement,
appendText,
Expand Down Expand Up @@ -238,10 +238,6 @@ describe('trackCumulativeLayoutShift', () => {
})

describe('cls target element', () => {
afterEach(() => {
resetExperimentalFeatures()
})

it('should return the first target element selector amongst all the shifted nodes', () => {
startCLSTracking()
const textNode = appendText('text')
Expand Down
Loading