import { initializeApp } from "firebase/app";
import { getAnalytics, logEvent } from "firebase/analytics";


export class FirebaseUtil {
  constructor() {
    if (FirebaseUtil.instance) {
      return FirebaseUtil.instance;
    }
  
    this.initFirebase();
    FirebaseUtil.instance = this;
  }

  initFirebase() {
    const firebaseConfig = {
      apiKey: "AIzaSyDGqbzmXY_Uc5-CDPHoDT1SwkNJ_H-RMBQ",
      authDomain: "counterfire-98814.firebaseapp.com",
      projectId: "counterfire-98814",
      storageBucket: "counterfire-98814.appspot.com",
      messagingSenderId: "48010807157",
      appId: "1:48010807157:web:8d1f6aae9a28f37a4fb53c",
      measurementId: "G-M2VSRXJD71"
    };
    
    // Initialize Firebase
    this.app = initializeApp(firebaseConfig);
    this.analytics = getAnalytics(this.app);
  }

  uploadEvent(event, data) {
    logEvent(this.analytics, event, data);
  }
}