import { Injectable } from '@angular/core' ; import { Angulartics2 } from '../../angulartics2-core' ; declare var Pyze ; declare var PyzeEvents ; declare var PyzeIdentity ; @ Injectable ( { providedIn : 'root' } ) export class Angulartics2Pyze { constructor ( private angulartics2 ) { this . angulartics2 . setUsername . subscribe ( ( x ) => this . setUserId ( x ) ) ; this . angulartics2 . setUserProperties . subscribe ( x => this . postTraits ( x ) ) ; } startTracking ( ) { this . angulartics2 . pageTrack . pipe ( this . angulartics2 . filterDeveloperMode ( ) ) . subscribe ( x => this . pageTrack ( x . path ) ) ; this . angulartics2 . eventTrack . pipe ( this . angulartics2 . filterDeveloperMode ( ) ) . subscribe ( x => this . eventTrack ( x . action , x . properties ) ) ; } pageTrack ( path ) { try { Pyze . postPageView ( 'Page Viewed' , { page : path } ) ; } catch ( e ) { if ( ! ( e instanceof ReferenceError ) ) { throw e ; } } } eventTrack ( action , properties ) { try { PyzeEvents . postCustomEventWithAttributes ( action , properties ) ; } catch ( e ) { if ( ! ( e instanceof ReferenceError ) ) { throw e ; } } } setUserId ( userId ) { try { PyzeIdentity . setUserIdentifier ( userId ) ; } catch ( e ) { if ( ! ( e instanceof ReferenceError ) ) { throw e ; } } } postTraits ( properties ) { try { PyzeIdentity . postTraits ( properties ) ; } catch ( e ) { if ( ! ( e instanceof ReferenceError ) ) { throw e ; } } } }