{ "version": 3, "sources": ["src/app/tracking/channel-tracking.ts"], "sourcesContent": ["\nimport { Injectable } from '@angular/core'\nimport { Logger } from '../utils/logger'\nimport { EvidaEvent } from './evida-events'\nimport { GoogleAnalytics } from './google-analytics'\n\nexport enum Channel {\n none = 'none',\n sms = 'sms',\n email1 = 'email1',\n email2 = 'email2',\n email3 = 'email3',\n email4 = 'email4'\n}\n\nexport const ChannelEnumValues: Channel[] =\n[\n Channel.none,\n Channel.sms,\n Channel.email1,\n Channel.email2,\n Channel.email3,\n Channel.email4\n]\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ChannelTracking {\n private trackedEvents: string[] = []\n private _channel: string\n\n constructor(private log: Logger) { }\n\n public get channel(): string | undefined {\n return this._channel\n }\n public set channel(channel: string) {\n this._channel = channel\n }\n\n public setChannelFromLocation(channel: string | null | undefined) {\n this.channel = ChannelEnumValues.includes(channel as Channel) ? channel : Channel.none\n }\n\n /**\n * Track the channel information to GA\n * eventName should contain a 'channel' placeholder,\n * which will be substituded with the channel user have entered the site from\n *\n * @param {string} eventName\n */\n public trackChannel(eventName: string) {\n const result = EvidaEvent.format(eventName, { key: 'channel', value: this.channel })\n if (result === eventName) {\n this.log.warn(`Eventname \"${eventName}\" does not have the required placeholder \"{channel}\"`)\n } else {\n if (this.trackedEvents.includes(result)) {\n this.log.warn(`Logging of ${result} has already been done.`)\n } else {\n GoogleAnalytics.trackEvent(result)\n this.trackedEvents.push(result)\n }\n }\n }\n}\n"], "mappings": ";;;;;;;;;AAMA,IAAY;CAAZ,SAAYA,UAAO;AACjB,EAAAA,SAAA,MAAA,IAAA;AACA,EAAAA,SAAA,KAAA,IAAA;AACA,EAAAA,SAAA,QAAA,IAAA;AACA,EAAAA,SAAA,QAAA,IAAA;AACA,EAAAA,SAAA,QAAA,IAAA;AACA,EAAAA,SAAA,QAAA,IAAA;AACF,GAPY,YAAA,UAAO,CAAA,EAAA;AASZ,IAAM,oBACb;EACE,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;;AAMJ,IAAO,kBAAP,MAAO,iBAAe;EAI1B,YAAoB,KAAW;AAAX,SAAA,MAAA;AAHZ,SAAA,gBAA0B,CAAA;EAGC;EAEnC,IAAW,UAAO;AAChB,WAAO,KAAK;EACd;EACA,IAAW,QAAQ,SAAe;AAChC,SAAK,WAAW;EAClB;EAEO,uBAAuB,SAAkC;AAC9D,SAAK,UAAU,kBAAkB,SAAS,OAAkB,IAAI,UAAU,QAAQ;EACpF;;;;;;;;EASO,aAAa,WAAiB;AACnC,UAAM,SAAS,WAAW,OAAO,WAAW,EAAE,KAAK,WAAW,OAAO,KAAK,QAAO,CAAE;AACnF,QAAI,WAAW,WAAW;AACxB,WAAK,IAAI,KAAK,cAAc,SAAS,sDAAsD;IAC7F,OAAO;AACL,UAAI,KAAK,cAAc,SAAS,MAAM,GAAG;AACvC,aAAK,IAAI,KAAK,cAAc,MAAM,yBAAyB;MAC7D,OAAO;AACL,wBAAgB,WAAW,MAAM;AACjC,aAAK,cAAc,KAAK,MAAM;MAChC;IACF;EACF;;;uCApCW,kBAAe,mBAAA,MAAA,CAAA;IAAA;EAAA;;4EAAf,kBAAe,SAAf,iBAAe,WAAA,YAFd,OAAM,CAAA;EAAA;;", "names": ["Channel"] }