ngx-analytics
Version:
Vendor-agnostic web analytics for Angular2 applications, based on angulartics2
77 lines (72 loc) • 2.78 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'].segment = {}),global.ng.core,global['ngx-analytics']));
}(this, (function (exports,core,ngxAnalytics) { 'use strict';
var NgxAnalyticsSegment = (function () {
function NgxAnalyticsSegment(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); });
this.ngxAnalytics.setAlias.subscribe(function (x) { return _this.setAlias(x); });
}
NgxAnalyticsSegment.prototype.pageTrack = function (path) {
try {
analytics.page(path);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsSegment.prototype.eventTrack = function (action, properties) {
try {
analytics.track(action, properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsSegment.prototype.setUserProperties = function (properties) {
try {
if (properties.userId) {
analytics.identify(properties.userId, properties);
}
else {
analytics.identify(properties);
}
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsSegment.prototype.setAlias = function (alias) {
try {
analytics.alias(alias);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsSegment.decorators = [
{ type: core.Injectable },
];
NgxAnalyticsSegment.ctorParameters = function () { return [
{ type: ngxAnalytics.NgxAnalytics, },
]; };
return NgxAnalyticsSegment;
}());
exports.NgxAnalyticsSegment = NgxAnalyticsSegment;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=segment.umd.js.map