Merge pull request #10587 from overleaf/td-commit-hash-metric

Add editing session segmentation values for long tasks and release

GitOrigin-RevId: ee22238ae40b342cbd6b1e6cddcb2d0e67dba138
This commit is contained in:
Tim Down 2022-11-29 10:09:36 +00:00 committed by Copybot
parent 5728ffba2c
commit c4b1bb87ea
2 changed files with 31 additions and 0 deletions

View file

@ -287,6 +287,8 @@ If the project has been renamed please look in your project list for a new proje
'MeanLagsPerMeasure', 'MeanLagsPerMeasure',
'MeanKeypressesPerMeasure', 'MeanKeypressesPerMeasure',
'MeanKeypressPaint', 'MeanKeypressPaint',
'LongTasks',
'Release',
] ]
for (const prop of perfProps) { for (const prop of perfProps) {

View file

@ -2,6 +2,7 @@ import { Transaction } from '@codemirror/state'
import { EditorView } from '@codemirror/view' import { EditorView } from '@codemirror/view'
import { round } from 'lodash' import { round } from 'lodash'
import grammarlyExtensionPresent from '../shared/utils/grammarly' import grammarlyExtensionPresent from '../shared/utils/grammarly'
import getMeta from '../utils/meta'
const TIMER_START_NAME = 'CM6-BeforeUpdate' const TIMER_START_NAME = 'CM6-BeforeUpdate'
const TIMER_END_NAME = 'CM6-AfterUpdate' const TIMER_END_NAME = 'CM6-AfterUpdate'
@ -47,6 +48,22 @@ try {
} }
} catch (e) {} } catch (e) {}
let performanceLongtaskSupported = false
let longTaskSinceLastReportCount = 0
// Detect support for long task monitoring
try {
if (PerformanceObserver.supportedEntryTypes.includes('longtask')) {
performanceLongtaskSupported = true
// Register observer for long task notifications
const observer = new PerformanceObserver(list => {
longTaskSinceLastReportCount += list.getEntries().length
})
observer.observe({ entryTypes: ['longtask'] })
}
} catch (e) {}
function isInputOrDelete(userEventType: string | undefined) { function isInputOrDelete(userEventType: string | undefined) {
return ( return (
!!userEventType && ['input', 'delete'].includes(userEventType.split('.')[0]) !!userEventType && ['input', 'delete'].includes(userEventType.split('.')[0])
@ -242,6 +259,16 @@ export function reportCM6Perf() {
performance.clearMeasures(TIMER_KEYPRESS_MEASURE_NAME) performance.clearMeasures(TIMER_KEYPRESS_MEASURE_NAME)
let longTasks = null
// Get long task entries (Chromium-based browsers only at time of writing)
if (performanceLongtaskSupported) {
longTasks = longTaskSinceLastReportCount
longTaskSinceLastReportCount = 0
}
const release = getMeta('ol-ExposedSettings')?.sentryRelease || null
return { return {
max, max,
mean, mean,
@ -259,6 +286,8 @@ export function reportCM6Perf() {
meanLagsPerMeasure, meanLagsPerMeasure,
meanKeypressesPerMeasure, meanKeypressesPerMeasure,
meanKeypressPaint, meanKeypressPaint,
longTasks,
release,
} }
} }