{"version":3,"file":"angulartics2-adobeanalytics.js","sources":["ng://angulartics2/adobeanalytics/adobeanalytics.ts","ng://angulartics2/adobeanalytics/angulartics2-adobeanalytics.ts"],"sourcesContent":["import { Location } from '@angular/common';\nimport { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from 'angulartics2';\n\ndeclare const s: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2AdobeAnalytics {\n\n constructor(\n private angulartics2: Angulartics2,\n private location: Location,\n ) {\n this.angulartics2.setUserProperties\n .subscribe((x) => this.setUserProperties(x));\n }\n\n startTracking(): void {\n this.angulartics2.pageTrack\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe((x) => this.pageTrack(x.path));\n this.angulartics2.eventTrack\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe((x) => this.eventTrack(x.action, x.properties));\n }\n\n pageTrack(path: string) {\n if (typeof s !== 'undefined' && s) {\n s.clearVars();\n s.t({pageName: path});\n }\n }\n\n /**\n * Track Event in Adobe Analytics\n *\n * @param action associated with the event\n * @param properties action detials\n *\n * @link https://marketing.adobe.com/resources/help/en_US/sc/implement/js_implementation.html\n */\n eventTrack(action: string, properties: any) {\n // TODO: make interface\n // @property {string} properties.category\n // @property {string} properties.label\n // @property {number} properties.value\n // @property {boolean} properties.noninteraction\n if (!properties) {\n properties = properties || {};\n }\n\n if (typeof s !== 'undefined' && s) {\n if (typeof properties === 'object') {\n this.setUserProperties(properties);\n }\n if (action) {\n // if linkName property is passed, use that; otherwise, the action is the linkName\n const linkName = (properties['linkName']) ? properties['linkName'] : action;\n // note that 'this' should refer the link element, but we can't get that in this function. example:\n // \n // if disableDelay property is passed, use that to turn off/on the 500ms delay; otherwise, it uses this\n const disableDelay = !!properties['disableDelay'] ? true : this;\n // if action property is passed, use that; otherwise, the action remains unchanged\n if (properties['action']) {\n action = properties['action'];\n }\n this.setPageName();\n\n if (action.toUpperCase() === 'DOWNLOAD') {\n s.tl(disableDelay, 'd', linkName);\n } else if (action.toUpperCase() === 'EXIT') {\n s.tl(disableDelay, 'e', linkName);\n } else {\n s.tl(disableDelay, 'o', linkName);\n }\n }\n }\n }\n\n private setPageName() {\n const path = this.location.path(true);\n const hashNdx = path.indexOf('#');\n if (hashNdx > 0 && hashNdx < path.length) {\n s.pageName = path.substring(hashNdx + 1);\n } else {\n s.pageName = path;\n }\n }\n\n setUserProperties(properties: any) {\n if (typeof s !== 'undefined' && s) {\n if (typeof properties === 'object') {\n for (const key in properties) {\n if (properties.hasOwnProperty(key)) {\n s[key] = properties[key];\n }\n }\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './adobeanalytics';\n"],"names":[],"mappings":";;;;;;IAUE,oCACU,YAA0B,EAC1B,QAAkB;QAF5B,iBAMC;QALS,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAAU;QAE1B,IAAI,CAAC,YAAY,CAAC,iBAAiB;aAChC,SAAS,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAA,CAAC,CAAC;KAChD;IAED,kDAAa,GAAb;QAAA,iBAOC;QANC,IAAI,CAAC,YAAY,CAAC,SAAS;aACxB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC;aAC7C,SAAS,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAA,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,CAAC,UAAU;aACzB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC;aAC7C,SAAS,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,GAAA,CAAC,CAAC;KAC9D;IAED,8CAAS,GAAT,UAAU,IAAY;QACpB,IAAI,OAAO,CAAC,KAAK,WAA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