'use strict';

const apiClient = require('./api-client-00edc9b6.js');

class BenefitsEventTrackingApi {
  async postTrackEventAsync(event) {
    return apiClient.BackendApiClient.instance.url('benefits/track-event').post(event).res();
  }
}
const benefitsEventTrackingApi = new BenefitsEventTrackingApi();

class BenefitsEventTrackingService {
  async trackAppLoadedAsync() {
    return this.trackEventAsync('appLoaded');
  }
  async trackPageViewedAsync(event) {
    return this.trackEventAsync({ pageViewed: event });
  }
  async trackBenefitLinkClickedAsync({ benefitId, benefit }) {
    const event = {
      benefitId,
      attachment: 'link',
      category: benefit.category,
      subtitle: benefit.subtitle,
      title: benefit.title
    };
    return this.trackEventAsync({ benefitSelected: event });
  }
  async trackBenefitAttachmentClickedAsync({ benefitId, benefit }) {
    const event = {
      benefitId,
      attachment: 'document',
      category: benefit.category,
      subtitle: benefit.subtitle,
      title: benefit.title
    };
    return this.trackEventAsync({ benefitSelected: event });
  }
  async trackEventAsync(event) {
    try {
      await benefitsEventTrackingApi.postTrackEventAsync({
        event
      });
    }
    catch (_a) {
      return;
    }
  }
}
const benefitsEventTrackingService = new BenefitsEventTrackingService();

exports.benefitsEventTrackingService = benefitsEventTrackingService;
