Do not sending telemetry while on freeze or disabled#43
Open
Do not sending telemetry while on freeze or disabled#43
Conversation
SeanSilke
requested changes
Apr 30, 2026
Collaborator
SeanSilke
left a comment
There was a problem hiding this comment.
Нужно увести за флаг. Флаг пусть будет - pauseSendingWhenPageInactive .
И нужно решить проблему накопления событий когда отправка на паузе.
this.events.length >= this.config.buffSize. Сейчас scheduleSend работает так что переполнения не будет, при паузе будет переполнение.
В чем именно баг дизайна
- Проверка this.events.length >= this.config.buffSize находится после canSendTelemetry().
- Значит при pause-state ветка переполнения вообще не исполняется.
- Итог: events.length может стать сколь угодно большим.
Можно делать принудительную отправку или ограничивать размер очереди.
Мне кажется предпочтительным вариант с maxQueueSize
Добавить maxQueueSize и политику дропа:
- maxQueueSize (например 1000 по умолчанию)
- queueOverflowStrategy: 'drop_oldest' | 'drop_newest' (обычно берут drop_oldest)
- счетчик droppedEventsCount для диагностики
Логика:
- В push() после events.push(...) сразу проверять maxQueueSize.
Если превышен: - drop_oldest: events.splice(0, overflow)
- drop_newest: events.length = maxQueueSize
- scheduleSend() пусть дальше работает как сейчас (с учетом lifecycle).
… implement event flushing mechanism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📦 Published PR as canary version:
2.0.18--canary.43.25312371161.0✨ Test out this PR locally via:
npm install @salutejs/web-telemetry@2.0.18--canary.43.25312371161.0 # or yarn add @salutejs/web-telemetry@2.0.18--canary.43.25312371161.0