mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
[web] analytics for flaky connections (#35916)
* emit connection-restored events * emit post-offline sync success/failure events GitOrigin-RevId: 3fce5f328d726aeb5edf39f14239ef6e5bda2f99
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
// Migrated from static methods of Document in Document.js
|
||||
|
||||
import { DocumentContainer } from '@/features/ide-react/editor/document-container'
|
||||
import {
|
||||
DocumentContainer,
|
||||
getShareJsOpSize,
|
||||
} from '@/features/ide-react/editor/document-container'
|
||||
import { debugConsole } from '@/utils/debugging'
|
||||
import { Socket } from '@/features/ide-react/connection/types/socket'
|
||||
import { IdeEventEmitter } from '@/features/ide-react/create-ide-event-emitter'
|
||||
@@ -45,18 +48,37 @@ export class OpenDocuments {
|
||||
const docs = this.unsavedDocs()
|
||||
let pendingOpsLength = 0
|
||||
let inflightOpsLength = 0
|
||||
let pendingChars = 0
|
||||
let inflightChars = 0
|
||||
for (const doc of docs) {
|
||||
const pendingOp = doc.getPendingOp()
|
||||
const inFlightOp = doc.getInflightOp()
|
||||
pendingOpsLength += pendingOp?.length || 0
|
||||
inflightOpsLength += inFlightOp?.length || 0
|
||||
pendingChars += pendingOp ? getShareJsOpSize(pendingOp) : 0
|
||||
inflightChars += inFlightOp ? getShareJsOpSize(inFlightOp) : 0
|
||||
}
|
||||
return {
|
||||
pendingOpsLength,
|
||||
inflightOpsLength,
|
||||
pendingChars,
|
||||
inflightChars,
|
||||
}
|
||||
}
|
||||
|
||||
// performance.now() timeline, matching the unsaved-docs alert
|
||||
getOldestUnsavedOpCreatedAt(): number | null {
|
||||
let oldest: number | null = null
|
||||
for (const doc of this.unsavedDocs()) {
|
||||
const createdAt =
|
||||
doc.getInflightOpCreatedAt() ?? doc.getPendingOpCreatedAt()
|
||||
if (createdAt != null && (oldest === null || createdAt < oldest)) {
|
||||
oldest = createdAt
|
||||
}
|
||||
}
|
||||
return oldest
|
||||
}
|
||||
|
||||
private createDoc(docId: string) {
|
||||
const doc = new DocumentContainer(
|
||||
docId,
|
||||
|
||||
Reference in New Issue
Block a user