ngx-analytics
Version:
Vendor-agnostic web analytics for Angular2 applications, based on angulartics2
66 lines (61 loc) • 2.49 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-analytics')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'ngx-analytics'], factory) :
(factory((global['ngx-analytics'] = global['ngx-analytics'] || {}, global['ngx-analytics'].intercom = {}),global.ng.core,global['ngx-analytics']));
}(this, (function (exports,core,ngxAnalytics) { 'use strict';
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: core.Injectable },
];
NgxAnalyticsIntercom.ctorParameters = function () { return [
{ type: ngxAnalytics.NgxAnalytics, },
]; };
return NgxAnalyticsIntercom;
}());
exports.NgxAnalyticsIntercom = NgxAnalyticsIntercom;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=intercom.umd.js.map