UNPKG

@kurkov87/ngx-analytics

Version:

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

60 lines (57 loc) 1.91 kB
import { Injectable } from '@angular/core'; import { NgxAnalytics } from 'ngx-analytics'; var NgxAnalyticsWoopra = (function () { function NgxAnalyticsWoopra(ngxAnalytics$$1) { var _this = this; this.ngxAnalytics = ngxAnalytics$$1; if (typeof (woopra) === 'undefined') { console.warn('Woopra not found'); } 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); }); } NgxAnalyticsWoopra.prototype.pageTrack = function (path) { try { woopra.track('pv', { url: path }); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsWoopra.prototype.eventTrack = function (action, properties) { try { woopra.track(action, properties); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsWoopra.prototype.setUserProperties = function (properties) { try { if (properties.email) { woopra.identify(properties); } } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; NgxAnalyticsWoopra.decorators = [ { type: Injectable }, ]; NgxAnalyticsWoopra.ctorParameters = function () { return [ { type: NgxAnalytics, }, ]; }; return NgxAnalyticsWoopra; }()); export { NgxAnalyticsWoopra }; //# sourceMappingURL=woopra.es2015.js.map