import { IAnalytics , IAnalyticsUser , IEventArgs , IPageEvent , TraitsMap } from "./IAnalytics" ; export class CompositeAnalytics implements IAnalytics { constructor ( private readonly delegates ) { } public event ( event ) { this . invoke ( delegate => delegate . event ( event ) ) ; } public event2 ( event , data ? ) { this . invoke ( delegate => delegate . event2 ( event , data ) ) ; } public identify ( user ) { this . invoke ( delegate => delegate . identify ( user ) ) ; } public page ( event ) { this . invoke ( delegate => delegate . page ( event ) ) ; } public traits ( map ) { this . invoke ( delegate => delegate . traits ( map ) ) ; } public version ( version ) { this . invoke ( delegate => delegate . version ( version ) ) ; } public heartbeat ( ) { this . invoke ( delegate => delegate . heartbeat ( ) ) ; } public logout ( ) { this . invoke ( delegate => delegate . logout ( ) ) ; } private invoke ( handler ) { for ( const delegate of this . delegates ) { try { handler ( delegate ) ; } catch ( e ) { console . error ( e ) ; } } } }