import eventTrackingApi from '../api/event-tracking.api';
import sessionQuery from './session.query';
export class EventTrackingService {
  async trackAppLoadedAsync() {
    return this.trackEventAsync('appLoaded');
  }
  async trackInputChangedAsync(event) {
    return this.trackEventAsync({ inputChanged: event });
  }
  async trackStepProgressedAsync(event) {
    return this.trackEventAsync({ stepProgressed: event });
  }
  async trackModalViewedAsync(event) {
    return this.trackEventAsync({ modalViewed: event });
  }
  async trackModalClosedAsync(event) {
    return this.trackEventAsync({ modalClosed: event });
  }
  async trackFormSubmittedAsync(event) {
    return this.trackEventAsync({ formSubmitted: event });
  }
  async trackPrivacyPolicyViewedAsync() {
    return this.trackEventAsync('privacyPolicyViewed');
  }
  async trackEventAsync(event) {
    try {
      await eventTrackingApi.postAnalyticsEventAsync({
        event,
        distinctId: sessionQuery.distinctUserId
      });
    }
    catch (_a) {
      return;
    }
  }
}
export default new EventTrackingService();
