|
| 1 | +importTelemetryReporterfrom'vscode-extension-telemetry' |
| 2 | +import{EXTENSION_ID,VERSION,INSTRUMENTATION_KEY,NODE_ENV}from'../../environment' |
| 3 | + |
| 4 | +/** |
| 5 | + * Telemetry |
| 6 | + * https://github.com/microsoft/vscode-extension-telemetry |
| 7 | + * |
| 8 | + */ |
| 9 | + |
| 10 | +interfaceProperties{ |
| 11 | +[key:string]:string |
| 12 | +} |
| 13 | + |
| 14 | +interfaceMeasurements{ |
| 15 | +[key:string]:number |
| 16 | +} |
| 17 | + |
| 18 | +letreporter:any |
| 19 | + |
| 20 | +exportconstactivate=(subscribeFn:(reporter:any)=>void):void=>{ |
| 21 | +if(NODE_ENV==='production'){ |
| 22 | +reporter=newTelemetryReporter(EXTENSION_ID,VERSION,INSTRUMENTATION_KEY) |
| 23 | +subscribeFn(reporter) |
| 24 | +} |
| 25 | +} |
| 26 | + |
| 27 | +exportconstdeactivate=():void=>{ |
| 28 | +if(reporter){ |
| 29 | +reporter.dispose() |
| 30 | +} |
| 31 | +} |
| 32 | + |
| 33 | +exportconstonError=(error:Error,properties?:Properties,measurements?:Measurements):void=>{ |
| 34 | +if(reporter){ |
| 35 | +reporter.sendTelemetryException(error,properties,measurements) |
| 36 | +} |
| 37 | +} |
| 38 | + |
| 39 | +exportconstonEvent=(eventName:string,properties?:Properties,measurements?:Measurements):void=>{ |
| 40 | +if(reporter){ |
| 41 | +reporter.sendTelemetryEvent(eventName,properties,measurements) |
| 42 | +} |
| 43 | +} |