(core) Enabling telemetry on /api/version endpoint

Summary:
Version API endpoint wasn't logging telemetry from POST requests. The issue was in registration
order, this endpoint was registered before `expressJson` and it couldn't read json body in the handler.

Test Plan: Added new test

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D4277
This commit is contained in:
Jarosław Sadziński
2024-06-26 15:49:13 +02:00
parent 05214d8f9a
commit 184be9387f
8 changed files with 41 additions and 27 deletions

View File

@@ -1971,7 +1971,7 @@ export class FlexServer implements GristServer {
}
public addUpdatesCheck() {
if (this._check('update')) { return; }
if (this._check('update', 'json')) { return; }
// For now we only are active for sass deployments.
if (this._deploymentType !== 'saas') { return; }

View File

@@ -85,15 +85,12 @@ export class UpdateManager {
const payload = (name: string) => req.body?.[name] ?? req.query[name];
// 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.
// with the version of the client.
const deploymentId = optStringParam(
payload("installationId"),
"installationId"
);
// Current version of grist-core part of the client. Currently not used and not
// passed from the client.
// Deployment type of the client (we expect this to be 'core' for most of the cases).
const deploymentType = optStringParam(
payload("deploymentType"),

View File

@@ -106,7 +106,6 @@ export async function main(port: number, serverTypes: ServerType[],
server.addHealthCheck();
if (includeHome || includeApp) {
server.addBootPage();
server.addUpdatesCheck();
}
server.denyRequestsIfNotReady();
@@ -148,6 +147,7 @@ export async function main(port: number, serverTypes: ServerType[],
server.addDocApiForwarder();
}
server.addJsonSupport();
server.addUpdatesCheck();
await server.addLandingPages();
// todo: add support for home api to standalone app
server.addHomeApi();