@@ -14,7 +14,6 @@ import {
1414 CancelableInterval ,
1515 createCancelableInterval ,
1616 formatDuration ,
17- getAnonymousId ,
1817 getEnv ,
1918 assertDataSource ,
2019 getRealType ,
@@ -31,7 +30,7 @@ import { RefreshScheduler, ScheduledRefreshOptions } from './RefreshScheduler';
3130import { OrchestratorApi , OrchestratorApiOptions } from './OrchestratorApi' ;
3231import { CompilerApi } from './CompilerApi' ;
3332import { DevServer } from './DevServer' ;
34- import agentCollect from './agentCollect' ;
33+ import { agentCollect } from './agentCollect' ;
3534import { OrchestratorStorage } from './OrchestratorStorage' ;
3635import { prodLogger , devLogger } from './logger' ;
3736import { OptsHandler } from './OptsHandler' ;
@@ -60,6 +59,7 @@ import type {
6059 DriverConfig ,
6160 ScheduledRefreshTimeZonesFn ,
6261 ContextToCubeStoreRouterIdFn ,
62+ LoggerFnParams ,
6363} from './types' ;
6464import {
6565 ContextToOrchestratorIdFn ,
@@ -171,8 +171,6 @@ export class CubejsServerCore {
171171
172172 public projectFingerprint : string | null = null ;
173173
174- public anonymousId : string | null = null ;
175-
176174 public coreServerVersion : string | null = null ;
177175
178176 protected contextAcceptor : ContextAcceptor ;
@@ -233,7 +231,7 @@ export class CubejsServerCore {
233231
234232 this . startScheduledRefreshTimer ( ) ;
235233
236- this . event = async ( name , props ) => {
234+ this . event = async ( event , props : LoggerFnParams ) => {
237235 if ( ! this . options . telemetry ) {
238236 return ;
239237 }
@@ -248,15 +246,12 @@ export class CubejsServerCore {
248246 }
249247 }
250248
251- if ( ! this . anonymousId ) {
252- this . anonymousId = getAnonymousId ( ) ;
253- }
254-
255249 const internalExceptionsEnv = getEnv ( 'internalExceptions' ) ;
256250
257251 try {
258252 await track ( {
259- event : name ,
253+ timestamp : new Date ( ) . toJSON ( ) ,
254+ event,
260255 projectFingerprint : this . projectFingerprint ,
261256 coreServerVersion : this . coreServerVersion ,
262257 dockerVersion : getEnv ( 'dockerImageVersion' ) ,
@@ -410,7 +405,12 @@ export class CubejsServerCore {
410405 if ( agentEndpointUrl ) {
411406 const oldLogger = this . logger ;
412407 this . preAgentLogger = oldLogger ;
408+
413409 this . logger = ( msg , params ) => {
410+ // Filling timestamp as much as earlier as we can, otherwise it can be incorrect. Because next code is async
411+ // with await points which can be delayed with Node.js micro-tasking.
412+ params . timestamp = params . timestamp || new Date ( ) . toJSON ( ) ;
413+
414414 oldLogger ( msg , params ) ;
415415 agentCollect (
416416 {
0 commit comments