Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('pageStateHistory', () => {
})
})
})
;[RumEventType.ACTION, RumEventType.ERROR].forEach((eventType) => {
;[RumEventType.ACTION, RumEventType.ERROR, RumEventType.RESOURCE, RumEventType.LONG_TASK, RumEventType.VITAL].forEach((eventType) => {
describe(`for ${eventType} events`, () => {
let pageStateHistory: PageStateHistory

Expand Down
13 changes: 4 additions & 9 deletions packages/rum-core/src/domain/contexts/pageStateHistory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Duration, RelativeTime } from '@datadog/browser-core'
import {
SKIPPED,
elapsed,
createValueHistory,
SESSION_TIME_OUT_DELAY,
Expand Down Expand Up @@ -101,7 +100,7 @@ export function startPageStateHistory(

hooks.register(
HookNames.Assemble,
({ startTime, duration = 0 as Duration, eventType }): DefaultRumEventAttributes | SKIPPED => {
({ startTime, duration = 0 as Duration, eventType }): DefaultRumEventAttributes => {
if (eventType === RumEventType.VIEW) {
const pageStates = pageStateEntryHistory.findAll(startTime, duration)
return {
Expand All @@ -110,14 +109,10 @@ export function startPageStateHistory(
}
}

if (eventType === RumEventType.ACTION || eventType === RumEventType.ERROR) {
return {
type: eventType,
view: { in_foreground: wasInPageStateDuringPeriod(PageState.ACTIVE, startTime, 0 as Duration) },
}
return {
type: eventType,
view: { in_foreground: wasInPageStateDuringPeriod(PageState.ACTIVE, startTime, 0 as Duration) },
}

return SKIPPED
}
)

Expand Down
12 changes: 12 additions & 0 deletions packages/rum-core/src/rawRumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export interface RawRumResourceEvent {
delivery_type?: DeliveryType
graphql?: GraphQlMetadata
}
view?: {
in_foreground: boolean
}
_dd: {
trace_id?: string
span_id?: string // not available for initial document tracing
Expand Down Expand Up @@ -261,6 +264,9 @@ export interface RawRumLongTaskEvent {
entry_type: typeof RumLongTaskEntryType.LONG_TASK
duration: ServerDuration
}
view?: {
in_foreground: boolean
}
_dd: {
discarded: boolean
}
Expand Down Expand Up @@ -302,6 +308,9 @@ export interface RawRumLongAnimationFrameEvent {
window_attribution: string
}>
}
view?: {
in_foreground: boolean
}
_dd: {
discarded: boolean
}
Expand Down Expand Up @@ -378,6 +387,9 @@ export interface RawRumVitalEvent {
description?: string
duration?: number
}
view?: {
in_foreground: boolean
}
_dd?: {
vital: {
computed_value: true
Expand Down
30 changes: 30 additions & 0 deletions packages/rum-core/src/rumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,16 @@ export type RumLongTaskEvent = CommonProperties &
}[]
[k: string]: unknown
}
/**
* View properties
*/
readonly view?: {
/**
* Is the long task starting in the foreground (focus in browser)
*/
readonly in_foreground?: boolean
[k: string]: unknown
}
/**
* Internal properties
*/
Expand Down Expand Up @@ -921,6 +931,16 @@ export type RumResourceEvent = CommonProperties &
}
[k: string]: unknown
}
/**
* View properties
*/
readonly view?: {
/**
* Is the resource starting in the foreground (focus in browser)
*/
readonly in_foreground?: boolean
[k: string]: unknown
}
/**
* Internal properties
*/
Expand Down Expand Up @@ -1393,6 +1413,16 @@ export type RumVitalEventCommonProperties = CommonProperties &
* RUM event type
*/
readonly type: 'vital'
/**
* View properties
*/
readonly view?: {
/**
* Is the vital starting in the foreground (focus in browser)
*/
readonly in_foreground?: boolean
[k: string]: unknown
}
/**
* Vital properties
*/
Expand Down
Loading