UNPKG

loop-modules

Version:

Shared modules for the Loop product suite.

35 lines (34 loc) 1.04 kB
// angular import { NavigationStart } from '@angular/router'; var TrackableEntity = (function () { function TrackableEntity(router, routeUrl) { var _this = this; this.router = router; this.routeUrl = routeUrl; if (this.router.routerState.snapshot.url.indexOf(routeUrl) !== -1) { this.started_at = Date.now(); } this.router.events.subscribe(function (event) { if (event instanceof NavigationStart) { _this.ended_at = Date.now(); if (_this.started_at) { _this.track(_this.started_at, _this.ended_at); _this.clearTracking(); } } }); } /** * Clears the tracking meta data * * @private * * @memberOf TrackableEntity */ TrackableEntity.prototype.clearTracking = function () { this.started_at = undefined; this.ended_at = undefined; }; return TrackableEntity; }()); export { TrackableEntity };