From 98176132b0736f03046c78bde9654ae4d80cefc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Wed, 12 Jun 2024 11:33:13 +0200 Subject: [PATCH] (core) Renaming installationId metadata for checkUpdateAPI telemetry endpoint. Summary: CheckUpdateAPI is now storing client's installation id in a new field called 'deploymentId'. Previously it was using installationId which is reserved (and overriden) by the home server. Test Plan: Existing and manual Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D4268 --- app/common/Telemetry.ts | 2 +- app/server/lib/Telemetry.ts | 11 +++++++++++ app/server/lib/UpdateManager.ts | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/common/Telemetry.ts b/app/common/Telemetry.ts index 328a3c7e..aab28a27 100644 --- a/app/common/Telemetry.ts +++ b/app/common/Telemetry.ts @@ -1746,7 +1746,7 @@ export const TelemetryContracts: TelemetryContracts = { minimumTelemetryLevel: Level.limited, retentionPeriod: 'indefinitely', metadataContracts: { - installationId: { + deploymentId: { description: 'The installation id of the client.', dataType: 'string', }, diff --git a/app/server/lib/Telemetry.ts b/app/server/lib/Telemetry.ts index edef1912..6d341600 100644 --- a/app/server/lib/Telemetry.ts +++ b/app/server/lib/Telemetry.ts @@ -334,6 +334,17 @@ export class Telemetry implements ITelemetry { try { this._numPendingForwardEventRequests += 1; const {category: eventCategory} = TelemetryContracts[event]; + + if (metadata) { + if ('installationId' in metadata || + 'eventSource' in metadata || + 'eventName' in metadata || + 'eventCategory' in metadata) + { + throw new Error('metadata contains reserved keys'); + } + } + await this._doForwardEvent(JSON.stringify({ event, metadata: { diff --git a/app/server/lib/UpdateManager.ts b/app/server/lib/UpdateManager.ts index 47556b74..c7ac9f67 100644 --- a/app/server/lib/UpdateManager.ts +++ b/app/server/lib/UpdateManager.ts @@ -86,7 +86,7 @@ export class UpdateManager { // This is the most interesting part for us, to track installation ids and match them // with the version of the client. Won't be send without telemetry opt in. - const installationId = optStringParam( + const deploymentId = optStringParam( payload("installationId"), "installationId" ); @@ -104,8 +104,8 @@ export class UpdateManager { .getTelemetry() .logEvent(req as RequestWithLogin, "checkedUpdateAPI", { full: { - installationId, - deploymentType, + deploymentId, + deploymentType }, });