import moment , { Moment } from 'moment-timezone' ; import { METRIC_TYPE } from './' ; export interface ApplicationUsageCurrent { type : METRIC_TYPE . APPLICATION_USAGE ; appId : string ; startTime : Moment ; numberOfClicks : number ; } export class ApplicationUsage { private currentUsage ? : ApplicationUsageCurrent ; public start ( ) { if ( window ) window . addEventListener ( 'click' , ( ) => this . currentUsage && this . currentUsage . numberOfClicks ++ ) ; } public appChanged ( appId ? ) { const currentUsage = this . currentUsage ; if ( appId ) { this . currentUsage = { type : METRIC_TYPE . APPLICATION_USAGE , appId , startTime : moment ( ) , numberOfClicks : 0 , } ; } else { this . currentUsage = void 0 ; } return currentUsage ; } }