UNPKG

@kurkov87/ngx-analytics

Version:

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

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