import { Injectable } from '@angular/core' ; import { Visitor } from 'universal-analytics' ; import * as UA from 'universal-analytics' ; import { ConfigurationService } from '../configuration/configuration.service' ; import { ConfigModel } from '../../models/config.model' ; @ Injectable ( ) export class AnalyticsService { private config : ConfigModel ; private visitor : Visitor ; constructor ( private configurationService ) { this . configurationService . getConfiguration ( ) . subscribe ( ( config ) => { this . config = config ; if ( this . config . googleAnalyticsEnabled ) { this . visitor = UA ( this . config . googleAnalyticsId ) ; } } ) ; } getVisitor ( ) { return this . visitor ; } }