UNPKG

ngx-analytics

Version:

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

115 lines (110 loc) 4.09 kB
(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'].mixpanel = {}),global.ng.core,global['ngx-analytics'])); }(this, (function (exports,core,ngxAnalytics) { 'use strict'; 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: core.Injectable }, ]; NgxAnalyticsMixpanel.ctorParameters = function () { return [ { type: ngxAnalytics.NgxAnalytics, }, ]; }; return NgxAnalyticsMixpanel; }()); exports.NgxAnalyticsMixpanel = NgxAnalyticsMixpanel; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=mixpanel.umd.js.map