diff options
Diffstat (limited to '')
-rw-r--r-- | packages/telemetry/src/index.ts | 15 |
1 files changed, 12 insertions, 3 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, |