{"version":3,"file":"event-CJ2zvWCI.js","sources":["../../../app/assets/javascripts/app/tracking/google/google_analytics_4/event.ts"],"sourcesContent":["\nimport log from \"plugins/loglevel/index\"\nimport Data_retriever from \"app/data_retriever\"\nimport WaitObjectByPathPromise from \"app/wait_object_by_path_promise\"\n\ninterface EventParams {\n event_name: string,\n options?: {\n [key: string]: unknown,\n },\n}\n\n/*\n * @see https://developers.google.com/analytics/devguides/collection/analyticsjs/events\n *\n */\nconst track = ({event_name, options= {}}: EventParams): void => {\n if (typeof event_name === \"undefined\") {\n log.debug(\"category missing!\")\n return\n }\n\n log.debug(`event_name = ${event_name}`)\n log.debug(`options = ${JSON.stringify(options)}`)\n\n // GA4 event implementation\n /*\n * @see https://support.google.com/analytics/answer/10271001?hl=en#zippy=,in-this-article\n *\n * @see https://support.google.com/analytics/answer/10085872#event-name-rules&zippy=,in-this-article for Event Naming rules doc\n *\n * @see https://developers.google.com/tag-platform/gtagjs/reference#event for Custom event doc\n */\n WaitObjectByPathPromise(\"gtag\")\n .then((gtag) => {\n const final_options = Object.assign({}, {\n send_to: Data_retriever.get(\"google-analytics-measurement-id\"),\n }, options)\n\n gtag(\"event\", event_name, final_options)\n })\n .catch(() => {\n log.warn(\"gtag is undefined!\")\n })\n}\n\nexport default { track }\nexport { track }\n"],"names":["track","event_name","options","log","WaitObjectByPathPromise","gtag","final_options","Data_retriever","GA4_Event"],"mappings":"uJAgBA,MAAMA,EAAQ,CAAC,CAAC,WAAAC,EAAY,QAAAC,EAAS,MAA2B,CAC1D,GAAA,OAAOD,EAAe,IAAa,CACrCE,EAAI,MAAM,mBAAmB,EAC7B,MAAA,CAGEA,EAAA,MAAM,gBAAgB,OAAAF,EAAY,EACtCE,EAAI,MAAM,aAAa,YAAK,UAAUD,CAAO,EAAG,EAUhDE,EAAwB,MAAM,EAC7B,KAAMC,GAAS,CACd,MAAMC,EAAgB,OAAO,OAAO,GAAI,CACtC,QAASC,EAAe,IAAI,iCAAiC,GAC5DL,CAAO,EAELG,EAAA,QAASJ,EAAYK,CAAa,CAAA,CACxC,EACA,MAAM,IAAM,CACXH,EAAI,KAAK,oBAAoB,CAAA,CAC9B,CACH,EAEeK,EAAA,CAAE,MAAAR,CAAM"}