UNPKG

ngx-analytics

Version:

Vendor-agnostic web analytics for Angular2 applications, based on angulartics2

108 lines (105 loc) 3.59 kB
import { Injectable } from '@angular/core'; import { NgxAnalytics } from 'ngx-analytics'; var NgxAnalyticsMixpanel = (function () { function NgxAnalyticsMixpanel(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.setUserPropertiesOnce(x); }); this.ngxAnalytics.setSuperProperties.subscribe(function (x) { return _this.setSuperProperties(x); }); this.ngxAnalytics.setSuperPropertiesOnce.subscribe(function (x) { return _this.setSuperPropertiesOnce(x); }); this.ngxAnalytics.setAlias.subscribe(function (x) { return _this.setAlias(x); }); } NgxAnalyticsMixpanel.prototype.pageTrack = function (path) { try { mixpanel.track('Page Viewed', { page: path }); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.prototype.eventTrack = function (action, properties) { try { mixpanel.track(action, properties); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.prototype.setUsername = function (userId) { try { mixpanel.identify(userId); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.prototype.setUserProperties = function (properties) { try { mixpanel.people.set(properties); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.prototype.setUserPropertiesOnce = function (properties) { try { mixpanel.people.set_once(properties); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.prototype.setSuperProperties = function (properties) { try { mixpanel.register(properties); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.prototype.setSuperPropertiesOnce = function (properties) { try { mixpanel.register_once(properties); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.prototype.setAlias = function (alias) { try { mixpanel.alias(alias); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsMixpanel.decorators = [ { type: Injectable }, ]; NgxAnalyticsMixpanel.ctorParameters = function () { return [ { type: NgxAnalytics, }, ]; }; return NgxAnalyticsMixpanel; }()); export { NgxAnalyticsMixpanel }; //# sourceMappingURL=mixpanel.es2015.js.map