import { AnalyticEvent } from "./event"; /** * AnalyticsConfig is the configuration for the analytics collection */ export interface AnalyticsConfig { /** user's anonymous id */ anonymousId: string; /** boolean flag to determine if user has already been given a disclaimer message */ disclaimerDisplayed?: boolean; /** displayed version of the disclaimer */ disclaimerVersion?: string; /** optional opt out value */ optOut?: boolean; } /** * Props for AnalyticsStorage, mostly used for testing and debugging */ interface AnalyticsStorageProps { /** * directory to store * @default path.join(os.tmpdir(), "wing-analytics") */ analyticsStorageDir?: string; /** * path to analytics config file * @default path.join(path.join(WING_HOME_DIR, 'wing-analytics-config.json')) */ configFile?: string; /** * debug flag for verbose logging when storing and retrieving analytics events * @default false */ debug?: boolean; } /** * Storage class used to encapsulate the storage and retrieval of analytics events * and configuration. Errors are ignored for the most part unless in debug mode. */ export declare class AnalyticsStorage { analyticsStorageDir: string; analyticsConfigFile: string; analyticsConfig: AnalyticsConfig; debug?: boolean; constructor(props?: AnalyticsStorageProps); /** * Stores a single analytic event to disk * * @param event the analytic event to save * @returns the path to the saved event or undefined if there was an error */ storeAnalyticEvent(event: AnalyticEvent): string | undefined; /** * Retrieves an analytic event from disk * * @param filePath the path the event was saved to * @returns the event or undefined if there was an error */ loadEvent(filePath: string): AnalyticEvent | undefined; /** * Reads the analytics config for the user's anonymous id, * if an id does not exist, one is generated and saved to disk * * @returns the anonymous id for the user */ getAnonymousId(): string; private generateAnonymousId; /** * Retrieves the analytics config from disk, if one does not exist * a new one is created and saved to disk * * @returns the analytics config for the user */ loadConfig(): AnalyticsConfig; /** * Saves the analytics config to disk * * @param config the analytics config to save to disk */ saveConfig(config: AnalyticsConfig): void; /** * Helper method to flatten objects * * @param properties The properties to flatten * @param parentKey The key of the parent (defaults to "") * @returns */ private flattenProperties; private saveEvent; } export {};