From 5f6c6c3f46a84ef6e3cf0871591b45e9954fae40 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Fri, 20 Nov 2020 18:21:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20loadEvent=20v2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/trackTimings.spec.ts | 4 ++-- .../rumEventsCollection/view/trackTimings.ts | 4 ++-- .../view/trackViews.spec.ts | 6 +++--- .../rumEventsCollection/view/trackViews.ts | 18 +++++++++--------- .../view/viewCollection.spec.ts | 4 ++-- .../rumEventsCollection/view/viewCollection.ts | 2 +- packages/rum/src/types.ts | 9 ++------- 7 files changed, 21 insertions(+), 26 deletions(-) diff --git a/packages/rum/src/domain/rumEventsCollection/view/trackTimings.spec.ts b/packages/rum/src/domain/rumEventsCollection/view/trackTimings.spec.ts index 3f9b3faaf0..365cf7e9b6 100644 --- a/packages/rum/src/domain/rumEventsCollection/view/trackTimings.spec.ts +++ b/packages/rum/src/domain/rumEventsCollection/view/trackTimings.spec.ts @@ -71,7 +71,7 @@ describe('trackTimings', () => { domInteractive: 234, firstContentfulPaint: 123, firstInputDelay: 100, - loadEventEnd: 567, + loadEvent: 567, }) }) }) @@ -101,7 +101,7 @@ describe('trackNavigationTimings', () => { domComplete: 456, domContentLoaded: 345, domInteractive: 234, - loadEventEnd: 567, + loadEvent: 567, }) }) }) diff --git a/packages/rum/src/domain/rumEventsCollection/view/trackTimings.ts b/packages/rum/src/domain/rumEventsCollection/view/trackTimings.ts index 832a941314..eae2f2f8e3 100644 --- a/packages/rum/src/domain/rumEventsCollection/view/trackTimings.ts +++ b/packages/rum/src/domain/rumEventsCollection/view/trackTimings.ts @@ -7,7 +7,7 @@ export interface Timings { domInteractive?: number domContentLoaded?: number domComplete?: number - loadEventEnd?: number + loadEvent?: number largestContentfulPaint?: number firstInputDelay?: number } @@ -51,7 +51,7 @@ export function trackNavigationTimings(lifeCycle: LifeCycle, callback: (newTimin domComplete: entry.domComplete, domContentLoaded: entry.domContentLoadedEventEnd, domInteractive: entry.domInteractive, - loadEventEnd: entry.loadEventEnd, + loadEvent: entry.loadEventEnd, }) } }) diff --git a/packages/rum/src/domain/rumEventsCollection/view/trackViews.spec.ts b/packages/rum/src/domain/rumEventsCollection/view/trackViews.spec.ts index 7d3e0bf641..a3db5ce13a 100644 --- a/packages/rum/src/domain/rumEventsCollection/view/trackViews.spec.ts +++ b/packages/rum/src/domain/rumEventsCollection/view/trackViews.spec.ts @@ -488,7 +488,7 @@ describe('rum view measures', () => { domComplete: 456, domContentLoaded: 345, domInteractive: 234, - loadEventEnd: 567, + loadEvent: 567, }) }) @@ -511,7 +511,7 @@ describe('rum view measures', () => { domInteractive: 234, firstContentfulPaint: 123, largestContentfulPaint: 789, - loadEventEnd: 567, + loadEvent: 567, }) expect(getViewEvent(2).timings).toEqual({}) }) @@ -563,7 +563,7 @@ describe('rum view measures', () => { domInteractive: 234, firstContentfulPaint: 123, largestContentfulPaint: 789, - loadEventEnd: 567, + loadEvent: 567, }) }) diff --git a/packages/rum/src/domain/rumEventsCollection/view/trackViews.ts b/packages/rum/src/domain/rumEventsCollection/view/trackViews.ts index 7d8cb5e864..256db3810c 100644 --- a/packages/rum/src/domain/rumEventsCollection/view/trackViews.ts +++ b/packages/rum/src/domain/rumEventsCollection/view/trackViews.ts @@ -125,7 +125,7 @@ function newView( scheduleViewUpdate() }) - const { setActivityLoadingTime, setLoadEventEnd } = trackLoadingTime(loadingType, (newLoadingTime) => { + const { setActivityLoadingTime, setLoadEvent } = trackLoadingTime(loadingType, (newLoadingTime) => { loadingTime = newLoadingTime scheduleViewUpdate() }) @@ -171,8 +171,8 @@ function newView( }, updateTimings(newTimings: Timings) { timings = newTimings - if (newTimings.loadEventEnd !== undefined) { - setLoadEventEnd(newTimings.loadEventEnd) + if (newTimings.loadEvent !== undefined) { + setLoadEvent(newTimings.loadEvent) } }, updateLocation(newLocation: Location) { @@ -208,21 +208,21 @@ function trackHash(onHashChange: () => void) { } function trackLoadingTime(loadType: ViewLoadingType, callback: (loadingTime: number) => void) { - let isWaitingForLoadEventEnd = loadType === ViewLoadingType.INITIAL_LOAD + let isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD let isWaitingForActivityLoadingTime = true const loadingTimeCandidates: number[] = [] function invokeCallbackIfAllCandidatesAreReceived() { - if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEventEnd && loadingTimeCandidates.length > 0) { + if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEvent && loadingTimeCandidates.length > 0) { callback(Math.max(...loadingTimeCandidates)) } } return { - setLoadEventEnd(loadEventEnd: number) { - if (isWaitingForLoadEventEnd) { - isWaitingForLoadEventEnd = false - loadingTimeCandidates.push(loadEventEnd) + setLoadEvent(loadEvent: number) { + if (isWaitingForLoadEvent) { + isWaitingForLoadEvent = false + loadingTimeCandidates.push(loadEvent) invokeCallbackIfAllCandidatesAreReceived() } }, diff --git a/packages/rum/src/domain/rumEventsCollection/view/viewCollection.spec.ts b/packages/rum/src/domain/rumEventsCollection/view/viewCollection.spec.ts index 0d628bf196..aab0dd07bb 100644 --- a/packages/rum/src/domain/rumEventsCollection/view/viewCollection.spec.ts +++ b/packages/rum/src/domain/rumEventsCollection/view/viewCollection.spec.ts @@ -45,7 +45,7 @@ describe('viewCollection', () => { firstContentfulPaint: 10, firstInputDelay: 12, largestContentfulPaint: 10, - loadEventEnd: 10, + loadEvent: 10, }, } lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, view as View) @@ -70,7 +70,7 @@ describe('viewCollection', () => { firstContentfulPaint: 10 * 1e6, firstInputDelay: 12 * 1e6, largestContentfulPaint: 10 * 1e6, - loadEventEnd: 10 * 1e6, + loadEvent: 10 * 1e6, loadingTime: 20 * 1e6, loadingType: ViewLoadingType.INITIAL_LOAD, longTask: { diff --git a/packages/rum/src/domain/rumEventsCollection/view/viewCollection.ts b/packages/rum/src/domain/rumEventsCollection/view/viewCollection.ts index c3baa1faab..77606e6388 100644 --- a/packages/rum/src/domain/rumEventsCollection/view/viewCollection.ts +++ b/packages/rum/src/domain/rumEventsCollection/view/viewCollection.ts @@ -31,7 +31,7 @@ function processViewUpdate(view: View) { firstContentfulPaint: msToNs(view.timings.firstContentfulPaint), firstInputDelay: msToNs(view.timings.firstInputDelay), largestContentfulPaint: msToNs(view.timings.largestContentfulPaint), - loadEventEnd: msToNs(view.timings.loadEventEnd), + loadEvent: msToNs(view.timings.loadEvent), loadingTime: msToNs(view.loadingTime), loadingType: view.loadingType, longTask: { diff --git a/packages/rum/src/types.ts b/packages/rum/src/types.ts index c10df5e699..ea24fe1efa 100644 --- a/packages/rum/src/types.ts +++ b/packages/rum/src/types.ts @@ -62,7 +62,7 @@ export interface RumViewEvent { domInteractive?: number domContentLoaded?: number domComplete?: number - loadEventEnd?: number + loadEvent?: number loadingTime?: number timeSpent: number error: Count @@ -103,12 +103,7 @@ export interface RumActionEvent { } } -export type RawRumEvent = - | RumErrorEvent - | RumResourceEvent - | RumViewEvent - | RumLongTaskEvent - | RumActionEvent +export type RawRumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumActionEvent export interface RumContext { date: number