Files
SnapOtter/packages/shared/src/analytics/events.ts
T
SnapOtter 979a833978 fix: resolve analytics data gaps and resize validation failures
- Fix resize 20% failure rate: add Zod refine requiring at least one
  dimension, enforce integer/max constraints, clamp percentage scaling
  to minimum 1px, and guard against missing metadata in withoutEnlargement
- Fix PostHog init race condition: move consent check before async import
  so frontend events (search, pageview) are no longer silently dropped
- Fix identify() passing nested $set/$set_once wrappers instead of flat
  properties, so version person property now appears on PostHog profiles
- Add error_code and error_message to failed tool_used analytics events
  for debugging tool failures from PostHog
2026-05-06 23:21:45 +08:00

41 lines
958 B
TypeScript

export const ANALYTICS_EVENTS = {
TOOL_USED: "tool_used",
SEARCH: "search",
PIPELINE_EXECUTED: "pipeline_executed",
AI_BUNDLE_ACTION: "ai_bundle_action",
} as const;
export type AnalyticsEvent = (typeof ANALYTICS_EVENTS)[keyof typeof ANALYTICS_EVENTS];
export interface ToolUsedProperties {
tool_id: string;
status: "completed" | "failed";
duration_ms: number;
category: string;
is_ai_tool: boolean;
params?: Record<string, string | number | boolean>;
error_code?: string;
error_message?: string;
}
export interface SearchProperties {
query: string;
results_count: number;
clicked_tool_id?: string;
}
export interface PipelineExecutedProperties {
step_count: number;
tool_ids: string[];
is_batch: boolean;
file_count?: number;
duration_ms: number;
status: "completed" | "failed";
}
export interface AiBundleActionProperties {
bundle_id: string;
action: "installed" | "uninstalled";
duration_ms: number;
}