import TelemetryReporter from 'vscode-extension-telemetry' ; import vscode = require ( 'vscode' ) ; export let reporter ; export class Reporter extends vscode . Disposable { constructor ( ctx ) { super ( ( ) => { if ( reporter ) { reporter . dispose ( ) ; } } ) ; const packageInfo = getPackageInfo ( ctx ) ; reporter = packageInfo && new TelemetryReporter ( packageInfo . name , packageInfo . version , packageInfo . aiKey ) ; } } interface IPackageInfo { name : string ; version : string ; aiKey : string ; } function getPackageInfo ( _context ) { const extensionPackage = require ( '../package' ) ; if ( extensionPackage ) { return { name : extensionPackage . name , version : extensionPackage . version , aiKey : extensionPackage . aiKey } ; } return undefined ; }