UNPKG

angulartics2

Version:

Vendor-agnostic web analytics for Angular2 applications

1 lines 165 kB
{"version":3,"file":"angulartics2.mjs","sources":["../../src/lib/angulartics2-config.ts","../../src/lib/angulartics2-token.ts","../../src/lib/routerless.ts","../../src/lib/angulartics2-core.ts","../../src/lib/angular-router.ts","../../src/lib/angulartics2On.ts","../../src/lib/angulartics2.module.ts","../../src/lib/routerless.module.ts","../../src/lib/providers/adobeanalytics/adobeanalytics.ts","../../src/lib/providers/appinsights/appinsights.ts","../../src/lib/providers/baidu/baidu.ts","../../src/lib/providers/facebook/facebook.ts","../../src/lib/providers/ga/ga.ts","../../src/lib/providers/ga-enhanced-ecom/ga-enhanced-ecom.ts","../../src/lib/providers/gtm/gtm.ts","../../src/lib/providers/gst/gst.ts","../../src/lib/providers/hubspot/hubspot.ts","../../src/lib/providers/kissmetrics/kissmetrics.ts","../../src/lib/providers/launch/launch.ts","../../src/lib/providers/mixpanel/mixpanel.ts","../../src/lib/providers/posthog/posthog.ts","../../src/lib/providers/pyze/pyze.ts","../../src/lib/providers/matomo/matomo.ts","../../src/lib/providers/segment/segment.ts","../../src/lib/providers/intercom/intercom.ts","../../src/lib/providers/woopra/woopra.ts","../../src/lib/providers/clicky/clicky.ts","../../src/lib/providers/amplitude/amplitude.ts","../../src/lib/providers/splunk/splunk.ts","../../src/lib/providers/ibm-digital-analytics/ibm-digital-analytics.ts","../../src/lib/providers/gosquared/gosquared.ts","../../src/lib/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&param2=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<PageTrackingSettings>;\n /** Disable page tracking */\n developerMode: boolean;\n ga: Partial<GoogleAnalyticsSettings>;\n appInsights: Partial<AppInsightsSettings>;\n gtm: Partial<GoogleTagManagerSettings>;\n gst: Partial<GoogleGlobalSiteTagSettings>;\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:\n /^\\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<Angulartics2Settings>;\n}\n\nexport const ANGULARTICS2_TOKEN = new InjectionToken<Angulartics2Token>(\n 'ANGULARTICS2'\n);\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<TrackNavigationEnd> {\n return new BehaviorSubject<TrackNavigationEnd>({ url: '/' });\n }\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<Partial<PageTrack>>(10);\n eventTrack = new ReplaySubject<Partial<EventTrack>>(10);\n exceptionTrack = new ReplaySubject<any>(10);\n setAlias = new ReplaySubject<string>(10);\n setUsername = new ReplaySubject<{ userId: string | number } | string>(10);\n setUserProperties = new ReplaySubject<any>(10);\n setUserPropertiesOnce = new ReplaySubject<any>(10);\n setSuperProperties = new ReplaySubject<any>(10);\n setSuperPropertiesOnce = new ReplaySubject<any>(10);\n userTimings = new ReplaySubject<UserTimings>(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) => this.trackUrlChange(event.url));\n }\n\n /** filters all events when developer mode is true */\n filterDeveloperMode<T>(): MonoTypeOperatorFunction<T> {\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 (\n this.settings.pageTracking.clearIds ||\n this.settings.pageTracking.clearQueryParams ||\n this.settings.pageTracking.clearHash\n ) {\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(\n part =>\n !this.settings.pageTracking.clearIds ||\n !part.match(this.settings.pageTracking.idsRegExp),\n )\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';\nimport { Observable } from 'rxjs';\n\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(private router: Router, private location: Location) {}\n\n trackLocation(settings): Observable<TrackNavigationEnd> {\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 { AfterContentInit, Directive, ElementRef, Input, NgModule, Renderer2 } from '@angular/core';\nimport { Angulartics2 } from './angulartics2-core';\n\n@Directive({ selector: '[angulartics2On]' })\nexport class Angulartics2On implements AfterContentInit {\n // eslint-disable-next-line @angular-eslint/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(this.elRef.nativeElement, this.angulartics2On || 'click', (event: Event) =>\n 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<Angulartics2Settings> = {},\n ): ModuleWithProviders<Angulartics2Module> {\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","import { ModuleWithProviders, NgModule } from '@angular/core';\n\nimport {ANGULARTICS2_TOKEN} from './angulartics2-token';\nimport {Angulartics2Settings} from './angulartics2-config';\nimport {Angulartics2OnModule} from './angulartics2On';\nimport {Angulartics2} from './angulartics2-core';\nimport {RouterlessTracking} from './routerless';\n\n@NgModule({\n imports: [Angulartics2OnModule],\n})\nexport class Angulartics2RouterlessModule {\n static forRoot(\n settings: Partial<Angulartics2Settings> = {}\n ): ModuleWithProviders<Angulartics2RouterlessModule> {\n return {\n ngModule: Angulartics2RouterlessModule,\n providers: [\n { provide: ANGULARTICS2_TOKEN, useValue: { settings } },\n RouterlessTracking,\n Angulartics2,\n ],\n };\n }\n}\n","import { Location } from '@angular/common';\nimport { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\n\ndeclare const s: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2AdobeAnalytics {\n constructor(private angulartics2: Angulartics2, private location: Location) {\n this.angulartics2.setUserProperties.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 // <a href=\"http://anothersite.com\" onclick=\"s.tl(this,'e','AnotherSite',null)\">\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","import { Injectable } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport {\n NavigationEnd,\n NavigationError,\n NavigationStart,\n Router,\n} from '@angular/router';\nimport { filter } from 'rxjs/operators';\n\nimport { AppInsightsSettings } from '../../angulartics2-config';\nimport { Angulartics2 } from '../../angulartics2-core';\n\ndeclare const appInsights: Microsoft.ApplicationInsights.IAppInsights;\n\nexport class AppInsightsDefaults implements AppInsightsSettings {\n userId = null;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2AppInsights {\n loadStartTime: number = null;\n loadTime: number = null;\n\n metrics: { [name: string]: number } = null;\n dimensions: { [name: string]: string } = null;\n measurements: { [name: string]: number } = null;\n\n constructor(\n private angulartics2: Angulartics2,\n private title: Title,\n private router: Router\n ) {\n if (typeof appInsights === 'undefined') {\n console.warn('appInsights not found');\n }\n\n const defaults = new AppInsightsDefaults();\n // Set the default settings for this module\n this.angulartics2.settings.appInsights = {\n ...defaults,\n ...this.angulartics2.settings.appInsights,\n };\n this.angulartics2.setUsername.subscribe((x: string) => this.setUsername(x));\n this.angulartics2.setUserProperties.subscribe((x) =>\n this.setUserProperties(x)\n );\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 this.angulartics2.exceptionTrack\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe((x) => this.exceptionTrack(x));\n this.router.events\n .pipe(\n this.angulartics2.filterDeveloperMode(),\n filter((event) => event instanceof NavigationStart)\n )\n .subscribe((event) => this.startTimer());\n\n this.router.events\n .pipe(\n filter(\n (event) =>\n event instanceof NavigationError || event instanceof NavigationEnd\n )\n )\n .subscribe((error) => this.stopTimer());\n }\n\n startTimer() {\n this.loadStartTime = Date.now();\n this.loadTime = null;\n }\n\n stopTimer() {\n this.loadTime = Date.now() - this.loadStartTime;\n this.loadStartTime = null;\n }\n\n /**\n * Page Track in Baidu Analytics\n *\n * @param path - Location 'path'\n *\n * @link https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackpageview\n */\n pageTrack(path: string) {\n appInsights.trackPageView(\n this.title.getTitle(),\n path,\n this.dimensions,\n this.metrics,\n this.loadTime\n );\n }\n\n /**\n * Log a user action or other occurrence.\n *\n * @param name Name to identify this event in the portal.\n * @param properties Additional data used to filter events and metrics in the portal. Defaults to empty.\n *\n * @link https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackevent\n */\n eventTrack(name: string, properties: { [name: string]: string }) {\n appInsights.trackEvent(name, properties, this.measurements);\n }\n\n /**\n * Exception Track Event in GA\n *\n * @param properties - Comprised of the mandatory fields 'appId' (string), 'appName' (string) and 'appVersion' (string) and\n * optional fields 'fatal' (boolean) and 'description' (string), error\n *\n * @link https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackexception\n */\n exceptionTrack(properties: any) {\n const description =\n properties.event || properties.description || properties;\n\n appInsights.trackException(description);\n }\n\n /**\n * @link https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#setauthenticatedusercontext\n */\n setUsername(userId: string) {\n this.angulartics2.settings.appInsights.userId = userId;\n appInsights.setAuthenticatedUserContext(userId);\n }\n\n setUserProperties(\n properties: Partial<{ userId: string; accountId: string }>\n ) {\n if (properties.userId) {\n this.angulartics2.settings.appInsights.userId = properties.userId;\n }\n if (properties.accountId) {\n appInsights.setAuthenticatedUserContext(\n this.angulartics2.settings.appInsights.userId,\n properties.accountId\n );\n } else {\n appInsights.setAuthenticatedUserContext(\n this.angulartics2.settings.appInsights.userId\n );\n }\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\n\n\ndeclare var _hmt: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2BaiduAnalytics {\n constructor(private angulartics2: Angulartics2) {\n if (typeof _hmt === 'undefined') {\n _hmt = [];\n } else {\n _hmt.push(['_setAutoPageview', false]);\n }\n this.angulartics2.setUsername\n .subscribe((x: string) => this.setUsername(x));\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 /**\n * Page Track in Baidu Analytics\n *\n * @param path Required url 'path'\n *\n * @link http://tongji.baidu.com/open/api/more?p=ref_trackPageview\n */\n pageTrack(path: string) {\n if (typeof _hmt !== 'undefined' && _hmt) {\n _hmt.push(['_trackPageview', path]);\n }\n }\n\n /**\n * Track Event in Baidu Analytics\n *\n * @param action Name associated with the event\n * @param properties Comprised of:\n * - 'category' (string)\n * - 'opt_label' (string)\n * - 'opt_value' (string)\n *\n * @link http://tongji.baidu.com/open/api/more?p=ref_trackEvent\n */\n eventTrack(action: string, properties: any) {\n // baidu analytics requires category\n if (!properties || !properties.category) {\n properties = properties || {};\n properties.category = 'Event';\n properties.opt_label = 'default';\n properties.opt_value = 'default';\n }\n\n if (typeof _hmt !== 'undefined' && _hmt) {\n _hmt.push([\n '_trackEvent',\n properties.category,\n action,\n properties.opt_label,\n properties.opt_value,\n ]);\n }\n }\n\n setUsername(userId: string) {\n // set default custom variables name to 'identity' and 'value'\n _hmt.push(['_setCustomVar', 1, 'identity', userId]);\n }\n\n setUserProperties(properties: any) {\n _hmt.push(['_setCustomVar', 2, 'user', JSON.stringify(properties)]);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\n\ndeclare const fbq: facebook.Pixel.Event;\n\nconst facebookEventList = [\n 'ViewContent',\n 'Search',\n 'AddToCart',\n 'AddToWishlist',\n 'InitiateCheckout',\n 'AddPaymentInfo',\n 'Purchase',\n 'Lead',\n 'CompleteRegistration',\n];\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2Facebook {\n constructor(private angulartics2: Angulartics2) { }\n\n startTracking(): void {\n this.angulartics2.eventTrack\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe(x => this.eventTrack(x.action, x.properties));\n }\n\n /**\n * Send interactions to the Pixel, i.e. for event tracking in Pixel\n *\n * @param action action associated with the event\n */\n eventTrack(action: string, properties: any = {}) {\n if (typeof fbq === 'undefined') {\n return;\n }\n if (facebookEventList.indexOf(action) === -1) {\n return fbq('trackCustom', action, properties);\n }\n return fbq('track', action, properties);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\nimport { GoogleAnalyticsSettings } from '../../angulartics2-config';\nimport { UserTimings } from '../../angulartics2-interfaces';\n\ndeclare var _gaq: GoogleAnalyticsCode;\ndeclare var ga: UniversalAnalytics.ga;\ndeclare var location: any;\n\nexport class GoogleAnalyticsDefaults implements GoogleAnalyticsSettings {\n additionalAccountNames = [];\n userId = null;\n transport = '';\n anonymizeIp = false;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2GoogleAnalytics {\n dimensionsAndMetrics = [];\n settings: Partial<GoogleAnalyticsSettings>;\n\n constructor(private angulartics2: Angulartics2) {\n const defaults = new GoogleAnalyticsDefaults();\n // Set the default settings for this module\n this.angulartics2.settings.ga = {\n ...defaults,\n ...this.angulartics2.settings.ga,\n };\n this.settings = this.angulartics2.settings.ga;\n this.angulartics2.setUsername.subscribe((x: string) => this.setUsername(x));\n this.angulartics2.setUserProperties.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 this.angulartics2.exceptionTrack\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe(x => this.exceptionTrack(x));\n this.angulartics2.userTimings\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe(x => this.userTimings(x));\n }\n\n pageTrack(path: string) {\n if (typeof _gaq !== 'undefined' && _gaq) {\n _gaq.push(['_trackPageview', path]);\n for (const accountName of this.angulartics2.settings.ga.additionalAccountNames) {\n _gaq.push([accountName + '._trackPageview', path]);\n }\n }\n if (typeof ga !== 'undefined' && ga) {\n if (this.angulartics2.settings.ga.userId) {\n ga('set', '&uid', this.angulartics2.settings.ga.userId);\n for (const accountName of this.angulartics2.settings.ga.additionalAccountNames) {\n ga(accountName + '.set', '&uid', this.angulartics2.settings.ga.userId);\n }\n }\n if (this.angulartics2.settings.ga.anonymizeIp) {\n ga('set', 'anonymizeIp', true);\n for (const accountName of this.angulartics2.settings.ga.additionalAccountNames) {\n ga(accountName + '.set', 'anonymizeIp', true);\n }\n }\n ga('send', 'pageview', path);\n for (const accountName of this.angulartics2.settings.ga.additionalAccountNames) {\n ga(accountName + '.send', 'pageview', path);\n }\n }\n }\n\n /**\n * Track Event in GA\n *\n * @param action Associated with the event\n * @param properties Comprised of:\n * - category (string) and optional\n * - label (string)\n * - value (integer)\n * - noninteraction (boolean)\n *\n * @link https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#SettingUpEventTracking\n * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/events\n */\n eventTrack(action: string, properties: any) {\n // Google Analytics requires an Event Category\n if (!properties || !properties.category) {\n properties = properties || {};\n properties.category = 'Event';\n }\n // GA requires that eventValue be an integer, see:\n // https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#eventValue\n // https://github.com/luisfarzati/angulartics/issues/81\n if (properties.value) {\n const parsed = parseInt(properties.value, 10);\n properties.value = isNaN(parsed) ? 0 : parsed;\n }\n\n if (typeof ga !== 'undefined') {\n const eventOptions = {\n eventCategory: properties.category,\n eventAction: action,\n eventLabel: properties.label,\n eventValue: properties.value,\n nonInteraction: properties.noninteraction,\n page: properties.page || location.hash.substring(1) || location.pathname,\n userId: this.angulartics2.settings.ga.userId,\n hitCallback: properties.hitCallback,\n ...(this.angulartics2.settings.ga.transport && {\n transport: this.angulartics2.settings.ga.transport,\n }),\n };\n\n // add custom dimensions and metrics\n this.setDimensionsAndMetrics(properties);\n\n ga('send', 'event', eventOptions);\n\n for (const accountName of this.angulartics2.settings.ga.additionalAccountNames) {\n ga(accountName + '.send', 'event', eventOptions);\n }\n } else if (typeof _gaq !== 'undefined') {\n _gaq.push([\n '_trackEvent',\n properties.category,\n action,\n properties.label,\n properties.value,\n properties.noninteraction,\n ]);\n }\n }\n\n /**\n * Exception Track Event in GA\n *\n * @param properties Comprised of the optional fields:\n * - fatal (string)\n * - description (string)\n *\n * @https://developers.google.com/analytics/devguides/collection/analyticsjs/exceptions\n *\n * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/events\n */\n exceptionTrack(properties: any) {\n if (properties.fatal === undefined) {\n console.log('No \"fatal\" provided, sending with fatal=true');\n properties.fatal = true;\n }\n\n properties.exDescription = properties.description;\n\n const eventOptions = {\n exFatal: properties.fatal,\n exDescription: properties.description,\n };\n\n ga('send', 'exception', eventOptions);\n for (const accountName of this.angulartics2.settings.ga.additionalAccountNames) {\n ga(accountName + '.send', 'exception', eventOptions);\n }\n }\n\n /**\n * User Timings Event in GA\n *\n * @param properties Comprised of the mandatory fields:\n * - timingCategory (string)\n * - timingVar (string)\n * - timingValue (number)\n * Properties can also have the optional fields:\n * - timingLabel (string)\n *\n * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings\n */\n userTimings(properties: UserTimings) {\n if (\n !properties ||\n !properties.timingCategory ||\n !properties.timingVar ||\n !properties.timingValue\n ) {\n console.error(\n 'Properties timingCategory, timingVar, and timingValue are required to be set.',\n );\n return;\n }\n\n if (typeof ga !== 'undefined') {\n ga('send', 'timing', properties);\n for (const accountName of this.angulartics2.settings.ga.additionalAccountNames) {\n ga(accountName + '.send', 'timing', properties);\n }\n }\n }\n\n setUsername(userId: string) {\n this.angulartics2.settings.ga.userId = userId;\n if (typeof ga === 'undefined') {\n return;\n }\n ga('set', 'userId', userId);\n }\n\n setUserProperties(properties: any) {\n this.setDimensionsAndMetrics(properties);\n }\n\n private setDimensionsAndMetrics(properties: any) {\n if (typeof ga === 'undefined') {\n return;\n }\n // clean previously used dimensions and metrics that will not be overriden\n this.dimensionsAndMetrics.forEach(elem => {\n if (!properties.hasOwnProperty(elem)) {\n ga('set', elem, undefined);\n\n this.angulartics2.settings.ga.additionalAccountNames.forEach((accountName: string) => {\n ga(`${accountName}.set`, elem, undefined);\n });\n }\n });\n this.dimensionsAndMetrics = [];\n\n // add custom dimensions and metrics\n Object.keys(properties).forEach(key => {\n if (key.lastIndexOf('dimension', 0) === 0 || key.lastIndexOf('metric', 0) === 0) {\n ga('set', key, properties[key]);\n\n this.angulartics2.settings.ga.additionalAccountNames.forEach((accountName: string) => {\n ga(`${accountName}.set`, key, properties[key]);\n });\n this.dimensionsAndMetrics.push(key);\n }\n });\n }\n}\n","import { Injectable } from '@angular/core';\nimport {\n GaEnhancedEcomAction,\n GaEnhancedEcomActionFieldObject,\n GaEnhancedEcomImpressionFieldObject,\n GaEnhancedEcomProductFieldObject,\n} from './ga-enhanced-ecom-options';\n\ndeclare var ga: UniversalAnalytics.ga;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2GoogleAnalyticsEnhancedEcommerce {\n /**\n * Add impression in GA enhanced ecommerce tracking\n * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-activities\n */\n ecAddImpression(properties: Partial<GaEnhancedEcomImpressionFieldObject>) {\n ga('ec:addImpression', properties);\n }\n\n /**\n * Add product in GA enhanced ecommerce tracking\n * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce\n */\n ecAddProduct(product: Partial<GaEnhancedEcomProductFieldObject>) {\n ga('ec:addProduct', product);\n }\n\n /**\n * Set action in GA enhanced ecommerce tracking\n * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce\n */\n ecSetAction(\n action: GaEnhancedEcomAction,\n properties: Partial<GaEnhancedEcomActionFieldObject>\n ) {\n ga('ec:setAction', action, properties);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\nimport { GoogleTagManagerSettings } from '../../angulartics2-config';\n\ndeclare var dataLayer: any;\n\nexport class GoogleTagManagerDefaults implements GoogleTagManagerSettings {\n userId = null;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2GoogleTagManager {\n constructor(protected angulartics2: Angulartics2) {\n // The dataLayer needs to be initialized\n if (typeof dataLayer !== 'undefined' && dataLayer) {\n dataLayer = (window as any).dataLayer = (window as any).dataLayer || [];\n }\n const defaults = new GoogleTagManagerDefaults();\n // Set the default settings for this module\n this.angulartics2.settings.gtm = { ...defaults, ...this.angulartics2.settings.gtm };\n this.angulartics2.setUsername.subscribe((x: string) => this.setUsername(x));\n }\n\n startTracking() {\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 this.angulartics2.exceptionTrack\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe((x: any) => this.exceptionTrack(x));\n }\n\n pageTrack(path: string) {\n this.pushLayer({\n event: 'Page View',\n 'content-name': path,\n userId: this.angulartics2.settings.gtm.userId,\n });\n }\n\n /**\n * Send Data Layer\n *\n * @layer data layer object\n */\n pushLayer(layer: any) {\n if (typeof dataLayer !== 'undefined' && dataLayer) {\n dataLayer.push(layer);\n }\n }\n\n /**\n * Send interactions to the dataLayer, i.e. for event tracking in Google Analytics\n *\n * @param action associated with the event\n */\n eventTrack(action: string, properties: any) {\n // TODO: make interface\n // @param {string} properties.category\n // @param {string} [properties.label]\n // @param {number} [properties.value]\n // @param {boolean} [properties.noninteraction]\n // Set a default GTM category\n properties = properties || {};\n\n this.pushLayer({\n event: properties.event || 'interaction',\n target: properties.category || 'Event',\n action,\n label: properties.label,\n value: properties.value,\n interactionType: properties.noninteraction,\n userId: this.angulartics2.settings.gtm.userId,\n ...properties.gtmCustom,\n });\n }\n\n /**\n * Exception Track Event in GTM\n *\n */\n exceptionTrack(properties: any) {\n // TODO: make interface\n // @param {Object} properties\n // @param {string} properties.appId\n // @param {string} properties.appName\n // @param {string} properties.appVersion\n // @param {string} [properties.description]\n // @param {boolean} [properties.fatal]\n if (!properties || !properties.appId || !properties.appName || !properties.appVersion) {\n console.error('Must be setted appId, appName and appVersion.');\n return;\n }\n\n if (properties.fatal === undefined) {\n console.log('No \"fatal\" provided, sending with fatal=true');\n properties.exFatal = true;\n }\n\n properties.exDescription = properties.event ? properties.event.stack : properties.description;\n\n this.eventTrack(\n `Exception thrown for ${properties.appName} <${properties.appId}@${properties.appVersion}>`,\n {\n category: 'Exception',\n label: properties.exDescription,\n },\n );\n }\n\n /**\n * Set userId for use with Universal Analytics User ID feature\n *\n * @param userId used to identify user cross-device in Google Analytics\n */\n setUsername(userId: string) {\n this.angulartics2.settings.gtm.userId = userId;\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { UserTimings } from '../../angulartics2-interfaces';\nimport { GoogleGlobalSiteTagSettings } from '../../angulartics2-config';\nimport { Angulartics2 } from '../../angulartics2-core';\nimport { EventGst, UserTimingsGst } from './gst-interfaces';\n\ndeclare var gtag: any;\ndeclare var ga: any;\n\nexport class GoogleGlobalSiteTagDefaults implements GoogleGlobalSiteTagSettings {\n trackingIds: string[] = [];\n\n constructor() {\n if (typeof ga !== 'undefined' && ga) {\n // See: https://developers.google.com/analytics/devguides/collection/analyticsjs/ga-object-methods-reference\n ga(() => {\n ga.getAll().forEach((tracker: any) => {\n const id = tracker.get('trackingId');\n // If set both in forRoot and HTML page, we want to avoid duplicates\n if (id !== undefined && this.trackingIds.indexOf(id) === -1) {\n this.trackingIds.push(id);\n }\n });\n });\n }\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2GoogleGlobalSiteTag {\n private dimensionsAndMetrics: { [key: string]: any } = {};\n\n constructor(protected angulartics2: Angulartics2) {\n const defaults = new GoogleGlobalSiteTagDefaults();\n // Set the default settings for this module\n this.angulartics2.settings.gst = { ...defaults, ...this.angulartics2.settings.gst };\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 this.angulartics2.exceptionTrack\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe((x: any) => this.exceptionTrack(x));\n this.angulartics2.userTimings\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe(x => this.userTimings(this.convertTimings(x)));\n this.angulartics2.setUsername\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe((x: string) => this.setUsername(x));\n this.angulartics2.setUserProperties\n .pipe(this.angulartics2.filterDeveloperMode())\n .subscribe((x: any) => this.setUserProperties(x));\n }\n\n /**\n * Manually track page view, see:\n *\n * https://developers.google.com/analytics/devguides/collection/gtagjs/single-page-applications#tracking_virtual_pageviews\n *\n * @param path relative url\n */\n pageTrack(path: string) {\n if (typeof gtag !== 'undefined' && gtag) {\n const params: any = {\n page_path: path,\n page_location: window.location.protocol + '//' + window.location.host + path,\n ...this.dimensionsAndMetrics,\n };\n\n // Custom map must be reset with all config to stay valid.\n\n if (this.angulartics2.settings.gst.customMap) {\n params.custom_map = this.angulartics2.settings.gst.customMap;\n }\n if (this.angulartics2.settings.gst.userId) {\n params.user_id = this.angulartics2.settings.gst.userId;\n }\n if (this.angulartics2.settings.gst.anonymizeIp) {\n params.anonymize_ip = this.angulartics2.settings.gst.anonymizeIp;\n }\n\n for (const id of this.angulartics2.settings.gst.trackingIds) {\n gtag('config', id, params);\n }\n }\n }\n\n /**\n * Send interactions to gtag, i.e. for event tracking in Google Analytics. See:\n *\n * https://developers.google.com/analytics/devguides/collection/gtagjs/events\n *\n * @param action associated with the event\n */\n eventTrack(action: string, properties: Partial<EventGst> = {}) {\n this.eventTrackInternal(action, {\n event_category: properties.category || 'interaction',\n event_label: properties.label,\n value: properties.value,\n non_interaction: properties.noninteraction,\n ...properties.gstCustom,\n });\n }\n\n /**\n * Exception Track Event in GST. See:\n *\n * https://developers.google.com/analytics/devguides/collection/gtagjs/exceptions\n *\n */\n exceptionTrack(properties: any) {\n // TODO: make interface\n // @param {Object} properties\n // @param {string} [properties.description]\n // @param {boolean} [properties.fatal]\n if (properties.fatal === undefined) {\n console.log('No \"fatal\" provided, sending with fatal=true');\n properties.fatal = true;\n }\n\n properties.exDescription = properties.event ? properties.event.stack : properties.description;\n\n this.eventTrack('exception', {\n gstCustom: {\n description: properties.exDescription,\n fatal: properties.fatal,\n ...properties.gstCustom,\n },\n });\n }\n\n /**\n * User Timings Event in GST.\n *\n * @param properties Comprised of the mandatory fields:\n * - name (string)\n * - value (number - integer)\n * Properties can also have the optional fields:\n * - category (string)\n * - label (string)\n *\n * @link https://developers.google.com/analytics/devguides/collection/gtagjs/user-timings\n */\n userTimings(properties: UserTimingsGst) {\n if (!properties) {\n console.error('User timings - \"properties\" parameter is required to be set.');\n return;\n }\n\n this.eventTrackInternal('timing_complete', {\n name: properties.name,\n value: properties.value,\n event_category: properties.category,\n event_label: properties.label,\n });\n }\n\n private convertTimings(properties: UserTimings): UserTimingsGst {\n return {\n name: properties.timingVar,\n value: properties.timingValue,\n category: properties.timingCategory,\n label: properties.timingLabel,\n };\n }\n\n setUsername(userId: string | { userId: string | number }) {\n this.angulartics2.settings.gst.userId = userId;\n if (typeof gtag !== 'undefined' && gtag) {\n gtag('set', { user_id: typeof userId === 'string' || !userId ? userId : userId.userId });\n }\n }\n\n setUserProperties(properties: any) {\n this.setDimensionsAndMetrics(properties);\n }\n\n private setDimensionsAndMetrics(properties: { [key: string]: any }) {\n // We want the dimensions and metrics to accumulate, so we merge with previous value\n this.dimensionsAndMetrics = {\n ...this.dimensionsAndMetrics,\n ...properties,\n };\n\n // Remove properties that are null or undefined\n Object.keys(this.dimensionsAndMetrics).forEach(key => {\n const val = this.dimensionsAndMetrics[key];\n if (val === undefined || val === null) {\n delete this.dimensionsAndMetrics[key];\n }\n });\n\n if (typeof gtag !== 'undefined' && gtag) {\n gtag('set', this.dimensionsAndMetrics);\n }\n }\n\n private eventTrackInternal(action: string, properties: any = {}) {\n this.cleanProperties(properties);\n if (typeof gtag !== 'undefined' && gtag) {\n gtag('event', action, properties);\n }\n }\n\n private cleanProperties(properties: { [key: string]: any }): void {\n // GA requires that eventValue be an non-negative integer, see:\n // https://developers.google.com/analytics/devguides/collection/gtagjs/events\n if (properties.value) {\n const parsed = parseInt(properties.value, 10);\n properties.value = isNaN(parsed) ? 0 : parsed;\n }\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\n\ndeclare var _hsq: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2Hubspot {\n constructor(private angulartics2: Angulartics2) {\n this.angulartics2.setUserProperties.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 _hsq !== 'undefined') {\n _hsq.push(['setPath', path]);\n _hsq.push(['trackPageView']);\n }\n }\n\n eventTrack(action: string, properties: any) {\n if (typeof _hsq !== 'undefined') {\n _hsq.push(['trackEvent', properties]);\n }\n }\n\n setUserProperties(properties: any) {\n if (typeof _hsq !== 'undefined') {\n _hsq.push(['identify', properties]);\n }\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\n\ndeclare var _kmq: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2Kissmetrics {\n constructor(private angulartics2: Angulartics2) {\n if (typeof _kmq === 'undefined') {\n _kmq = [];\n }\n this.angulartics2.setUsername.subscribe((x: string) => this.setUsername(x));\n this.angulartics2.setUserProperties.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 _kmq.push(['record', 'Pageview', { Page: path }]);\n }\n\n eventTrack(action: string, properties: any) {\n _kmq.push(['record', action, properties]);\n }\n\n setUsername(userId: string) {\n _kmq.push(['identify', userId]);\n }\n\n setUserProperties(properties: any) {\n _kmq.push(['set', properties]);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\n\ndeclare const _satellite: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2LaunchByAdobe {\n payload: any = {};\n\n constructor(protected angulartics2: Angulartics2) {\n if ('undefined' === typeof _satellite) {\n console.warn('Launch not found!');\n }\n this.angulartics2.setUsername.subscribe((x: string) => this.setUsername(x));\n this.angulartics2.setUserProperties.subscribe(x => this.setUserProperties(x));\n }\n\n setUsername(userId: string | boolean) {\n if ('undefined' !== typeof userId && userId) {\n this.payload.userId = userId;\n }\n }\n\n setUserProperties(properties: any) {\n if ('undefined' !== typeof properties && properties) {\n this.payload.properties = properties;\n }\n }\n\n startTracking() {\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 this.payload = this.payload || {};\n this.payload.path = path;\n\n if ('undefined' !== typeof _satellite && _satellite) {\n _satellite.track('pageTrack', this.payload);\n }\n }\n\n /**\n * @param action associated with the event\n * @param properties associated with the event\n */\n eventTrack(action: string, properties: any) {\n properties = properties || {};\n\n // add properties to payload\n this.payload.action = action;\n this.payload.eventProperties = properties;\n\n if ('undefined' !== typeof _satellite && _satellite) {\n _satellite.track('eventTrack', this.payload);\n }\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from '../../angulartics2-core';\n\ndeclare var mixpanel: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2Mixpanel {\n constructor(private angulartics2: Angulartics2) {\n this.angulartics2.setUsername.subscribe((x: string) => this.setUsername(x));\n this.angulartics2.setUserProperties.subscribe(x => this.setUserProperties(x));\n this.angulartics2.setUserPropertiesOnce.subscribe(x => this.setUserPropertiesOnce(x));\n this.angulartics2.setSuperProperties.subscribe(x => this.setSuperProperties(x));\n this.angulartics2.setSuperPropertiesOnce.subscribe(x => this.setSuperPrope