(core) add a cli command to view telemetry settings

Summary:
This adds a `yarn cli settings telemetry [--json] [--all]` command
that allows telemetry settings to be inspected. It is useful for
keeping documentation about telemetry up to date.

Test Plan:
manual (a bit cheeky; justified on basis of breakage
not being very important yet, this is essentially an internal
feature)

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3917
This commit is contained in:
Paul Fitzpatrick
2023-06-09 17:30:38 -04:00
parent 2b3e31a05c
commit c5e750abc6
2 changed files with 94 additions and 3 deletions

View File

@@ -162,11 +162,9 @@ export class Telemetry implements ITelemetry {
}
private async _initialize() {
this._telemetryLevel = getTelemetryLevel();
if (process.env.GRIST_TELEMETRY_LEVEL !== undefined) {
this._telemetryLevel = TelemetryLevels.check(process.env.GRIST_TELEMETRY_LEVEL);
this._checkTelemetryEvent = buildTelemetryEventChecker(this._telemetryLevel);
} else {
this._telemetryLevel = 'off';
}
const {id} = await this._gristServer.getActivations().current();
@@ -218,3 +216,11 @@ export class Telemetry implements ITelemetry {
});
}
}
export function getTelemetryLevel(): TelemetryLevel {
if (process.env.GRIST_TELEMETRY_LEVEL !== undefined) {
return TelemetryLevels.check(process.env.GRIST_TELEMETRY_LEVEL);
} else {
return 'off';
}
}