"use client";

interface AnalyticsEvent {
  name: string;
  properties?: Record<string, any>;
}

class Analytics {
  private events: AnalyticsEvent[] = [];

  track(eventName: string, properties?: Record<string, any>) {
    const event: AnalyticsEvent = {
      name: eventName,
      properties,
    };

    this.events.push(event);

    // Log in development
    if (process.env.NODE_ENV === "development") {
      console.log("Analytics Event:", event);
    }

    // Here you can integrate with analytics services like:
    // - Google Analytics
    // - Plausible
    // - Vercel Analytics
    // - Custom analytics endpoint
  }

  pageView(path: string) {
    this.track("page_view", { path });
  }

  scroll(depth: number) {
    this.track("scroll", { depth });
  }

  click(element: string) {
    this.track("click", { element });
  }

  getEvents() {
    return this.events;
  }

  clear() {
    this.events = [];
  }
}

export const analytics = new Analytics();






