@kurkov87/ngx-analytics
Version:
Vendor-agnostic web analytics for Angular2 applications, based on angulartics2
59 lines (56 loc) • 2.03 kB
JavaScript
import { Injectable } from '@angular/core';
import { NgxAnalytics } from 'ngx-analytics';
var NgxAnalyticsIntercom = (function () {
function NgxAnalyticsIntercom(ngxAnalytics$$1) {
var _this = this;
this.ngxAnalytics = ngxAnalytics$$1;
this.ngxAnalytics.pageTrack.subscribe(function (x) { return _this.pageTrack(x.path); });
this.ngxAnalytics.eventTrack.subscribe(function (x) { return _this.eventTrack(x.action, x.properties); });
this.ngxAnalytics.setUserProperties.subscribe(function (x) { return _this.setUserProperties(x); });
this.ngxAnalytics.setUserPropertiesOnce.subscribe(function (x) { return _this.setUserProperties(x); });
}
NgxAnalyticsIntercom.prototype.pageTrack = function (path) {
try {
this.eventTrack('Pageview', {
url: path
});
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsIntercom.prototype.eventTrack = function (action, properties) {
try {
Intercom('trackEvent', action, properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsIntercom.prototype.setUserProperties = function (properties) {
try {
if (properties.userId && !properties.user_id) {
properties.user_id = properties.userId;
}
Intercom('boot', properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsIntercom.decorators = [
{ type: Injectable },
];
NgxAnalyticsIntercom.ctorParameters = function () { return [
{ type: NgxAnalytics, },
]; };
return NgxAnalyticsIntercom;
}());
export { NgxAnalyticsIntercom };
//# sourceMappingURL=intercom.es2015.js.map