Skip to content

Commit

Permalink
🔥[RUM] remove screen performance events (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan authored Nov 27, 2019
1 parent 0cbac8a commit 5b0d557
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 91 deletions.
68 changes: 1 addition & 67 deletions packages/rum/src/rum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export enum RumEventCategory {
LONG_TASK = 'long_task',
VIEW = 'view',
RESOURCE = 'resource',
SCREEN_PERFORMANCE = 'screen_performance',
}

interface PerformanceResourceDetailsElement {
Expand Down Expand Up @@ -84,29 +83,6 @@ export interface RumResourceEvent {
traceId?: number
}

export interface RumPerformanceScreenEvent {
evt: {
category: RumEventCategory.SCREEN_PERFORMANCE
}
screen: {
performance: PerformanceScreenDetails
}
}

type PerformanceScreenDetails =
| {
domComplete: number
domContentLoadedEventEnd: number
domInteractive: number
loadEventEnd: number
}
| {
'first-paint': number
}
| {
'first-contentful-paint': number
}

export interface RumErrorEvent {
http?: HttpContext
error: ErrorContext
Expand Down Expand Up @@ -148,13 +124,7 @@ export interface RumUserAction {
[key: string]: ContextValue
}

export type RumEvent =
| RumErrorEvent
| RumPerformanceScreenEvent
| RumResourceEvent
| RumViewEvent
| RumLongTaskEvent
| RumUserAction
export type RumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumUserAction

export function startRum(
applicationId: string,
Expand Down Expand Up @@ -303,12 +273,6 @@ function trackPerformanceTiming(
case 'resource':
handleResourceEntry(configuration, entry as PerformanceResourceTiming, addRumEvent)
break
case 'navigation':
handleNavigationEntry(entry as PerformanceNavigationTiming, addRumEvent)
break
case 'paint':
handlePaintEntry(entry as PerformancePaintTiming, addRumEvent)
break
case 'longtask':
handleLongTaskEntry(entry as PerformanceLongTaskTiming, addRumEvent)
break
Expand Down Expand Up @@ -348,36 +312,6 @@ export function handleResourceEntry(
})
}

export function handleNavigationEntry(entry: PerformanceNavigationTiming, addRumEvent: (event: RumEvent) => void) {
addRumEvent({
evt: {
category: RumEventCategory.SCREEN_PERFORMANCE,
},
screen: {
performance: {
domComplete: msToNs(entry.domComplete),
domContentLoadedEventEnd: msToNs(entry.domContentLoadedEventEnd),
domInteractive: msToNs(entry.domInteractive),
loadEventEnd: msToNs(entry.loadEventEnd),
},
},
})
}

export function handlePaintEntry(entry: PerformancePaintTiming, addRumEvent: (event: RumEvent) => void) {
const performance = {
[entry.name]: msToNs(entry.startTime),
}
addRumEvent({
evt: {
category: RumEventCategory.SCREEN_PERFORMANCE,
},
screen: {
performance: performance as PerformanceScreenDetails,
},
})
}

export function handleLongTaskEntry(entry: PerformanceLongTaskTiming, addRumEvent: (event: RumEvent) => void) {
addRumEvent({
duration: msToNs(entry.duration),
Expand Down
25 changes: 1 addition & 24 deletions packages/rum/test/rum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ import sinon from 'sinon'

import { LifeCycle, LifeCycleEventType } from '../src/lifeCycle'
import { startPerformanceCollection } from '../src/performanceCollection'
import {
handlePaintEntry,
handleResourceEntry,
PerformancePaintTiming,
RumEvent,
RumEventCategory,
RumResourceEvent,
startRum,
} from '../src/rum'
import { handleResourceEntry, RumEvent, RumResourceEvent, startRum } from '../src/rum'
import { RumGlobal } from '../src/rum.entry'

function getEntry(addRumEvent: (event: RumEvent) => void, index: number) {
Expand Down Expand Up @@ -133,21 +125,6 @@ describe('rum handle performance entry', () => {
expect(resourceEvent.http.performance!.connect.duration).toEqual(7 * 1e6)
expect(resourceEvent.http.performance!.download.duration).toEqual(75 * 1e6)
})

it('should rewrite paint entries', () => {
const entry: Partial<PerformancePaintTiming> = { name: 'first-paint', startTime: 123456, entryType: 'paint' }
handlePaintEntry(entry as PerformancePaintTiming, addRumEvent)
expect(getEntry(addRumEvent, 0)).toEqual({
evt: {
category: RumEventCategory.SCREEN_PERFORMANCE,
},
screen: {
performance: {
'first-paint': 123456 * 1e6,
},
},
})
})
})

describe('rum session', () => {
Expand Down

0 comments on commit 5b0d557

Please sign in to comment.