@stacksjs/stx
Version:
A performant UI Framework. Powered by Bun.
92 lines • 2.57 kB
TypeScript
/**
* Generate analytics dashboard HTML
*/
export declare function getAnalyticsDashboardHtml(mostViewed: Array<{ componentId: string, viewCount: number }>, mostChangedProps: Array<{ propName: string, changeCount: number }>): string;
/**
* Generate analytics styles
*/
export declare function getAnalyticsStyles(): string;
/**
* Analytics event
*/
export declare interface AnalyticsEvent {
type: AnalyticsEventType
timestamp: number
componentId?: string
variantId?: string
propName?: string
query?: string
metadata?: Record<string, any>
}
/**
* Component analytics summary
*/
export declare interface ComponentAnalytics {
componentId: string
componentName: string
viewCount: number
uniqueViews: number
lastViewed?: number
propChanges: Record<string, number>
topChangedProps: string[]
variantViews: Record<string, number>
avgTimeSpent: number
}
/**
* Analytics storage
*/
export declare interface AnalyticsStorage {
version: number
events: AnalyticsEvent[]
sessions: AnalyticsSession[]
}
/**
* Analytics session
*/
export declare interface AnalyticsSession {
id: string
startTime: number
endTime?: number
componentViews: string[]
}
/**
* Analytics event types
*/
export type AnalyticsEventType = | 'view'
| 'prop_change'
| 'variant_switch'
| 'search'
| 'bookmark'
| 'copy_code'
| 'test_run'
/**
* Analytics tracker
*/
export declare class AnalyticsTracker {
private storage: AnalyticsStorage;
private storagePath: string;
private currentSession: AnalyticsSession | null;
private dirty: any;
private viewStartTimes: any;
constructor(rootDir: string);
private loadStorage(): AnalyticsStorage;
save(): Promise<void>;
startSession(): void;
endSession(): void;
track(event: Omit<AnalyticsEvent, 'timestamp'>): void;
trackView(componentId: string, variantId?: string): void;
private endViewTiming(componentId: string): void;
trackPropChange(componentId: string, propName: string, value: any): void;
trackVariantSwitch(componentId: string, variantId: string): void;
trackSearch(query: string, resultCount: number): void;
getComponentAnalytics(componentId: string, componentName: string): ComponentAnalytics;
getMostViewedComponents(limit?: any): Array<{ componentId: string, viewCount: number }>;
getMostChangedProps(limit?: any): Array<{ propName: string, changeCount: number }>;
getSearchAnalytics(): {
totalSearches: number
topQueries: Array<{ query: string, count: number }>
avgResultCount: number
};
clear(): void;
exportAnalytics(): string;
}