Move the one performance metric in page to exit to avoid join (#17784)

This commit is contained in:
Kevin Heis 2021-02-11 08:28:07 -08:00 коммит произвёл GitHub
Родитель e68e6a5185
Коммит 626bfa5918
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 19 добавлений и 19 удалений

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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)
)