import { posthog } from 'posthog-js';
export class PosthogTrackingProvider {
    constructor() {
        this.verbose = false;
    }
    initialize(props) {
        this.verbose = props.verbose;
        if (this.verbose) {
            // eslint-disable-next-line no-console
            console.log('PosthogProvider initialize');
        }
        const posthogKey = props.posthogKey;
        posthog.init(posthogKey, {
            // eslint-disable-next-line camelcase
            api_host: 'https://us.i.posthog.com',
            // eslint-disable-next-line camelcase
            person_profiles: 'identified_only' // or 'always' to create profiles for anonymous users as well
        });
    }
    identify(userID, userProperties = {}) {
        if (this.verbose) {
            // eslint-disable-next-line no-console
            console.log('PosthogProvider userID: ' + userID);
        }
        posthog.identify(userID, userProperties);
    }
    trackPageView(url) {
        if (this.verbose) {
            // eslint-disable-next-line no-console
            console.log('PostHogProvider url ', url);
        }
        // TODO posthog seems to record that automatically.
        //  How to not clash with this here? Just leave as no-op?
    }
    trackSingleItem(item, properties) {
        if (this.verbose) {
            // eslint-disable-next-line no-console
            console.log('PosthogProvider: trackSingleItem ' + item, properties);
        }
        posthog.capture(item, { properties });
    }
}
