Home / Function/ record() — astro Function Reference

record() — astro Function Reference

Architecture documentation for the record() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  5766783d_2be8_71c5_51a9_81e029a6eac4["record()"]
  aa586462_b436_2ea0_2f45_107a3d7bae01["AstroTelemetry"]
  5766783d_2be8_71c5_51a9_81e029a6eac4 -->|defined in| aa586462_b436_2ea0_2f45_107a3d7bae01
  style 5766783d_2be8_71c5_51a9_81e029a6eac4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/telemetry/src/index.ts lines 127–171

	async record(event: TelemetryEvent | TelemetryEvent[] = []) {
		const events: TelemetryEvent[] = Array.isArray(event) ? event : [event];
		if (events.length < 1) {
			return Promise.resolve();
		}

		// Skip recording telemetry if the feature is disabled
		if (this.isDisabled) {
			this.debug('[record] telemetry has been disabled');
			return Promise.resolve();
		}

		const meta: EventMeta = {
			...getSystemInfo({ astroVersion: this.astroVersion, viteVersion: this.viteVersion }),
		};

		const context: EventContext = {
			...this.anonymousProjectInfo,
			anonymousId: this.anonymousId,
			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'}`;
		}

		if (this.debug.enabled) {
			// Print to standard error to simplify selecting the output
			this.debug({ context, meta });
			this.debug(JSON.stringify(events, null, 2));
			// Do not send the telemetry data if debugging. Users may use this feature
			// to preview what data would be sent.
			return Promise.resolve();
		}
		return post({
			context,
			meta,
			events,
		}).catch((err) => {
			// Log the error to the debugger, but otherwise do nothing.
			this.debug(`Error sending event: ${err.message}`);
		});
	}

Domain

Subdomains

Frequently Asked Questions

What does record() do?
record() is a function in the astro codebase, defined in packages/telemetry/src/index.ts.
Where is record() defined?
record() is defined in packages/telemetry/src/index.ts at line 127.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free