@shopify/cli-kit
Version:
A set of utilities, interfaces, and models that are common across all the platform features
93 lines (92 loc) • 3.18 kB
TypeScript
import { RuntimeData } from '../../private/node/analytics/storage.js';
import { Interfaces } from '@oclif/core';
export type CommandExitMode = 'ok' | 'unexpected_error' | 'expected_error';
interface ReportAnalyticsEventOptions {
config: Interfaces.Config;
errorMessage?: string;
exitMode: CommandExitMode;
}
/**
* Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.
*
* The payload for an event includes both generic data, and data gathered from installed plug-ins.
*
*/
export declare function reportAnalyticsEvent(options: ReportAnalyticsEventOptions): Promise<void>;
/**
* Records timing data for performance monitoring. Call twice with the same
* event name to start and stop timing. First call starts the timer, second
* call stops it and records the duration.
*
* @example
* ```ts
* recordTiming('theme-upload') // Start timing
* // ... do work ...
* recordTiming('theme-upload') // Stop timing and record duration
* ```
*
* @param eventName - Unique identifier for the timing event
*/
export declare function recordTiming(eventName: string): void;
/**
* Records error information for debugging and monitoring. Use this to track
* any exceptions or error conditions that occur during theme operations.
* Errors are automatically categorized for easier analysis.
*
* @example
* ```ts
* try {
* // ... risky operation ...
* } catch (error) {
* recordError(error)
* }
* ```
*
* @param error - Error object or message to record
*/
export declare function recordError<T>(error: T): T;
/**
* Records retry attempts for network operations. Use this to track when
* operations are retried due to transient failures. Helps identify
* problematic endpoints or operations that frequently fail.
*
* @example
* ```ts
* recordRetry('https://api.shopify.com/themes', 'upload')
* ```
*
* @param url - The URL or endpoint being retried
* @param operation - Description of the operation being retried
*/
export declare function recordRetry(url: string, operation: string): void;
/**
* Records custom events for tracking specific user actions or system events.
* Use this for important milestones, user interactions, or significant
* state changes in the application.
*
* @example
* ```ts
* recordEvent('theme-dev-started')
* recordEvent('file-watcher-connected')
* ```
*
* @param eventName - Descriptive name for the event
*/
export declare function recordEvent(eventName: string): void;
/**
* Compiles and returns all runtime analytics data collected during the session.
* This includes timing measurements, error records, retry attempts, and custom
* events. Use this to retrieve a complete snapshot of analytics data for
* reporting or debugging purposes.
*
* @example
* ```ts
* const analyticsData = compileData()
* console.log(`Recorded ${analyticsData.timings.length} timing events`)
* console.log(`Recorded ${analyticsData.errors.length} errors`)
* ```
*
* @returns Object containing all collected analytics data including timings, errors, retries, and events
*/
export declare function compileData(): RuntimeData;
export {};