@kurkov87/ngx-analytics
Version:
Vendor-agnostic web analytics for Angular2 applications, based on angulartics2
67 lines (64 loc) • 2.33 kB
JavaScript
import { Injectable } from '@angular/core';
import { NgxAnalytics } from 'ngx-analytics';
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: Injectable },
];
NgxAnalyticsAmplitude.ctorParameters = function () { return [
{ type: NgxAnalytics, },
]; };
return NgxAnalyticsAmplitude;
}());
export { NgxAnalyticsAmplitude };
//# sourceMappingURL=amplitude.es2015.js.map