Skip to content

Commit f2e45db

Browse files
🏷️ fix for unsupported 'transition' RUM event type
1 parent a35dd42 commit f2e45db

File tree

11 files changed

+46
-31
lines changed

11 files changed

+46
-31
lines changed

developer-extension/src/panel/components/tabs/eventsTab/eventRow.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const RUM_EVENT_TYPE_COLOR = {
3535
resource: 'cyan',
3636
telemetry: 'teal',
3737
vital: 'orange',
38+
transition: 'green',
3839
}
3940

4041
const LOG_STATUS_COLOR = {

packages/rum-core/src/domain/action/trackClickActions.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Context, Duration } from '@datadog/browser-core'
1+
import type { Duration } from '@datadog/browser-core'
22
import {
33
addDuration,
44
clocksNow,
@@ -11,8 +11,8 @@ import {
1111
import type { Clock } from '@datadog/browser-core/test'
1212
import { createNewEvent, mockClock, mockExperimentalFeatures } from '@datadog/browser-core/test'
1313
import { createFakeClick, createMutationRecord, mockRumConfiguration } from '../../../test'
14+
import type { AssembledRumEvent } from '../../rawRumEvent.types'
1415
import { RumEventType, ActionType, FrustrationType } from '../../rawRumEvent.types'
15-
import type { RumEvent } from '../../rumEvent.types'
1616
import { LifeCycle, LifeCycleEventType } from '../lifeCycle'
1717
import { PAGE_ACTIVITY_VALIDATION_DELAY } from '../waitPageActivityEnd'
1818
import type { RumConfiguration } from '../configuration'
@@ -177,7 +177,7 @@ describe('trackClickActions', () => {
177177
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, {
178178
type: RumEventType.RESOURCE,
179179
action: { id: 'unrelated-action-id' },
180-
} as RumEvent & Context)
180+
} as AssembledRumEvent)
181181

182182
clock.tick(EXPIRE_DELAY)
183183

@@ -602,7 +602,7 @@ describe('trackClickActions', () => {
602602
}
603603

604604
function createFakeErrorEvent() {
605-
return { type: RumEventType.ERROR, action: { id: findActionId() } } as RumEvent & Context
605+
return { type: RumEventType.ERROR, action: { id: findActionId() } } as AssembledRumEvent
606606
}
607607
})
608608

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Context, RawError, EventRateLimiter } from '@datadog/browser-core'
1+
import type { RawError, EventRateLimiter } from '@datadog/browser-core'
22
import {
33
combine,
44
isEmptyObject,
@@ -11,8 +11,8 @@ import {
1111
buildTags,
1212
} from '@datadog/browser-core'
1313
import type { RumEventDomainContext } from '../domainContext.types'
14+
import type { AssembledRumEvent } from '../rawRumEvent.types'
1415
import { RumEventType } from '../rawRumEvent.types'
15-
import type { RumEvent } from '../rumEvent.types'
1616
import type { LifeCycle } from './lifeCycle'
1717
import { LifeCycleEventType } from './lifeCycle'
1818
import type { RumConfiguration } from './configuration'
@@ -120,7 +120,7 @@ export function startRumAssembly(
120120

121121
const serverRumEvent = combine(defaultRumEventAttributes, rawRumEvent, {
122122
ddtags: buildTags(configuration).join(','),
123-
}) as RumEvent & Context
123+
}) as AssembledRumEvent
124124

125125
if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {
126126
if (isEmptyObject(serverRumEvent.context!)) {
@@ -133,7 +133,7 @@ export function startRumAssembly(
133133
}
134134

135135
function shouldSend(
136-
event: RumEvent & Context,
136+
event: AssembledRumEvent,
137137
beforeSend: RumConfiguration['beforeSend'],
138138
domainContext: RumEventDomainContext,
139139
eventRateLimiters: { [key in RumEventType]?: EventRateLimiter }

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { Context, Duration, PageMayExitEvent, RawError, RelativeTime } from '@datadog/browser-core'
22
import { AbstractLifeCycle } from '@datadog/browser-core'
33
import type { RumEventDomainContext } from '../domainContext.types'
4-
import type { RawRumEvent } from '../rawRumEvent.types'
5-
import type { RumEvent } from '../rumEvent.types'
4+
import type { RawRumEvent, AssembledRumEvent } from '../rawRumEvent.types'
65
import type { RequestCompleteEvent, RequestStartEvent } from './requestCollection'
76
import type { AutoAction } from './action/actionCollection'
87
import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent, BeforeViewUpdateEvent } from './view/trackViews'
@@ -85,7 +84,7 @@ export interface LifeCycleEventMap {
8584
[LifeCycleEventTypeAsConst.SESSION_RENEWED]: void
8685
[LifeCycleEventTypeAsConst.PAGE_MAY_EXIT]: PageMayExitEvent
8786
[LifeCycleEventTypeAsConst.RAW_RUM_EVENT_COLLECTED]: RawRumEventCollectedData
88-
[LifeCycleEventTypeAsConst.RUM_EVENT_COLLECTED]: RumEvent & Context
87+
[LifeCycleEventTypeAsConst.RUM_EVENT_COLLECTED]: AssembledRumEvent
8988
[LifeCycleEventTypeAsConst.RAW_ERROR_COLLECTED]: {
9089
error: RawError
9190
customerContext?: Context

packages/rum-core/src/domain/startCustomerDataTelemetry.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Observable, resetExperimentalFeatures } from '@datadog/browser-core'
33
import type { Clock, MockTelemetry } from '@datadog/browser-core/test'
44
import { mockClock, startMockTelemetry } from '@datadog/browser-core/test'
55
import { mockRumConfiguration } from '../../test'
6+
import type { AssembledRumEvent } from '../rawRumEvent.types'
67
import { RumEventType } from '../rawRumEvent.types'
7-
import type { RumEvent } from '../rumEvent.types'
88
import { LifeCycle, LifeCycleEventType } from './lifeCycle'
99
import { MEASURES_PERIOD_DURATION, startCustomerDataTelemetry } from './startCustomerDataTelemetry'
1010
import type { RumConfiguration } from './configuration'
@@ -15,7 +15,7 @@ describe('customerDataTelemetry', () => {
1515
let telemetry: MockTelemetry
1616
let fakeContextBytesCount: number
1717
let lifeCycle: LifeCycle
18-
const viewEvent = { type: RumEventType.VIEW } as RumEvent & Context
18+
const viewEvent = { type: RumEventType.VIEW } as AssembledRumEvent
1919

2020
const config: Partial<RumConfiguration> = {
2121
telemetrySampleRate: 100,

packages/rum-core/src/domain/trackEventCounts.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { Context } from '@datadog/browser-core'
21
import { objectValues } from '@datadog/browser-core'
3-
import type { RumEvent } from '../rumEvent.types'
2+
import type { AssembledRumEvent } from '../rawRumEvent.types'
43
import { FrustrationType, RumEventType } from '../rawRumEvent.types'
54
import { LifeCycle, LifeCycleEventType } from './lifeCycle'
65
import { trackEventCounts } from './trackEventCounts'
@@ -12,8 +11,8 @@ describe('trackEventCounts', () => {
1211
lifeCycle = new LifeCycle()
1312
})
1413

15-
function notifyCollectedRawRumEvent(partialEvent: Partial<RumEvent>) {
16-
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, partialEvent as RumEvent & Context)
14+
function notifyCollectedRawRumEvent(partialEvent: Partial<AssembledRumEvent>) {
15+
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, partialEvent as AssembledRumEvent)
1716
}
1817

1918
it('tracks errors', () => {

packages/rum-core/src/domain/view/trackViewEventCounts.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import type { Context } from '@datadog/browser-core'
21
import { registerCleanupTask } from '@datadog/browser-core/test'
3-
import type { RumEvent } from '../../rumEvent.types'
42
import { LifeCycle, LifeCycleEventType } from '../lifeCycle'
3+
import type { AssembledRumEvent } from '../../rawRumEvent.types'
54
import { RumEventType } from '../../rawRumEvent.types'
65
import { trackViewEventCounts } from './trackViewEventCounts'
76

@@ -20,7 +19,7 @@ describe('trackViewEventCounts', () => {
2019
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, {
2120
type: RumEventType.ERROR,
2221
view: { id: 'view-id' },
23-
} as RumEvent & Context)
22+
} as AssembledRumEvent)
2423

2524
expect(onChange).toHaveBeenCalledTimes(1)
2625
})
@@ -29,7 +28,7 @@ describe('trackViewEventCounts', () => {
2928
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, {
3029
type: RumEventType.ERROR,
3130
view: { id: 'unrelated-view-id' },
32-
} as RumEvent & Context)
31+
} as AssembledRumEvent)
3332

3433
expect(onChange).not.toHaveBeenCalled()
3534
})

packages/rum-core/src/domain/view/trackViews.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Context, Duration, RelativeTime } from '@datadog/browser-core'
1+
import type { Duration, RelativeTime } from '@datadog/browser-core'
22
import {
33
PageExitReason,
44
timeStampNow,
@@ -11,8 +11,8 @@ import {
1111
import type { Clock } from '@datadog/browser-core/test'
1212
import { mockClock, registerCleanupTask, createNewEvent } from '@datadog/browser-core/test'
1313
import { createPerformanceEntry, mockPerformanceObserver } from '../../../test'
14+
import type { AssembledRumEvent } from '../../rawRumEvent.types'
1415
import { RumEventType, ViewLoadingType } from '../../rawRumEvent.types'
15-
import type { RumEvent } from '../../rumEvent.types'
1616
import { LifeCycle, LifeCycleEventType } from '../lifeCycle'
1717
import type { RumPerformanceEntry } from '../../browser/performanceObservable'
1818
import { RumPerformanceEntryType } from '../../browser/performanceObservable'
@@ -874,7 +874,7 @@ describe('view event count', () => {
874874
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, {
875875
type: RumEventType.RESOURCE,
876876
view: { id: firstView.id },
877-
} as RumEvent & Context)
877+
} as AssembledRumEvent)
878878

879879
clock.tick(THROTTLE_VIEW_UPDATE_PERIOD)
880880

@@ -895,7 +895,7 @@ describe('view event count', () => {
895895
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, {
896896
type: RumEventType.RESOURCE,
897897
view: { id: firstView.id },
898-
} as RumEvent & Context)
898+
} as AssembledRumEvent)
899899

900900
clock.tick(THROTTLE_VIEW_UPDATE_PERIOD)
901901

@@ -908,7 +908,7 @@ describe('view event count', () => {
908908
type: RumEventType.ACTION,
909909
action: {},
910910
view: viewTest.getLatestViewContext(),
911-
} as RumEvent & Context
911+
} as AssembledRumEvent
912912
}
913913

914914
describe('view specific context', () => {

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import type {
1212
} from '@datadog/browser-core'
1313
import type { GraphQlMetadata } from './domain/resource/graphql'
1414
import type { PageState } from './domain/contexts/pageStateHistory'
15+
import type {
16+
RumActionEvent,
17+
RumErrorEvent,
18+
RumLongTaskEvent,
19+
RumResourceEvent,
20+
RumViewEvent,
21+
RumVitalEvent,
22+
} from './rumEvent.types'
1523

1624
export const RumEventType = {
1725
ACTION: 'action',
@@ -24,6 +32,16 @@ export const RumEventType = {
2432

2533
export type RumEventType = (typeof RumEventType)[keyof typeof RumEventType]
2634

35+
export type AssembledRumEvent = (
36+
| RumViewEvent
37+
| RumActionEvent
38+
| RumResourceEvent
39+
| RumErrorEvent
40+
| RumVitalEvent
41+
| RumLongTaskEvent
42+
) &
43+
Context
44+
2745
export const RumLongTaskEntryType = {
2846
LONG_TASK: 'long-task',
2947
LONG_ANIMATION_FRAME: 'long-animation-frame',

packages/rum-core/src/transport/startRumBatch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { Context, Observable, RawError, PageMayExitEvent, Encoder } from '@datadog/browser-core'
1+
import type { Observable, RawError, PageMayExitEvent, Encoder } from '@datadog/browser-core'
22
import { createBatch, createFlushController, createHttpRequest, DeflateEncoderStreamId } from '@datadog/browser-core'
33
import type { RumConfiguration } from '../domain/configuration'
44
import type { LifeCycle } from '../domain/lifeCycle'
55
import { LifeCycleEventType } from '../domain/lifeCycle'
6+
import type { AssembledRumEvent } from '../rawRumEvent.types'
67
import { RumEventType } from '../rawRumEvent.types'
7-
import type { RumEvent } from '../rumEvent.types'
88

99
export function startRumBatch(
1010
configuration: RumConfiguration,
@@ -32,7 +32,7 @@ export function startRumBatch(
3232
messageBytesLimit: configuration.messageBytesLimit,
3333
})
3434

35-
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (serverRumEvent: RumEvent & Context) => {
35+
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (serverRumEvent: AssembledRumEvent) => {
3636
if (serverRumEvent.type === RumEventType.VIEW) {
3737
batch.upsert(serverRumEvent, serverRumEvent.view.id)
3838
} else {

0 commit comments

Comments
 (0)