{"version":3,"file":"angulartics2.js","sources":["ng://angulartics2/angulartics2-config.ts","ng://angulartics2/angulartics2-token.ts","ng://angulartics2/routerless.ts","ng://angulartics2/angulartics2-core.ts","ng://angulartics2/angular-router.ts","ng://angulartics2/angulartics2On.ts","ng://angulartics2/angulartics2.module.ts","ng://angulartics2/angulartics2.ts"],"sourcesContent":["export interface GoogleAnalyticsSettings {\n /** array of additional account names (only works for analyticsjs) */\n additionalAccountNames: string[];\n userId: any;\n /** see https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#transport */\n transport: string;\n anonymizeIp: boolean;\n}\n\nexport interface AppInsightsSettings {\n userId: string;\n}\n\nexport interface GoogleTagManagerSettings {\n userId: any;\n}\n\nexport interface GoogleGlobalSiteTagSettings {\n trackingIds: any;\n userId?: any;\n anonymizeIp?: boolean;\n customMap?: { [key: string]: string };\n}\n\nexport interface PageTrackingSettings {\n autoTrackVirtualPages: boolean;\n basePath: string;\n excludedRoutes: (string | RegExp)[];\n /** drop ids from url `/sections/123/pages/456` -> `/sections/pages` */\n clearIds: boolean;\n /** drop contents of url after hash marker `/callback#authcode=1234` -> `/callback` */\n clearHash: boolean;\n /** drop query params from url `/sections/123/pages?param=456¶m2=789` -> `/sections/123/pages` */\n clearQueryParams: boolean;\n /** used with clearIds, define the matcher to clear url parts */\n idsRegExp: RegExp;\n}\n\nexport interface Angulartics2Settings {\n pageTracking: Partial;\n /** Disable page tracking */\n developerMode: boolean;\n ga: Partial;\n appInsights: Partial;\n gtm: Partial;\n gst: Partial;\n}\n\nexport class DefaultConfig implements Angulartics2Settings {\n pageTracking = {\n autoTrackVirtualPages: true,\n basePath: '',\n excludedRoutes: [],\n clearIds: false,\n clearHash: false,\n clearQueryParams: false,\n idsRegExp: /^\\d+$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,\n };\n developerMode = false;\n ga = {};\n appInsights = {};\n gtm = {};\n gst = {};\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { Angulartics2Settings } from './angulartics2-config';\n\nexport interface Angulartics2Token {\n settings: Partial;\n}\n\nexport const ANGULARTICS2_TOKEN = new InjectionToken('ANGULARTICS2');\n","import { BehaviorSubject, Observable } from 'rxjs';\n\nimport { Angulartics2Settings } from './angulartics2-config';\n\nexport interface TrackNavigationEnd {\n url: string;\n}\n\nexport class RouterlessTracking {\n trackLocation(settings: Angulartics2Settings): Observable {\n return new BehaviorSubject({ url: '/' });\n }\n prepareExternalUrl(url: string): string {\n return url;\n }\n}\n","import { Inject, Injectable } from '@angular/core';\n\nimport { MonoTypeOperatorFunction, ReplaySubject } from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { Angulartics2Settings, DefaultConfig } from './angulartics2-config';\nimport { EventTrack, PageTrack, UserTimings } from './angulartics2-interfaces';\nimport { Angulartics2Token, ANGULARTICS2_TOKEN } from './angulartics2-token';\nimport { RouterlessTracking, TrackNavigationEnd } from './routerless';\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2 {\n settings: Angulartics2Settings;\n\n pageTrack = new ReplaySubject>(10);\n eventTrack = new ReplaySubject>(10);\n exceptionTrack = new ReplaySubject(10);\n setAlias = new ReplaySubject(10);\n setUsername = new ReplaySubject<{ userId: string | number } | string>(10);\n setUserProperties = new ReplaySubject(10);\n setUserPropertiesOnce = new ReplaySubject(10);\n setSuperProperties = new ReplaySubject(10);\n setSuperPropertiesOnce = new ReplaySubject(10);\n userTimings = new ReplaySubject(10);\n\n constructor(\n private tracker: RouterlessTracking,\n @Inject(ANGULARTICS2_TOKEN) setup: Angulartics2Token,\n ) {\n const defaultConfig = new DefaultConfig();\n this.settings = { ...defaultConfig, ...setup.settings };\n this.settings.pageTracking = {\n ...defaultConfig.pageTracking,\n ...setup.settings.pageTracking,\n };\n this.tracker\n .trackLocation(this.settings)\n .subscribe((event: TrackNavigationEnd) =>\n this.trackUrlChange(event.url),\n );\n }\n\n /** filters all events when developer mode is true */\n filterDeveloperMode(): MonoTypeOperatorFunction {\n return filter((value, index) => !this.settings.developerMode);\n }\n\n protected trackUrlChange(url: string) {\n if (this.settings.pageTracking.autoTrackVirtualPages && !this.matchesExcludedRoute(url)) {\n const clearedUrl = this.clearUrl(url);\n let path: string;\n if (this.settings.pageTracking.basePath.length) {\n path = this.settings.pageTracking.basePath + clearedUrl;\n } else {\n path = this.tracker.prepareExternalUrl(clearedUrl);\n }\n this.pageTrack.next({ path });\n }\n }\n\n /**\n * Use string literals or regular expressions to exclude routes\n * from automatic pageview tracking.\n *\n * @param url location\n */\n protected matchesExcludedRoute(url: string): boolean {\n for (const excludedRoute of this.settings.pageTracking.excludedRoutes) {\n const matchesRegex = excludedRoute instanceof RegExp && excludedRoute.test(url);\n if (matchesRegex || url.indexOf(excludedRoute as string) !== -1) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Removes id's from tracked route.\n * EX: `/project/12981/feature` becomes `/project/feature`\n *\n * @param url current page path\n */\n protected clearUrl(url: string): string {\n if (this.settings.pageTracking.clearIds || this.settings.pageTracking.clearQueryParams ||\n this.settings.pageTracking.clearHash) {\n return url\n .split('/')\n .map(part => this.settings.pageTracking.clearQueryParams ? part.split('?')[0] : part)\n .map(part => this.settings.pageTracking.clearHash ? part.split('#')[0] : part)\n .filter(part => !this.settings.pageTracking.clearIds || !part.match(this.settings.pageTracking.idsRegExp))\n .join('/');\n }\n return url;\n }\n}\n","import { Location } from '@angular/common';\nimport { Injectable } from '@angular/core';\nimport { NavigationEnd, Router } from '@angular/router';\n\nimport { delay, filter, map } from 'rxjs/operators';\n\nimport { Observable } from 'rxjs';\nimport { RouterlessTracking, TrackNavigationEnd } from './routerless';\n\n/**\n * Track Route changes for applications using Angular's\n * default router\n *\n * @link https://angular.io/api/router/Router\n */\n@Injectable({ providedIn: 'root' })\nexport class AngularRouterTracking implements RouterlessTracking {\n constructor(\n private router: Router,\n private location: Location,\n ) {}\n\n trackLocation(settings): Observable {\n return this.router.events.pipe(\n filter(e => e instanceof NavigationEnd),\n filter(() => !settings.developerMode),\n map((e: NavigationEnd) => {\n return { url: e.urlAfterRedirects };\n }),\n delay(0),\n );\n }\n\n prepareExternalUrl(url: string): string {\n return this.location.prepareExternalUrl(url);\n }\n}\n","import {\n AfterContentInit,\n Directive,\n ElementRef,\n Input,\n NgModule,\n Renderer2,\n} from '@angular/core';\nimport { Angulartics2 } from './angulartics2-core';\n\n@Directive({ selector: '[angulartics2On]' })\nexport class Angulartics2On implements AfterContentInit {\n // tslint:disable-next-line:no-input-rename\n @Input('angulartics2On') angulartics2On: string;\n @Input() angularticsAction: string;\n @Input() angularticsCategory: string;\n @Input() angularticsLabel: string;\n @Input() angularticsValue: string;\n @Input() angularticsProperties: any = {};\n\n constructor(\n private elRef: ElementRef,\n private angulartics2: Angulartics2,\n private renderer: Renderer2\n ) { }\n\n ngAfterContentInit() {\n this.renderer.listen(\n this.elRef.nativeElement,\n this.angulartics2On || 'click',\n (event: Event) => this.eventTrack(event),\n );\n }\n\n eventTrack(event: Event) {\n const action = this.angularticsAction; // || this.inferEventName();\n const properties: any = {\n ...this.angularticsProperties,\n eventType: event.type,\n };\n\n if (this.angularticsCategory) {\n properties.category = this.angularticsCategory;\n }\n if (this.angularticsLabel) {\n properties.label = this.angularticsLabel;\n }\n if (this.angularticsValue) {\n properties.value = this.angularticsValue;\n }\n\n this.angulartics2.eventTrack.next({\n action,\n properties,\n });\n }\n\n /*private isCommand() {\n return ['a:', 'button:', 'button:button', 'button:submit', 'input:button', 'input:submit'].indexOf(\n getDOM().tagName(this.el).toLowerCase() + ':' + (getDOM().type(this.el) || '')) >= 0;\n }\n\n private inferEventName() {\n if (this.isCommand()) return getDOM().getText(this.el) || getDOM().getValue(this.el);\n return getDOM().getProperty(this.el, 'id') || getDOM().getProperty(this.el, 'name') || getDOM().tagName(this.el);\n }*/\n}\n\n@NgModule({\n declarations: [Angulartics2On],\n exports: [Angulartics2On],\n})\nexport class Angulartics2OnModule {}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\n\nimport { AngularRouterTracking } from './angular-router';\nimport { Angulartics2Settings } from './angulartics2-config';\nimport { Angulartics2 } from './angulartics2-core';\nimport { ANGULARTICS2_TOKEN } from './angulartics2-token';\nimport { Angulartics2On, Angulartics2OnModule } from './angulartics2On';\nimport { RouterlessTracking } from './routerless';\n\n@NgModule({\n imports: [Angulartics2OnModule],\n exports: [Angulartics2On],\n})\nexport class Angulartics2Module {\n static forRoot(\n settings: Partial = {},\n ): ModuleWithProviders {\n return {\n ngModule: Angulartics2Module,\n providers: [\n { provide: ANGULARTICS2_TOKEN, useValue: { settings } },\n { provide: RouterlessTracking, useClass: AngularRouterTracking },\n Angulartics2,\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["tslib_1.__param","tslib_1.__decorate"],"mappings":";;;;;;;MAgDa,aAAa;IAA1B;QACE,iBAAY,GAAG;YACb,qBAAqB,EAAE,IAAI;YAC3B,QAAQ,EAAE,EAAE;YACZ,cAAc,EAAE,EAAE;YAClB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,KAAK;YAChB,gBAAgB,EAAE,KAAK;YACvB,SAAS,EAAE,qFAAqF;SACjG,CAAC;QACF,kBAAa,GAAG,KAAK,CAAC;QACtB,OAAE,GAAG,EAAE,CAAC;QACR,gBAAW,GAAG,EAAE,CAAC;QACjB,QAAG,GAAG,EAAE,CAAC;QACT,QAAG,GAAG,EAAE,CAAC;KACV;CAAA;;MCvDY,kBAAkB,GAAG,IAAI,cAAc,CAAoB,cAAc,CAAC;;MCA1E,kBAAkB;IAC7B,aAAa,CAAC,QAA8B;QAC1C,OAAO,IAAI,eAAe,CAAqB,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;KAC9D;IACD,kBAAkB,CAAC,GAAW;QAC5B,OAAO,GAAG,CAAC;KACZ;CACF;;ICJY,YAAY,GAAzB,MAAa,YAAY;IAcvB,YACU,OAA2B,EAC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