1 | import { ɵɵdefineInjectable, ɵɵinject, Injectable } from '@angular/core';
|
2 | import { Angulartics2 } from 'angulartics2';
|
3 |
|
4 | class Angulartics2Mixpanel {
|
5 | constructor(angulartics2) {
|
6 | this.angulartics2 = angulartics2;
|
7 | this.angulartics2.setUsername
|
8 | .subscribe((x) => this.setUsername(x));
|
9 | this.angulartics2.setUserProperties
|
10 | .subscribe((x) => this.setUserProperties(x));
|
11 | this.angulartics2.setUserPropertiesOnce
|
12 | .subscribe((x) => this.setUserPropertiesOnce(x));
|
13 | this.angulartics2.setSuperProperties
|
14 | .subscribe((x) => this.setSuperProperties(x));
|
15 | this.angulartics2.setSuperPropertiesOnce
|
16 | .subscribe((x) => this.setSuperPropertiesOnce(x));
|
17 | this.angulartics2.setAlias
|
18 | .subscribe((x) => this.setAlias(x));
|
19 | }
|
20 | startTracking() {
|
21 | this.angulartics2.pageTrack
|
22 | .pipe(this.angulartics2.filterDeveloperMode())
|
23 | .subscribe((x) => this.pageTrack(x.path));
|
24 | this.angulartics2.eventTrack
|
25 | .pipe(this.angulartics2.filterDeveloperMode())
|
26 | .subscribe((x) => this.eventTrack(x.action, x.properties));
|
27 | }
|
28 | pageTrack(path) {
|
29 | try {
|
30 | mixpanel.track('Page Viewed', { page: path });
|
31 | }
|
32 | catch (e) {
|
33 | if (!(e instanceof ReferenceError)) {
|
34 | throw e;
|
35 | }
|
36 | }
|
37 | }
|
38 | eventTrack(action, properties) {
|
39 | try {
|
40 | mixpanel.track(action, properties);
|
41 | }
|
42 | catch (e) {
|
43 | if (!(e instanceof ReferenceError)) {
|
44 | throw e;
|
45 | }
|
46 | }
|
47 | }
|
48 | setUsername(userId) {
|
49 | try {
|
50 | mixpanel.identify(userId);
|
51 | }
|
52 | catch (e) {
|
53 | if (!(e instanceof ReferenceError)) {
|
54 | throw e;
|
55 | }
|
56 | }
|
57 | }
|
58 | setUserProperties(properties) {
|
59 | try {
|
60 | mixpanel.people.set(properties);
|
61 | }
|
62 | catch (e) {
|
63 | if (!(e instanceof ReferenceError)) {
|
64 | throw e;
|
65 | }
|
66 | }
|
67 | }
|
68 | setUserPropertiesOnce(properties) {
|
69 | try {
|
70 | mixpanel.people.set_once(properties);
|
71 | }
|
72 | catch (e) {
|
73 | if (!(e instanceof ReferenceError)) {
|
74 | throw e;
|
75 | }
|
76 | }
|
77 | }
|
78 | setSuperProperties(properties) {
|
79 | try {
|
80 | mixpanel.register(properties);
|
81 | }
|
82 | catch (e) {
|
83 | if (!(e instanceof ReferenceError)) {
|
84 | throw e;
|
85 | }
|
86 | }
|
87 | }
|
88 | setSuperPropertiesOnce(properties) {
|
89 | try {
|
90 | mixpanel.register_once(properties);
|
91 | }
|
92 | catch (e) {
|
93 | if (!(e instanceof ReferenceError)) {
|
94 | throw e;
|
95 | }
|
96 | }
|
97 | }
|
98 | setAlias(alias) {
|
99 | try {
|
100 | mixpanel.alias(alias);
|
101 | }
|
102 | catch (e) {
|
103 | if (!(e instanceof ReferenceError)) {
|
104 | throw e;
|
105 | }
|
106 | }
|
107 | }
|
108 | }
|
109 | Angulartics2Mixpanel.ɵprov = ɵɵdefineInjectable({ factory: function Angulartics2Mixpanel_Factory() { return new Angulartics2Mixpanel(ɵɵinject(Angulartics2)); }, token: Angulartics2Mixpanel, providedIn: "root" });
|
110 | Angulartics2Mixpanel.decorators = [
|
111 | { type: Injectable, args: [{ providedIn: 'root' },] }
|
112 | ];
|
113 | Angulartics2Mixpanel.ctorParameters = () => [
|
114 | { type: Angulartics2 }
|
115 | ];
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | export { Angulartics2Mixpanel };
|
122 |
|