import { Inject, Injectable, } from '@angular/core'; import { BrandSettingsInterface, TrackingEventInterface, TrackingServiceInterface, } from './../../../models/index'; import * as analytics from 'universal-ga'; @Injectable() export class UniversalAnalyticsTrackingService implements TrackingServiceInterface { constructor( @Inject('brandSettings') private _brandSettings: BrandSettingsInterface, ) { analytics.initialize(this._brandSettings.universalAnalyticsToken); } public sendEvent(event: TrackingEventInterface) { analytics.event( event.name, 'action', JSON.stringify(event.properties), ); } }