diff options
author | 2022-06-29 14:54:33 -0700 | |
---|---|---|
committer | 2022-06-29 14:54:33 -0700 | |
commit | dd176ca58d9ce8ab757075491568a014c0943de2 (patch) | |
tree | 4240e17b97b37627653f96ca416041f60cbb30ec /packages/telemetry/src | |
parent | 1eab496e9d733a13f3a2eb2129e90949b130901d (diff) | |
download | astro-dd176ca58d9ce8ab757075491568a014c0943de2.tar.gz astro-dd176ca58d9ce8ab757075491568a014c0943de2.tar.zst astro-dd176ca58d9ce8ab757075491568a014c0943de2.zip |
add error event to telemetry (#3750)
Diffstat (limited to '')
-rw-r--r-- | packages/telemetry/src/index.ts | 15 | ||||
-rw-r--r-- | packages/telemetry/src/system-info.ts | 11 |
2 files changed, 20 insertions, 6 deletions
diff --git a/packages/telemetry/src/index.ts b/packages/telemetry/src/index.ts index f0315e16c..0bba53e5a 100644 --- a/packages/telemetry/src/index.ts +++ b/packages/telemetry/src/index.ts @@ -7,7 +7,7 @@ import { post } from './post.js'; import { getProjectInfo, ProjectInfo } from './project-info.js'; import { getSystemInfo, SystemInfo } from './system-info.js'; -export type AstroTelemetryOptions = { version: string }; +export type AstroTelemetryOptions = { astroVersion: string; viteVersion: string }; export type TelemetryEvent = { eventName: string; payload: Record<string, any> }; interface EventContext { anonymousId: string; @@ -25,7 +25,10 @@ export class AstroTelemetry { private debug = debug('astro:telemetry'); private get astroVersion() { - return this.opts.version; + return this.opts.astroVersion; + } + private get viteVersion() { + return this.opts.viteVersion; } private get ASTRO_TELEMETRY_DISABLED() { return process.env.ASTRO_TELEMETRY_DISABLED; @@ -131,7 +134,7 @@ export class AstroTelemetry { } const meta: EventMeta = { - ...getSystemInfo(this.astroVersion), + ...getSystemInfo({ astroVersion: this.astroVersion, viteVersion: this.viteVersion }), isGit: this.anonymousProjectInfo.isGit, }; @@ -141,6 +144,12 @@ export class AstroTelemetry { anonymousSessionId: this.anonymousSessionId, }; + // Every CI session also creates a new user, which blows up telemetry. + // To solve this, we track all CI runs under a single "CI" anonymousId. + if (meta.isCI) { + context.anonymousId = `CI.${meta.ciName || 'UNKNOWN'}`; + } + return post({ context, meta, diff --git a/packages/telemetry/src/system-info.ts b/packages/telemetry/src/system-info.ts index 9fe628ff0..5ff3b9559 100644 --- a/packages/telemetry/src/system-info.ts +++ b/packages/telemetry/src/system-info.ts @@ -31,6 +31,9 @@ export type SystemInfo = { systemPlatform: NodeJS.Platform; systemRelease: string; systemArchitecture: string; + astroVersion: string; + nodeVersion: string; + viteVersion: string; cpuCount: number; cpuModel: string | null; cpuSpeed: number | null; @@ -39,18 +42,21 @@ export type SystemInfo = { isWSL: boolean; isCI: boolean; ciName: string | null; - astroVersion: string; }; let meta: SystemInfo | undefined; -export function getSystemInfo(astroVersion: string): SystemInfo { +export function getSystemInfo(versions: {viteVersion: string, astroVersion: string}): SystemInfo { if (meta) { return meta; } const cpus = os.cpus() || []; meta = { + // Version information + nodeVersion: process.version.replace(/^v?/, ''), + viteVersion: versions.viteVersion, + astroVersion: versions.astroVersion, // Software information systemPlatform: os.platform(), systemRelease: os.release(), @@ -65,7 +71,6 @@ export function getSystemInfo(astroVersion: string): SystemInfo { isWSL, isCI, ciName, - astroVersion, }; return meta!; |