import { createConsoleAdapter } from './consoleAdapter';
import type { AnalyticsAdapter, AnalyticsParams } from './types';
import { env } from '../../config/env';

let _adapter: AnalyticsAdapter | null = null;

export function initAnalytics(debug = env.isDev): void {
  _adapter = createConsoleAdapter(debug);
  _adapter.init();
}

export function trackGameEvent(eventName: string, params: AnalyticsParams = {}): void {
  _adapter?.track(eventName, params);
}

export type { AnalyticsAdapter, AnalyticsParams };
