Add telemtery cli arg

This commit is contained in:
Andras Schmelczer 2025-11-18 22:17:34 +00:00
commit 3729778b12
3 changed files with 13 additions and 3 deletions

View file

@ -13,6 +13,7 @@ export interface CliArgs {
webSocketRetryIntervalMs?: number; webSocketRetryIntervalMs?: number;
logLevel: LogLevel; logLevel: LogLevel;
health?: string; health?: string;
enableTelemetry?: boolean;
} }
export function parseArgs(argv: string[]): CliArgs { export function parseArgs(argv: string[]): CliArgs {
@ -56,6 +57,10 @@ export function parseArgs(argv: string[]): CliArgs {
"--health <path>", "--health <path>",
"[OPTIONAL] Path to health status file for Docker healthcheck" "[OPTIONAL] Path to health status file for Docker healthcheck"
) )
.option(
"--enable-telemetry",
"[OPTIONAL] Enable telemetry (disabled by default)"
)
.addHelpText( .addHelpText(
"after", "after",
` `
@ -84,6 +89,7 @@ Examples:
| undefined; | undefined;
const logLevelStr = (opts.logLevel as string | undefined) ?? "INFO"; const logLevelStr = (opts.logLevel as string | undefined) ?? "INFO";
const health = opts.health as string | undefined; const health = opts.health as string | undefined;
const enableTelemetry = opts.enableTelemetry as boolean | undefined;
/* eslint-enable @typescript-eslint/no-unsafe-type-assertion */ /* eslint-enable @typescript-eslint/no-unsafe-type-assertion */
if (localPath === undefined) { if (localPath === undefined) {
@ -124,6 +130,7 @@ Examples:
ignorePatterns: ignorePattern, ignorePatterns: ignorePattern,
webSocketRetryIntervalMs: websocketRetryIntervalMs, webSocketRetryIntervalMs: websocketRetryIntervalMs,
logLevel, logLevel,
health health,
enableTelemetry
}; };
} }

View file

@ -98,7 +98,8 @@ async function main(): Promise<void> {
webSocketRetryIntervalMs: webSocketRetryIntervalMs:
args.webSocketRetryIntervalMs ?? args.webSocketRetryIntervalMs ??
DEFAULT_SETTINGS.webSocketRetryIntervalMs, DEFAULT_SETTINGS.webSocketRetryIntervalMs,
isSyncEnabled: true isSyncEnabled: true,
enableTelemetry: args.enableTelemetry ?? false
}; };
const client = await SyncClient.create({ const client = await SyncClient.create({

View file

@ -26,6 +26,8 @@ export const setUpTelemetry = (): (() => void) => {
return (): void => { return (): void => {
window.removeEventListener("error", onError); window.removeEventListener("error", onError);
window.removeEventListener("unhandledrejection", onUnhandledRejection); window.removeEventListener("unhandledrejection", onUnhandledRejection);
Sentry.close(5000); Sentry.close(5000).catch(() => {
// Ignore errors during shutdown
});
}; };
}; };