From 2f855d69c855d81a73fcd9af53b8d00c4ac5cb4f Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Fri, 9 Feb 2024 11:45:32 +0100 Subject: [PATCH] fix(logging): remove userId from identify and track COMPASS-7607 (#1814) --- .../logging/src/setup-logger-and-telemetry.ts | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/logging/src/setup-logger-and-telemetry.ts b/packages/logging/src/setup-logger-and-telemetry.ts index 7f3d24a10..8fbf3a020 100644 --- a/packages/logging/src/setup-logger-and-telemetry.ts +++ b/packages/logging/src/setup-logger-and-telemetry.ts @@ -111,15 +111,9 @@ export function setupLoggerAndTelemetry( session_id, }; - const getTelemetryUserIdentity = () => { - if (telemetryAnonymousId) { - return { - anonymousId: telemetryAnonymousId, - }; - } - - return { userId }; - }; + const getTelemetryUserIdentity = () => ({ + anonymousId: telemetryAnonymousId ?? userId, + }); // We emit different analytics events for loading files and evaluating scripts // depending on whether we're already in the REPL or not yet. We store the @@ -219,17 +213,13 @@ export function setupLoggerAndTelemetry( }) { if (updatedTelemetryUserIdentity.anonymousId) { telemetryAnonymousId = updatedTelemetryUserIdentity.anonymousId; - analytics.identify({ - anonymousId: updatedTelemetryUserIdentity.anonymousId, - traits: userTraits, - }); } else { userId = updatedTelemetryUserIdentity.userId; - analytics.identify({ - userId: updatedTelemetryUserIdentity.userId, - traits: userTraits, - }); } + analytics.identify({ + ...getTelemetryUserIdentity(), + traits: userTraits, + }); log.info('MONGOSH', mongoLogId(1_000_000_005), 'config', 'User updated'); } );