gtmeventtracking
Version:
GTM Google event Tracking Management System
118 lines (115 loc) • 3.8 kB
JavaScript
import { Injectable } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
var Angulartics2Mixpanel = (function () {
function Angulartics2Mixpanel(angulartics2) {
var _this = this;
this.angulartics2 = angulartics2;
this.angulartics2.pageTrack
.pipe(this.angulartics2.filterDeveloperMode())
.subscribe(function (x) { return _this.pageTrack(x.path); });
this.angulartics2.eventTrack
.pipe(this.angulartics2.filterDeveloperMode())
.subscribe(function (x) { return _this.eventTrack(x.action, x.properties); });
this.angulartics2.setUsername
.subscribe(function (x) { return _this.setUsername(x); });
this.angulartics2.setUserProperties
.subscribe(function (x) { return _this.setUserProperties(x); });
this.angulartics2.setUserPropertiesOnce
.subscribe(function (x) { return _this.setUserPropertiesOnce(x); });
this.angulartics2.setSuperProperties
.subscribe(function (x) { return _this.setSuperProperties(x); });
this.angulartics2.setSuperPropertiesOnce
.subscribe(function (x) { return _this.setSuperPropertiesOnce(x); });
this.angulartics2.setAlias
.subscribe(function (x) { return _this.setAlias(x); });
}
Angulartics2Mixpanel.prototype.pageTrack = function (path) {
try {
mixpanel.track('Page Viewed', { page: path });
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.prototype.eventTrack = function (action, properties) {
try {
mixpanel.track(action, properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.prototype.setUsername = function (userId) {
try {
mixpanel.identify(userId);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.prototype.setUserProperties = function (properties) {
try {
mixpanel.people.set(properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.prototype.setUserPropertiesOnce = function (properties) {
try {
mixpanel.people.set_once(properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.prototype.setSuperProperties = function (properties) {
try {
mixpanel.register(properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.prototype.setSuperPropertiesOnce = function (properties) {
try {
mixpanel.register_once(properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.prototype.setAlias = function (alias) {
try {
mixpanel.alias(alias);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Mixpanel.decorators = [
{ type: Injectable },
];
Angulartics2Mixpanel.ctorParameters = function () { return [
{ type: Angulartics2, },
]; };
return Angulartics2Mixpanel;
}());
export { Angulartics2Mixpanel };
//# sourceMappingURL=mixpanel.es2015.js.map