mastra
Version:
cli for mastra
50 lines • 1.81 kB
TypeScript
export type CLI_ORIGIN = 'mastra-cloud' | 'oss';
/**
* Bucket the Mastra platform API host into coarse labels for analytics.
*
* We report the *category* of API surface a deploy is talking to (cloud,
* staging, localhost, custom, unknown) rather than the raw host, so
* self-hosted or internal domains are never leaked to telemetry.
*/
export declare function bucketApiHost(apiUrl: string): 'cloud' | 'staging' | 'localhost' | 'custom' | 'unknown';
export declare function getAnalytics(): PosthogAnalytics | null;
export declare function setAnalytics(instance: PosthogAnalytics): void;
export declare class PosthogAnalytics {
private sessionId;
private client?;
private distinctId;
private version;
private packageManager;
constructor({ version, apiKey, host, }: {
version: string;
apiKey: string;
host: string;
});
private getOrCreateAnalyticsConfig;
private writeCliConfig;
private initializePostHog;
private static isTelemetryEnabled;
private createDistinctId;
private isHostnameDerivedDistinctId;
private getSystemProperties;
private getDurationMs;
private captureSessionStart;
getDistinctId(): string;
trackEvent(eventName: string, properties?: Record<string, any>): void;
trackCommand(options: {
command: string;
args?: Record<string, unknown>;
durationMs?: number;
status?: 'success' | 'error';
error?: string;
origin?: CLI_ORIGIN;
}): void;
trackCommandExecution<T>({ command, args, execution, origin, }: {
command: string;
args: Record<string, unknown>;
execution: () => Promise<T>;
origin?: CLI_ORIGIN;
}): Promise<T>;
shutdown(timeoutMs?: number): Promise<void>;
}
//# sourceMappingURL=index.d.ts.map