UNPKG

gtmeventtracking

Version:
77 lines (74 loc) 2.46 kB
import { Injectable } from '@angular/core'; import { Angulartics2 } from 'angulartics2'; var Angulartics2Segment = (function () { function Angulartics2Segment(angulartics2) { var _this = this; this.angulartics2 = angulartics2; this.angulartics2.pageTrack .pipe(this.angulartics2.filterDeveloperMode()) .subscribe(function (x) { return _this.pageTrack(x.path); }); this.angulartics2.eventTrack .pipe(this.angulartics2.filterDeveloperMode()) .subscribe(function (x) { return _this.eventTrack(x.action, x.properties); }); this.angulartics2.setUserProperties .subscribe(function (x) { return _this.setUserProperties(x); }); this.angulartics2.setUserPropertiesOnce .subscribe(function (x) { return _this.setUserProperties(x); }); this.angulartics2.setAlias .subscribe(function (x) { return _this.setAlias(x); }); } Angulartics2Segment.prototype.pageTrack = function (path) { try { analytics.page(path); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; Angulartics2Segment.prototype.eventTrack = function (action, properties) { try { analytics.track(action, properties); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; Angulartics2Segment.prototype.setUserProperties = function (properties) { try { if (properties.userId) { analytics.identify(properties.userId, properties); } else { analytics.identify(properties); } } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; Angulartics2Segment.prototype.setAlias = function (alias) { try { analytics.alias(alias); } catch (e) { if (!(e instanceof ReferenceError)) { throw e; } } }; Angulartics2Segment.decorators = [ { type: Injectable }, ]; Angulartics2Segment.ctorParameters = function () { return [ { type: Angulartics2, }, ]; }; return Angulartics2Segment; }()); export { Angulartics2Segment }; //# sourceMappingURL=segment.es2015.js.map