(core) Endpoint to report on the latest version of stable grist-core image

Summary:
New endpoint `/api/version` that returns latest version of stable docker image in format:
```
{"latestVersion":"1.1.12","
  updatedAt":"2024-03-06T06:28:25.752337Z","
  isCritical":false,
 "updateURL":"https://hub.docker.com/r/gristlabs/grist"
}
```

It connects to docker hub API and reads the version from the tag lists endpoint.
Stores telemetry passed from the client such us: current version, deployment type, installationId and others.

Test Plan: Added new test

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D4220
This commit is contained in:
Jarosław Sadziński
2024-04-05 10:54:53 +02:00
parent ddc28e327b
commit bddbcddbef
7 changed files with 665 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ type Comparator = (val1: any, val2: any) => number;
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
*/
const collator = new Intl.Collator(undefined, {numeric: true});
function naturalCompare(val1: any, val2: any) {
export function naturalCompare(val1: any, val2: any) {
if (typeof val1 === 'string' && typeof val2 === 'string') {
return collator.compare(val1, val2);
}

View File

@@ -1740,6 +1740,22 @@ export const TelemetryContracts: TelemetryContracts = {
},
},
},
checkedUpdateAPI: {
category: "SelfHosted",
description: 'Triggered when the app checks for updates.',
minimumTelemetryLevel: Level.limited,
retentionPeriod: 'indefinitely',
metadataContracts: {
installationId: {
description: 'The installation id of the client.',
dataType: 'string',
},
deploymentType: {
description: 'The deployment type of the client.',
dataType: 'string',
},
},
}
};
type TelemetryContracts = Record<TelemetryEvent, TelemetryEventContract>;
@@ -1810,6 +1826,7 @@ export const TelemetryEvents = StringUnion(
'visitedForm',
'submittedForm',
'changedAccessRules',
'checkedUpdateAPI'
);
export type TelemetryEvent = typeof TelemetryEvents.type;
@@ -1824,7 +1841,8 @@ type TelemetryEventCategory =
| 'TeamSite'
| 'ProductVisits'
| 'AccessRules'
| 'WidgetUsage';
| 'WidgetUsage'
| 'SelfHosted';
interface TelemetryEventContract {
description: string;