ngx-analytics
Version:
Vendor-agnostic web analytics for Angular2 applications, based on angulartics2
74 lines (69 loc) • 2.77 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'].amplitude = {}),global.ng.core,global['ngx-analytics']));
}(this, (function (exports,core,ngxAnalytics) { 'use strict';
var NgxAnalyticsAmplitude = (function () {
function NgxAnalyticsAmplitude(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.setUsername.subscribe(function (x) { return _this.setUsername(x); });
this.ngxAnalytics.setUserProperties.subscribe(function (x) { return _this.setUserProperties(x); });
this.ngxAnalytics.setUserPropertiesOnce.subscribe(function (x) { return _this.setUserProperties(x); });
}
NgxAnalyticsAmplitude.prototype.pageTrack = function (path) {
try {
this.eventTrack('Pageview', {
url: path
});
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsAmplitude.prototype.eventTrack = function (action, properties) {
try {
amplitude.getInstance().logEvent(action, properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsAmplitude.prototype.setUsername = function (userId) {
try {
amplitude.getInstance().setUserId(userId);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsAmplitude.prototype.setUserProperties = function (properties) {
try {
amplitude.getInstance().setUserProperties(properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
NgxAnalyticsAmplitude.decorators = [
{ type: core.Injectable },
];
NgxAnalyticsAmplitude.ctorParameters = function () { return [
{ type: ngxAnalytics.NgxAnalytics, },
]; };
return NgxAnalyticsAmplitude;
}());
exports.NgxAnalyticsAmplitude = NgxAnalyticsAmplitude;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=amplitude.umd.js.map