{"version":3,"file":"angulartics2-baidu.js","sources":["ng://angulartics2/baidu/baidu.ts","ng://angulartics2/baidu/angulartics2-baidu.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from 'angulartics2';\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './baidu';\n"],"names":[],"mappings":";;;;;IASE,oCAAoB,YAA0B;QAA9C,iBAUC;QAVmB,iBAAY,GAAZ,YAAY,CAAc;QAC5C,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;YAC/B,IAAI,GAAG,EAAE,CAAC;SACX;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;SACxC;QACD,IAAI,CAAC,YAAY,CAAC,WAAW;aAC1B,SAAS,CAAC,UAAC,CAAS,IAAK,OAAA,KAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAA,CAAC,CAAC;QACjD,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;;;;;;;;IASD,8CAAS,GAAT,UAAU,IAAY;QACpB,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,EAAE;YACvC,IAAI,CAAC,IAAI,CA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