From 8a08a22f02128fb60b73434bb38479cea582c9c7 Mon Sep 17 00:00:00 2001
From: Andrey Sobolev <haiodo@users.noreply.github.com>
Date: Fri, 8 Nov 2024 00:29:35 +0700
Subject: [PATCH] Fix using wrong stats token (#7127)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
---
 server/core/src/stats.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/core/src/stats.ts b/server/core/src/stats.ts
index 030addb3ed..eab940a388 100644
--- a/server/core/src/stats.ts
+++ b/server/core/src/stats.ts
@@ -99,7 +99,6 @@ export function initStatisticsContext (
       console.info('storing measurements into local file', metricsFile)
     }
     let oldMetricsValue = ''
-    const token = generateToken(systemAccountEmail, { name: '' }, { service: 'true' })
     const serviceId = encodeURIComponent(os.hostname() + '-' + serviceName)
 
     const intTimer = setInterval(() => {
@@ -118,6 +117,7 @@ export function initStatisticsContext (
         }
       }
       if (statsUrl !== undefined) {
+        const token = generateToken(systemAccountEmail, { name: '' }, { service: 'true' })
         const data: ServiceStatistics = {
           serviceName,
           cpu: getCPUInfo(),