Skip to content

Commit d891f5a

Browse files
committed
🐛 add transition
1 parent c89762c commit d891f5a

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

packages/rum-core/src/domain/assembly.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@datadog/browser-core'
1313
import type { RumEventDomainContext } from '../domainContext.types'
1414
import { RumEventType } from '../rawRumEvent.types'
15-
import type { RumEvent, RumTransitionEvent, RumViewEvent } from '../rumEvent.types'
15+
import type { RumEvent, RumViewEvent } from '../rumEvent.types'
1616
import type { LifeCycle } from './lifeCycle'
1717
import { LifeCycleEventType } from './lifeCycle'
1818
import type { RumConfiguration } from './configuration'
@@ -91,6 +91,11 @@ export function startRumAssembly(
9191
...VIEW_MODIFIABLE_FIELD_PATHS,
9292
...ROOT_MODIFIABLE_FIELD_PATHS,
9393
},
94+
[RumEventType.TRANSITION]: {
95+
...USER_CUSTOMIZABLE_FIELD_PATHS,
96+
...VIEW_MODIFIABLE_FIELD_PATHS,
97+
...ROOT_MODIFIABLE_FIELD_PATHS,
98+
},
9499
}
95100
const eventRateLimiters = {
96101
[RumEventType.ERROR]: createEventRateLimiter(
@@ -125,7 +130,7 @@ export function startRumAssembly(
125130

126131
const serverRumEvent = combine(defaultRumEventAttributes, rawRumEvent, {
127132
ddtags: buildTags(configuration).join(','),
128-
}) as Exclude<RumEvent, RumTransitionEvent> & Context
133+
}) as RumEvent & Context
129134

130135
if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {
131136
if (isEmptyObject(serverRumEvent.context!)) {
@@ -170,7 +175,7 @@ export function startRumAssembly(
170175
}
171176

172177
function shouldSend(
173-
event: Exclude<RumEvent, RumTransitionEvent> & Context,
178+
event: RumEvent & Context,
174179
beforeSend: RumConfiguration['beforeSend'],
175180
domainContext: RumEventDomainContext,
176181
eventRateLimiters: { [key in RumEventType]?: EventRateLimiter }

packages/rum-core/src/domain/event/eventCollection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const allowedEventTypes = [
2020
RumEventType.LONG_TASK,
2121
RumEventType.RESOURCE,
2222
RumEventType.STREAM,
23+
RumEventType.STREAM,
24+
RumEventType.TRANSITION,
2325
RumEventType.VITAL,
2426
] as const
2527

packages/rum-core/src/rawRumEvent.types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const RumEventType = {
2020
RESOURCE: 'resource',
2121
VITAL: 'vital',
2222
STREAM: 'stream',
23+
TRANSITION: 'transition',
2324
} as const
2425

2526
export type RumEventType = (typeof RumEventType)[keyof typeof RumEventType]
@@ -378,6 +379,23 @@ export interface RawRumStreamEvent {
378379
}
379380
}
380381

382+
export interface RawRumTransitionEvent {
383+
date: TimeStamp
384+
type: typeof RumEventType.TRANSITION
385+
stream: {
386+
id: string
387+
}
388+
transition: {
389+
type: string
390+
id?: string
391+
timestamp?: number
392+
buffer_starvation_duration?: number
393+
media_start_delay?: number
394+
error_code?: number
395+
duration?: number
396+
}
397+
}
398+
381399
export type RawRumEvent =
382400
| RawRumErrorEvent
383401
| RawRumResourceEvent
@@ -387,3 +405,4 @@ export type RawRumEvent =
387405
| RawRumActionEvent
388406
| RawRumVitalEvent
389407
| RawRumStreamEvent
408+
| RawRumTransitionEvent

packages/rum-core/test/fixtures.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ export function createRawRumEvent(type: RumEventType, overrides?: Context): RawR
143143
},
144144
overrides
145145
)
146+
case RumEventType.TRANSITION:
147+
return combine(
148+
{
149+
type,
150+
date: 0 as TimeStamp,
151+
stream: {
152+
id: generateUUID(),
153+
},
154+
transition: {
155+
id: generateUUID(),
156+
type: 'MEDIA_PLAYER_PLAY',
157+
}
158+
},
159+
overrides
160+
)
146161
}
147162
}
148163

0 commit comments

Comments
 (0)