import posthog from "posthog-js";
export default class Analytics {
    get isInitialized() {
        return this._isInitialized;
    }
    set isInitialized(v) {
        this._isInitialized = v;
    }
    constructor(apiHost, apiKey) {
        this._isInitialized = false;
        if (apiHost && apiKey) {
            posthog.init(apiKey, { api_host: apiHost, autocapture: false });
            this.isInitialized = true;
        }
    }
    userAuth(email) {
        if (!this.isInitialized) {
            return;
        }
        posthog.identify(email.toString());
    }
    logout() {
        if (!this.isInitialized) {
            return;
        }
        posthog.reset();
    }
    capture(eventName, data) {
        if (!this.isInitialized) {
            return;
        }
        // PostHog tracking
        posthog.capture(eventName, data);
        // GA4 tracking via dataLayer (for Google Analytics conversion tracking)
        if (typeof window !== "undefined" && window.dataLayer) {
            window.dataLayer.push(Object.assign({ event: eventName, eventCategory: "analytics", eventAction: eventName }, (data || {})));
        }
    }
}
//# sourceMappingURL=Analytics.js.map