{"version":3,"file":"angulartics2-intercom.js","sources":["ng://angulartics2/intercom/intercom.ts","ng://angulartics2/intercom/angulartics2-intercom.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { Angulartics2 } from 'angulartics2';\n\ndeclare var Intercom: any;\n\n@Injectable({ providedIn: 'root' })\nexport class Angulartics2Intercom {\n\n constructor(\n private angulartics2: Angulartics2\n ) {\n this.angulartics2.setUserProperties\n .subscribe((x) => this.setUserProperties(x));\n this.angulartics2.setUserPropertiesOnce\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 try {\n this.eventTrack('Pageview', {\n url: path\n });\n } catch (e) {\n if (!(e instanceof ReferenceError)) {\n throw e;\n }\n }\n }\n\n eventTrack(action: string, properties: any) {\n try {\n Intercom('trackEvent', action, properties);\n } catch (e) {\n if (!(e instanceof ReferenceError)) {\n throw e;\n }\n }\n }\n\n setUserProperties(properties: any) {\n try {\n if (properties.userId && !properties.user_id) {\n properties.user_id = properties.userId;\n }\n\n Intercom('boot', properties);\n } catch (e) {\n if (!(e instanceof ReferenceError)) {\n throw e;\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './intercom';\n"],"names":[],"mappings":";;;;;IASE,8BACU,YAA0B;QADpC,iBAOC;QANS,iBAAY,GAAZ,YAAY,CAAc;QAElC,IAAI,CAAC,YAAY,CAAC,iBAAiB;aAChC,SAAS,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAA,CAAC,CAAC;QAC/C,IAAI,CAAC,YAAY,CAAC,qBAAqB;aACpC,SAAS,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAA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