{"version":3,"file":"utils.mjs","sources":["../../../src/analytics/utils.ts"],"sourcesContent":["import { config } from '../config';\nimport { locationService } from '../services';\nimport { getEchoSrv, EchoEventType } from '../services/EchoSrv';\n\nimport {\n  type ExperimentViewEchoEvent,\n  type InteractionEchoEvent,\n  type MetaAnalyticsEvent,\n  type MetaAnalyticsEventPayload,\n  type PageviewEchoEvent,\n} from './types';\n\n/**\n * Helper function to report meta analytics to the {@link EchoSrv}.\n *\n * @public\n */\nexport const reportMetaAnalytics = (payload: MetaAnalyticsEventPayload) => {\n  getEchoSrv().addEvent<MetaAnalyticsEvent>({\n    type: EchoEventType.MetaAnalytics,\n    payload,\n  });\n};\n\n/**\n * Helper function to report pageview events to the {@link EchoSrv}.\n *\n * @public\n */\nexport const reportPageview = () => {\n  const location = locationService.getLocation();\n  const page = `${config.appSubUrl ?? ''}${location.pathname}${location.search}${location.hash}`;\n  getEchoSrv().addEvent<PageviewEchoEvent>({\n    type: EchoEventType.Pageview,\n    payload: {\n      page,\n    },\n  });\n};\n\n/**\n * Helper function to report interaction events to the {@link EchoSrv}.\n *\n * @public\n */\nexport const reportInteraction = (interactionName: string, properties?: Record<string, unknown>) => {\n  // get static reporting context and append it to properties\n  if (config.reportingStaticContext && config.reportingStaticContext instanceof Object) {\n    properties = { ...properties, ...config.reportingStaticContext };\n  }\n  getEchoSrv().addEvent<InteractionEchoEvent>({\n    type: EchoEventType.Interaction,\n    payload: {\n      interactionName,\n      properties,\n    },\n  });\n};\n\n/**\n * Helper function to report experimentview events to the {@link EchoSrv}.\n *\n * @public\n */\nexport const reportExperimentView = (id: string, group: string, variant: string) => {\n  getEchoSrv().addEvent<ExperimentViewEchoEvent>({\n    type: EchoEventType.ExperimentView,\n    payload: {\n      experimentId: id,\n      experimentGroup: group,\n      experimentVariant: variant,\n    },\n  });\n};\n"],"names":[],"mappings":";;;;;;AAiBO,MAAM,mBAAA,GAAsB,CAAC,OAAA,KAAuC;AACzE,EAAA,UAAA,GAAa,QAAA,CAA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