{"version":3,"file":"angulartics2-clicky.js","sources":["ng://angulartics2/clicky/clicky.ts","ng://angulartics2/clicky/angulartics2-clicky.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\n\nimport { Angulartics2 } from 'angulartics2';\nimport { ClickyProperties } from './clicky.interfaces';\n\ndeclare var clicky: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2Clicky {\n constructor(\n private angulartics2: Angulartics2,\n private titleService: Title,\n ) {\n if (typeof clicky === 'undefined') {\n console.warn('Angulartics 2 Clicky Plugin: clicky global not found');\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.eventOrGoalTrack(x.action, x.properties));\n }\n\n /**\n * Track Page in Clicky\n *\n * @param path location\n *\n * @link https://clicky.com/help/custom/manual#log\n */\n pageTrack(path: string) {\n const title: string = this.titleService.getTitle();\n clicky.log(path, title, 'pageview');\n }\n\n /**\n * Track Event Or Goal in Clicky\n *\n * @param action Action name\n * @param properties Definition of 'properties.goal' determines goal vs event tracking\n *\n * @link https://clicky.com/help/custom/manual#log\n * @link https://clicky.com/help/custom/manual#goal\n */\n eventOrGoalTrack(action: string, properties: Partial) {\n if (typeof properties.goal === 'undefined') {\n const title: string = properties.title || null;\n const type: string = properties.type != null ? this.validateType(properties.type) : null;\n clicky.log(action, title, type);\n } else {\n const goalId: string = properties.goal;\n const revenue: number = properties.revenue;\n clicky.goal(goalId, revenue, !!properties.noQueue);\n }\n }\n\n private validateType(type: string): string {\n const EventType = ['pageview', 'click', 'download', 'outbound'];\n return EventType.indexOf(type) > -1 ? type : 'pageview';\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './clicky';\n"],"names":[],"mappings":";;;;;IASa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC7B,Y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