@@ -14,7 +14,6 @@ import {
1414 CancelableInterval ,
1515 createCancelableInterval ,
1616 formatDuration ,
17- getAnonymousId ,
1817 getEnv ,
1918 assertDataSource ,
2019 getRealType ,
@@ -59,7 +58,7 @@ import type {
5958 LoggerFn ,
6059 DriverConfig ,
6160 ScheduledRefreshTimeZonesFn ,
62- ContextToCubeStoreRouterIdFn ,
61+ ContextToCubeStoreRouterIdFn , LoggerEventParams ,
6362} from './types' ;
6463import {
6564 ContextToOrchestratorIdFn ,
@@ -171,8 +170,6 @@ export class CubejsServerCore {
171170
172171 public projectFingerprint : string | null = null ;
173172
174- public anonymousId : string | null = null ;
175-
176173 public coreServerVersion : string | null = null ;
177174
178175 protected contextAcceptor : ContextAcceptor ;
@@ -233,7 +230,7 @@ export class CubejsServerCore {
233230
234231 this . startScheduledRefreshTimer ( ) ;
235232
236- this . event = async ( name , props ) => {
233+ this . event = async ( event , props : LoggerEventParams ) => {
237234 if ( ! this . options . telemetry ) {
238235 return ;
239236 }
@@ -248,15 +245,12 @@ export class CubejsServerCore {
248245 }
249246 }
250247
251- if ( ! this . anonymousId ) {
252- this . anonymousId = getAnonymousId ( ) ;
253- }
254-
255248 const internalExceptionsEnv = getEnv ( 'internalExceptions' ) ;
256249
257250 try {
258251 await track ( {
259- event : name ,
252+ timestamp : new Date ( ) . toJSON ( ) ,
253+ event,
260254 projectFingerprint : this . projectFingerprint ,
261255 coreServerVersion : this . coreServerVersion ,
262256 dockerVersion : getEnv ( 'dockerImageVersion' ) ,
@@ -410,7 +404,12 @@ export class CubejsServerCore {
410404 if ( agentEndpointUrl ) {
411405 const oldLogger = this . logger ;
412406 this . preAgentLogger = oldLogger ;
407+
413408 this . logger = ( msg , params ) => {
409+ // Filling timestamp as much as earlier as we can, otherwise it can be incorrect. Because next code is async
410+ // with await points which can be delayed with Node.js micro-tasking.
411+ params . timestamp = params . timestamp || new Date ( ) . toJSON ( ) ;
412+
414413 oldLogger ( msg , params ) ;
415414 agentCollect (
416415 {
0 commit comments