зеркало из https://github.com/github/docs.git
Move the one performance metric in page to exit to avoid join (#17784)
This commit is contained in:
Родитель
e68e6a5185
Коммит
626bfa5918
|
@ -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)
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче