mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
[web] block idle connection-restored events (#36425)
GitOrigin-RevId: 74b142f72f7982e6df9e0208965d8372e23afc74
This commit is contained in:
@@ -45,10 +45,25 @@ async function updateEditingSession(req, res, next) {
|
||||
res.sendStatus(202)
|
||||
}
|
||||
|
||||
// TODO: remove after clients running pre-#36315 code have drained
|
||||
function isIdleConnectionRestoredEvent(event, body) {
|
||||
if (event !== 'connection-restored') {
|
||||
return false
|
||||
}
|
||||
if (body.resolution === 'out-of-sync') {
|
||||
return false
|
||||
}
|
||||
return body.pendingChars === 0 && body.inflightChars === 0
|
||||
}
|
||||
|
||||
function recordEvent(req, res, next) {
|
||||
if (!Features.hasFeature('analytics')) {
|
||||
return res.sendStatus(202)
|
||||
}
|
||||
if (isIdleConnectionRestoredEvent(req.params.event, req.body)) {
|
||||
metrics.inc('analytics_idle_connection_restored_blocked')
|
||||
return res.sendStatus(202)
|
||||
}
|
||||
delete req.body._csrf
|
||||
AnalyticsManager.recordEventForSession(
|
||||
req.session,
|
||||
|
||||
Reference in New Issue
Block a user