import * as ua from 'universal-analytics' ; import { IAnalyticsBaseInfo , OperatingSystem } from './analyticsBaseInfo' ; /**
 * Google Universal Analytics Service
 */ export class GUAService { private _visitor : ua . Visitor ; private _getBasePayload : ( ) => any ; constructor ( trackingId , baseInfo ) { const proxy = process . env . HTTP_PROXY || process . env . HTTPS_PROXY ; const requestOptions = proxy ? { proxy } : { } ; this . _visitor = ua ( trackingId , baseInfo . clientId , { requestOptions , strictCidFormat : false } ) ; this . _getBasePayload = ( ) => { return { cd5 : baseInfo . cliVersion , cd6 : OperatingSystem [ baseInfo . operatingSystem ] , cd7 : baseInfo . extensionVersion , cid : baseInfo . clientId , dh : 'ns-vs-extension.org' , } ; } ; } public launchDebugger ( request , platform ) { const payload = this . _getBasePayload ( ) ; payload . ec = 'vscode-extension-debug' ; payload . ea = `debug-${ request }-on-${ platform }` ; return this . sendEvent ( payload ) ; } public runRunCommand ( platform ) { const payload = this . _getBasePayload ( ) ; payload . ec = 'vscode-extension-command' ; payload . ea = `command-run-on-${ platform }` ; return this . sendEvent ( payload ) ; } private sendEvent ( params ) { return new Promise < any > ( ( res , rej ) => { this . _visitor . event ( params , ( err ) => { return err ? rej ( err ) : res ( ) ; } ) ; } ) ; } }