import {AnalyticsEvent, BaseAnalytics} from "./Analytics";

export class LogAnalytics extends BaseAnalytics {
  public name = 'LogAnalytics';
  private events: AnalyticsEvent[] = [];

  track(name: string, data?: Record<string, any>): void {
    const event = { name, ts: this.getTimestamp(), data };
    console.log('[Analytics]', event);
    this.events.push(event);
  }

  flush(): void {
    if (this.events.length === 0) return;
    console.table(this.events);
    this.events = [];
  }
}
