diff --git a/javascripts/events.js b/javascripts/events.js index 7b53f980d2..55bec3f143 100644 --- a/javascripts/events.js +++ b/javascripts/events.js @@ -30,7 +30,7 @@ export function getUserEventsId () { export function sendEvent ({ type, version = '1.0.0', - page_render_duration, + exit_render_duration, exit_first_paint, exit_dom_interactive, exit_dom_complete, @@ -81,9 +81,10 @@ export function sendEvent ({ }, // Page event - page_render_duration, + // No extra fields // Exit event + exit_render_duration, exit_first_paint, exit_dom_interactive, exit_dom_complete, @@ -150,12 +151,14 @@ function sendExit () { if (document.visibilityState !== 'hidden') return sentExit = true const { + render, firstContentfulPaint, domInteractive, domComplete } = getPerformance() return sendEvent({ type: 'exit', + exit_render_duration: render, exit_first_paint: firstContentfulPaint, exit_dom_interactive: domInteractive, exit_dom_complete: domComplete, @@ -165,11 +168,7 @@ function sendExit () { } function initPageEvent () { - const { render } = getPerformance() - const pageEvent = sendEvent({ - type: 'page', - page_render_duration: render - }) + const pageEvent = sendEvent({ type: 'page' }) pageEventId = pageEvent?.context?.event_id } diff --git a/lib/schema-event.js b/lib/schema-event.js index 9365f70433..fbb37060f2 100644 --- a/lib/schema-event.js +++ b/lib/schema-event.js @@ -124,11 +124,6 @@ const pageSchema = { type: { type: 'string', pattern: '^page$' - }, - page_render_duration: { - type: 'number', - description: 'How long the server took to render the page content, in seconds.', - minimum: 0.001 } } } @@ -145,6 +140,11 @@ const exitSchema = { type: 'string', pattern: '^exit$' }, + exit_render_duration: { + type: 'number', + description: 'How long the server took to render the page content, in seconds.', + minimum: 0.001 + }, exit_first_paint: { type: 'number', minimum: 0.001, diff --git a/tests/rendering/events.js b/tests/rendering/events.js index 15daa36e7b..b0d8c64e29 100644 --- a/tests/rendering/events.js +++ b/tests/rendering/events.js @@ -280,19 +280,13 @@ describe('POST /events', () => { } }, 400) ) - - it('should page_render_duration is a positive number', () => - checkEvent({ - ...pageExample, - page_render_duration: -0.5 - }, 400) - ) }) describe('exit', () => { const exitExample = { ...baseExample, type: 'exit', + exit_render_duration: 0.9, exit_first_paint: 0.1, exit_dom_interactive: 0.2, exit_dom_complete: 0.3, @@ -304,6 +298,13 @@ describe('POST /events', () => { checkEvent(exitExample, 201) ) + it('should exit_render_duration is a positive number', () => + checkEvent({ + ...exitExample, + exit_render_duration: -0.5 + }, 400) + ) + it('exit_first_paint is a number', () => checkEvent({ ...exitExample, exit_first_paint: 'afjdkl' }, 400) )