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

🔥[RUM] remove screen performance events #180

Merged
merged 1 commit into from
Nov 27, 2019
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
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