All files / lib/analytics types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                                                               
/**
 * Analytics Types
 * Types used by the analytics sync job
 */
 
export interface ProStats {
	pro_id: string;
	page_views: number;
	project_clicks: number;
	image_clicks: number;
	whatsapp_clicks: number;
	call_clicks: number;
	inquiry_clicks: number;
	unique_sessions: number;
	sources: Record<string, number>;
	devices: Record<string, number>;
	cities: Record<string, number>;
}
 
export interface ProjectStats {
	project_id: string;
	pro_id: string;
	page_views: number;
	image_clicks: number;
	unique_sessions: number;
}
 
export interface AnalyticsQueryResult {
	data: Array<Record<string, unknown>>;
	meta: { name: string; type: string }[];
	rows: number;
}
 
/**
 * Environment variables needed for analytics sync:
 * - CLOUDFLARE_ACCOUNT_ID: Cloudflare account ID (set as var in wrangler.jsonc)
 * - CLOUDFLARE_API_TOKEN: API token with Analytics Engine read permissions (set as secret)
 * - ANALYTICS_DATASET: Name of the Analytics Engine dataset (defaults to 'dr-local-events')
 */
export interface AnalyticsSyncEnv {
	DB: D1Database;
	ANALYTICS: AnalyticsEngineDataset;
	KV_CACHE?: KVNamespace;
	CLOUDFLARE_ACCOUNT_ID?: string;
	CLOUDFLARE_API_TOKEN?: string;
	ANALYTICS_DATASET?: string;
}