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

💥 [RUMF-1577] Stop collecting foreground periods #2311

Merged
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
1 change: 0 additions & 1 deletion packages/core/src/tools/experimentalFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export enum ExperimentalFeature {
PAGEHIDE = 'pagehide',
FEATURE_FLAGS = 'feature_flags',
RESOURCE_PAGE_STATES = 'resource_page_states',
PAGE_STATES = 'page_states',
COLLECT_FLUSH_REASON = 'collect_flush_reason',
SCROLLMAP = 'scrollmap',
}
Expand Down
249 changes: 0 additions & 249 deletions packages/rum-core/src/domain/contexts/foregroundContexts.spec.ts

This file was deleted.

32 changes: 0 additions & 32 deletions packages/rum-core/src/domain/contexts/foregroundContexts.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Duration, RelativeTime, ServerDuration, TimeStamp } from '@datadog/browser-core'
import { resetExperimentalFeatures, ExperimentalFeature, addExperimentalFeatures } from '@datadog/browser-core'
import { resetExperimentalFeatures } from '@datadog/browser-core'
import type { RecorderApi } from '../../../boot/rumPublicApi'
import type { TestSetupBuilder } from '../../../../test'
import { setup, noopRecorderApi } from '../../../../test'
Expand Down Expand Up @@ -105,7 +105,10 @@ describe('viewCollection', () => {
_dd: {
document_version: 3,
replay_stats: undefined,
page_states: undefined,
page_states: [
{ start: 0 as ServerDuration, state: PageState.ACTIVE },
{ start: 10 as ServerDuration, state: PageState.PASSIVE },
],
},
date: jasmine.any(Number),
type: RumEventType.VIEW,
Expand Down Expand Up @@ -144,7 +147,6 @@ describe('viewCollection', () => {
count: 10,
},
time_spent: (100 * 1e6) as ServerDuration,
in_foreground_periods: [{ start: 0 as ServerDuration, duration: 10 as ServerDuration }],
},
session: {
has_replay: undefined,
Expand Down Expand Up @@ -207,25 +209,6 @@ describe('viewCollection', () => {
expect(rawRumViewEvent.view.loading_time).toBeUndefined()
})

it('should include page_states but not in_foreground_periods when PAGE_STATES ff is enabled', () => {
addExperimentalFeatures([ExperimentalFeature.PAGE_STATES])
const { lifeCycle, rawRumEvents } = setupBuilder.build()
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, VIEW)
const rawRumViewEvent = rawRumEvents[rawRumEvents.length - 1].rawRumEvent as RawRumViewEvent

expect(rawRumViewEvent._dd.page_states).toBeDefined()
expect(rawRumViewEvent.view.in_foreground_periods).toBeUndefined()
})

it('should include in_foreground_periods but not page_states when PAGE_STATES ff is disabled', () => {
const { lifeCycle, rawRumEvents } = setupBuilder.build()
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, VIEW)
const rawRumViewEvent = rawRumEvents[rawRumEvents.length - 1].rawRumEvent as RawRumViewEvent

expect(rawRumViewEvent._dd.page_states).toBeUndefined()
expect(rawRumViewEvent.view.in_foreground_periods).toBeDefined()
})

it('should not include scroll metrics when there are not scroll metrics in the raw event', () => {
const { lifeCycle, rawRumEvents } = setupBuilder.build()
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, { ...VIEW, scrollMetrics: undefined })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import type { Duration, ServerDuration, Observable } from '@datadog/browser-core'
import {
isExperimentalFeatureEnabled,
ExperimentalFeature,
isEmptyObject,
mapValues,
toServerDuration,
isNumber,
} from '@datadog/browser-core'
import { isEmptyObject, mapValues, toServerDuration, isNumber } from '@datadog/browser-core'
import type { RecorderApi } from '../../../boot/rumPublicApi'
import type { RawRumViewEvent } from '../../../rawRumEvent.types'
import { RumEventType } from '../../../rawRumEvent.types'
import type { LifeCycle, RawRumEventCollectedData } from '../../lifeCycle'
import { LifeCycleEventType } from '../../lifeCycle'
import { mapToForegroundPeriods } from '../../contexts/foregroundContexts'
import type { LocationChange } from '../../../browser/locationChangeObservable'
import type { RumConfiguration } from '../../configuration'
import type { FeatureFlagContexts } from '../../contexts/featureFlagContext'
Expand Down Expand Up @@ -59,13 +51,12 @@ function processViewUpdate(
): RawRumEventCollectedData<RawRumViewEvent> {
const replayStats = recorderApi.getReplayStats(view.id)
const featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(view.startClocks.relative)
const pageStatesEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGE_STATES)
const pageStates = pageStateHistory.findAll(view.startClocks.relative, view.duration)
const viewEvent: RawRumViewEvent = {
_dd: {
document_version: view.documentVersion,
replay_stats: replayStats,
page_states: pageStatesEnabled ? pageStates : undefined,
page_states: pageStates,
},
date: view.startClocks.timeStamp,
type: RumEventType.VIEW,
Expand Down Expand Up @@ -100,8 +91,6 @@ function processViewUpdate(
count: view.eventCounts.resourceCount,
},
time_spent: toServerDuration(view.duration),
in_foreground_periods:
!pageStatesEnabled && pageStates ? mapToForegroundPeriods(pageStates, view.duration) : undefined, // Todo: Remove in the next major release
},
feature_flags: featureFlagContext && !isEmptyObject(featureFlagContext) ? featureFlagContext : undefined,
display: view.scrollMetrics
Expand Down
Loading