import { Location } from '@angular/common' ; import { Injectable } from '@angular/core' ; import { NavigationEnd , Router } from '@angular/router' ; import { delay , filter , map } from 'rxjs/operators' ; import { Observable } from 'rxjs' ; import { RouterlessTracking , TrackNavigationEnd } from './routerless' ; link @ Injectable ( { providedIn : 'root' } ) export class AngularRouterTracking implements RouterlessTracking { constructor ( private router , private location ) { } trackLocation ( settings ) { return this . router . events . pipe ( filter ( e => e instanceof NavigationEnd ) , filter ( ( ) => ! settings . developerMode ) , map ( ( e ) => { return { url : e . urlAfterRedirects } ; } ) , delay ( 0 ) ) ; } prepareExternalUrl ( url ) { return this . location . prepareExternalUrl ( url ) ; } }