From 666643a6ae9eb7fdef0b063d5494efaf49febc94 Mon Sep 17 00:00:00 2001 From: Andrey Babushkin <55714097+reyand43@users.noreply.github.com> Date: Tue, 25 Mar 2025 17:08:49 +0300 Subject: [PATCH] Improve tracker perfomance (#3208) * fix(helm): add CORS config to Assist ingress Configure CORS headers and debug session information for the Assist service's ingress to ensure proper cross-origin requests handling and improved debugging capabilities. Signed-off-by: rjshrjndrn * increase perfomance ticker and remove empty batches * add commit * updated Changelog --------- Signed-off-by: rjshrjndrn Co-authored-by: rjshrjndrn --- tracker/tracker/CHANGELOG.md | 5 +++++ tracker/tracker/src/main/app/index.ts | 12 ++++++++++++ tracker/tracker/src/main/modules/performance.ts | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tracker/tracker/CHANGELOG.md b/tracker/tracker/CHANGELOG.md index 3c06e7057..878a2b1cb 100644 --- a/tracker/tracker/CHANGELOG.md +++ b/tracker/tracker/CHANGELOG.md @@ -1,3 +1,8 @@ +## 16.1.1 + +- reduced the frequency of performance tracker calls +- reduced the number of events when the user is idle + ## 16.1.0 - new `privateMode` option to hide all possible data from tracking diff --git a/tracker/tracker/src/main/app/index.ts b/tracker/tracker/src/main/app/index.ts index 069c94f30..31b09150c 100644 --- a/tracker/tracker/src/main/app/index.ts +++ b/tracker/tracker/src/main/app/index.ts @@ -272,6 +272,7 @@ export default class App { 'feature-flags': true, 'usability-test': true, } + private emptyBatchCounter = 0 constructor( projectKey: string, @@ -871,6 +872,17 @@ export default class App { return } + if (!this.messages.length) { + // Release empty batches every 30 secs (1000 * 30ms) + if (this.emptyBatchCounter < 1000) { + this.emptyBatchCounter++; + return; + } + } + + this.emptyBatchCounter = 0 + console.log('messages', this.messages.join(', ')) + try { requestIdleCb(() => { this.messages.unshift(Timestamp(this.timestamp()), TabData(this.session.getTabId())) diff --git a/tracker/tracker/src/main/modules/performance.ts b/tracker/tracker/src/main/modules/performance.ts index 3d6ad1458..f966a2f2b 100644 --- a/tracker/tracker/src/main/modules/performance.ts +++ b/tracker/tracker/src/main/modules/performance.ts @@ -80,7 +80,7 @@ export default function (app: App, opts: Partial): void { ticks = frames = undefined }) - app.ticker.attach(sendPerformanceTrack, 40, false) + app.ticker.attach(sendPerformanceTrack, 165, false) if (document.hidden !== undefined) { app.attachEventListener(