UNPKG

5.21 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('angulartics2')) :
3 typeof define === 'function' && define.amd ? define('angulartics2/mixpanel', ['exports', '@angular/core', 'angulartics2'], factory) :
4 (global = global || self, factory((global.angulartics2 = global.angulartics2 || {}, global.angulartics2.mixpanel = {}), global.ng.core, global.angulartics2));
5}(this, (function (exports, i0, i1) { 'use strict';
6
7 var Angulartics2Mixpanel = /** @class */ (function () {
8 function Angulartics2Mixpanel(angulartics2) {
9 var _this = this;
10 this.angulartics2 = angulartics2;
11 this.angulartics2.setUsername
12 .subscribe(function (x) { return _this.setUsername(x); });
13 this.angulartics2.setUserProperties
14 .subscribe(function (x) { return _this.setUserProperties(x); });
15 this.angulartics2.setUserPropertiesOnce
16 .subscribe(function (x) { return _this.setUserPropertiesOnce(x); });
17 this.angulartics2.setSuperProperties
18 .subscribe(function (x) { return _this.setSuperProperties(x); });
19 this.angulartics2.setSuperPropertiesOnce
20 .subscribe(function (x) { return _this.setSuperPropertiesOnce(x); });
21 this.angulartics2.setAlias
22 .subscribe(function (x) { return _this.setAlias(x); });
23 }
24 Angulartics2Mixpanel.prototype.startTracking = function () {
25 var _this = this;
26 this.angulartics2.pageTrack
27 .pipe(this.angulartics2.filterDeveloperMode())
28 .subscribe(function (x) { return _this.pageTrack(x.path); });
29 this.angulartics2.eventTrack
30 .pipe(this.angulartics2.filterDeveloperMode())
31 .subscribe(function (x) { return _this.eventTrack(x.action, x.properties); });
32 };
33 Angulartics2Mixpanel.prototype.pageTrack = function (path) {
34 try {
35 mixpanel.track('Page Viewed', { page: path });
36 }
37 catch (e) {
38 if (!(e instanceof ReferenceError)) {
39 throw e;
40 }
41 }
42 };
43 Angulartics2Mixpanel.prototype.eventTrack = function (action, properties) {
44 try {
45 mixpanel.track(action, properties);
46 }
47 catch (e) {
48 if (!(e instanceof ReferenceError)) {
49 throw e;
50 }
51 }
52 };
53 Angulartics2Mixpanel.prototype.setUsername = function (userId) {
54 try {
55 mixpanel.identify(userId);
56 }
57 catch (e) {
58 if (!(e instanceof ReferenceError)) {
59 throw e;
60 }
61 }
62 };
63 Angulartics2Mixpanel.prototype.setUserProperties = function (properties) {
64 try {
65 mixpanel.people.set(properties);
66 }
67 catch (e) {
68 if (!(e instanceof ReferenceError)) {
69 throw e;
70 }
71 }
72 };
73 Angulartics2Mixpanel.prototype.setUserPropertiesOnce = function (properties) {
74 try {
75 mixpanel.people.set_once(properties);
76 }
77 catch (e) {
78 if (!(e instanceof ReferenceError)) {
79 throw e;
80 }
81 }
82 };
83 Angulartics2Mixpanel.prototype.setSuperProperties = function (properties) {
84 try {
85 mixpanel.register(properties);
86 }
87 catch (e) {
88 if (!(e instanceof ReferenceError)) {
89 throw e;
90 }
91 }
92 };
93 Angulartics2Mixpanel.prototype.setSuperPropertiesOnce = function (properties) {
94 try {
95 mixpanel.register_once(properties);
96 }
97 catch (e) {
98 if (!(e instanceof ReferenceError)) {
99 throw e;
100 }
101 }
102 };
103 Angulartics2Mixpanel.prototype.setAlias = function (alias) {
104 try {
105 mixpanel.alias(alias);
106 }
107 catch (e) {
108 if (!(e instanceof ReferenceError)) {
109 throw e;
110 }
111 }
112 };
113 return Angulartics2Mixpanel;
114 }());
115 Angulartics2Mixpanel.ɵprov = i0.ɵɵdefineInjectable({ factory: function Angulartics2Mixpanel_Factory() { return new Angulartics2Mixpanel(i0.ɵɵinject(i1.Angulartics2)); }, token: Angulartics2Mixpanel, providedIn: "root" });
116 Angulartics2Mixpanel.decorators = [
117 { type: i0.Injectable, args: [{ providedIn: 'root' },] }
118 ];
119 Angulartics2Mixpanel.ctorParameters = function () { return [
120 { type: i1.Angulartics2 }
121 ]; };
122
123 /**
124 * Generated bundle index. Do not edit.
125 */
126
127 exports.Angulartics2Mixpanel = Angulartics2Mixpanel;
128
129 Object.defineProperty(exports, '__esModule', { value: true });
130
131})));
132//# sourceMappingURL=angulartics2-mixpanel.umd.js.map