@vscode/extension-telemetry
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -38,3 +38,13 @@ /*--------------------------------------------------------- | ||
flush: async () => { | ||
appInsightsClient?.flush(); | ||
appInsightsClient?.flush(false); | ||
}, | ||
dispose: async () => { | ||
appInsightsClient?.flush(true); | ||
const unloadPromise = new Promise((resolve) => { | ||
appInsightsClient?.unload(true, () => { | ||
resolve(); | ||
appInsightsClient = undefined; | ||
}); | ||
}); | ||
return unloadPromise; | ||
} | ||
@@ -41,0 +51,0 @@ }; |
@@ -59,3 +59,23 @@ /*--------------------------------------------------------------------------------------------- | ||
export const oneDataSystemClientFactory = async (key, vscodeAPI, xhrOverride) => { | ||
const appInsightsCore = await getAICore(key, vscodeAPI, xhrOverride); | ||
let appInsightsCore = await getAICore(key, vscodeAPI, xhrOverride); | ||
const flushOneDS = async () => { | ||
try { | ||
const flushPromise = new Promise((resolve, reject) => { | ||
if (!appInsightsCore) { | ||
resolve(); | ||
return; | ||
} | ||
appInsightsCore.flush(true, (completedFlush) => { | ||
if (!completedFlush) { | ||
reject("Failed to flush app 1DS!"); | ||
return; | ||
} | ||
}); | ||
}); | ||
return flushPromise; | ||
} | ||
catch (e) { | ||
throw new Error("Failed to flush 1DS!\n" + e.message); | ||
} | ||
}; | ||
// Shape the app insights core from 1DS into a standard format | ||
@@ -74,25 +94,17 @@ const telemetryClient = { | ||
}, | ||
flush: async () => { | ||
try { | ||
const flushPromise = new Promise((resolve, reject) => { | ||
if (!appInsightsCore) { | ||
resolve(); | ||
return; | ||
} | ||
appInsightsCore.flush(true, (completedFlush) => { | ||
if (!completedFlush) { | ||
reject("Failed to flush app 1DS!"); | ||
return; | ||
} | ||
appInsightsCore.unload(true, () => { | ||
resolve(); | ||
return; | ||
}); | ||
}); | ||
flush: flushOneDS, | ||
dispose: async () => { | ||
await flushOneDS(); | ||
const disposePromise = new Promise((resolve) => { | ||
if (!appInsightsCore) { | ||
resolve(); | ||
return; | ||
} | ||
appInsightsCore.unload(true, () => { | ||
resolve(); | ||
appInsightsCore = undefined; | ||
return; | ||
}); | ||
return flushPromise; | ||
} | ||
catch (e) { | ||
throw new Error("Failed to flush 1DS!\n" + e.message); | ||
} | ||
}); | ||
return disposePromise; | ||
} | ||
@@ -99,0 +111,0 @@ }; |
@@ -71,2 +71,15 @@ /*--------------------------------------------------------- | ||
/** | ||
* Sends a raw (unsanitized) telemetry event with the given properties and measurements. | ||
* NOTE: This will not be logged to the output channel due to API limitations. | ||
* @param eventName The name of the event | ||
* @param properties The set of properties to add to the event in the form of a string key value pair | ||
* @param measurements The set of measurements to add to the event in the form of a string key number value pair | ||
*/ | ||
sendRawTelemetryEvent(eventName, properties, measurements) { | ||
// Check level then send off dangerously which skips the API as the API sanitizes everything. | ||
if (this.telemetryLevel === "all") { | ||
this.internalSendTelemetryEvent(eventName, properties, measurements, true); | ||
} | ||
} | ||
/** | ||
* **DANGEROUS** Given an event name, some properties, and measurements sends a telemetry event without checking telemetry setting | ||
@@ -125,3 +138,4 @@ * Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development | ||
*/ | ||
dispose() { | ||
async dispose() { | ||
await this.telemetrySender.dispose(); | ||
this.telemetryLogger.dispose(); | ||
@@ -128,0 +142,0 @@ return Promise.all(this.disposables.map(d => d.dispose())); |
@@ -61,4 +61,8 @@ /*--------------------------------------------------------- | ||
async flush() { | ||
return this._telemetryClient?.flush(); | ||
} | ||
async dispose() { | ||
await this.flush(); | ||
if (this._telemetryClient) { | ||
await this._telemetryClient.flush(); | ||
await this._telemetryClient.dispose(); | ||
this._telemetryClient = undefined; | ||
@@ -65,0 +69,0 @@ } |
@@ -53,3 +53,3 @@ /*--------------------------------------------------------- | ||
// Do not change this string as it gets found and replaced upon packaging | ||
"common.telemetryclientversion": "0.8.1" | ||
"common.telemetryclientversion": "0.8.2" | ||
}; | ||
@@ -56,0 +56,0 @@ } |
@@ -85,3 +85,23 @@ "use strict"; | ||
const oneDataSystemClientFactory = async (key, vscodeAPI, xhrOverride) => { | ||
const appInsightsCore = await getAICore(key, vscodeAPI, xhrOverride); | ||
let appInsightsCore = await getAICore(key, vscodeAPI, xhrOverride); | ||
const flushOneDS = async () => { | ||
try { | ||
const flushPromise = new Promise((resolve, reject) => { | ||
if (!appInsightsCore) { | ||
resolve(); | ||
return; | ||
} | ||
appInsightsCore.flush(true, (completedFlush) => { | ||
if (!completedFlush) { | ||
reject("Failed to flush app 1DS!"); | ||
return; | ||
} | ||
}); | ||
}); | ||
return flushPromise; | ||
} | ||
catch (e) { | ||
throw new Error("Failed to flush 1DS!\n" + e.message); | ||
} | ||
}; | ||
// Shape the app insights core from 1DS into a standard format | ||
@@ -100,25 +120,17 @@ const telemetryClient = { | ||
}, | ||
flush: async () => { | ||
try { | ||
const flushPromise = new Promise((resolve, reject) => { | ||
if (!appInsightsCore) { | ||
resolve(); | ||
return; | ||
} | ||
appInsightsCore.flush(true, (completedFlush) => { | ||
if (!completedFlush) { | ||
reject("Failed to flush app 1DS!"); | ||
return; | ||
} | ||
appInsightsCore.unload(true, () => { | ||
resolve(); | ||
return; | ||
}); | ||
}); | ||
flush: flushOneDS, | ||
dispose: async () => { | ||
await flushOneDS(); | ||
const disposePromise = new Promise((resolve) => { | ||
if (!appInsightsCore) { | ||
resolve(); | ||
return; | ||
} | ||
appInsightsCore.unload(true, () => { | ||
resolve(); | ||
appInsightsCore = undefined; | ||
return; | ||
}); | ||
return flushPromise; | ||
} | ||
catch (e) { | ||
throw new Error("Failed to flush 1DS!\n" + e.message); | ||
} | ||
}); | ||
return disposePromise; | ||
} | ||
@@ -125,0 +137,0 @@ }; |
@@ -74,2 +74,15 @@ "use strict"; | ||
/** | ||
* Sends a raw (unsanitized) telemetry event with the given properties and measurements. | ||
* NOTE: This will not be logged to the output channel due to API limitations. | ||
* @param eventName The name of the event | ||
* @param properties The set of properties to add to the event in the form of a string key value pair | ||
* @param measurements The set of measurements to add to the event in the form of a string key number value pair | ||
*/ | ||
sendRawTelemetryEvent(eventName, properties, measurements) { | ||
// Check level then send off dangerously which skips the API as the API sanitizes everything. | ||
if (this.telemetryLevel === "all") { | ||
this.internalSendTelemetryEvent(eventName, properties, measurements, true); | ||
} | ||
} | ||
/** | ||
* **DANGEROUS** Given an event name, some properties, and measurements sends a telemetry event without checking telemetry setting | ||
@@ -128,3 +141,4 @@ * Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development | ||
*/ | ||
dispose() { | ||
async dispose() { | ||
await this.telemetrySender.dispose(); | ||
this.telemetryLogger.dispose(); | ||
@@ -131,0 +145,0 @@ return Promise.all(this.disposables.map(d => d.dispose())); |
@@ -64,4 +64,8 @@ "use strict"; | ||
async flush() { | ||
return this._telemetryClient?.flush(); | ||
} | ||
async dispose() { | ||
await this.flush(); | ||
if (this._telemetryClient) { | ||
await this._telemetryClient.flush(); | ||
await this._telemetryClient.dispose(); | ||
this._telemetryClient = undefined; | ||
@@ -68,0 +72,0 @@ } |
@@ -56,3 +56,3 @@ "use strict"; | ||
// Do not change this string as it gets found and replaced upon packaging | ||
"common.telemetryclientversion": "0.8.1" | ||
"common.telemetryclientversion": "0.8.2" | ||
}; | ||
@@ -59,0 +59,0 @@ } |
@@ -65,2 +65,3 @@ "use strict"; | ||
.setAutoCollectHeartbeat(false) | ||
.setAutoCollectIncomingRequestAzureFunctions(false) | ||
.setUseDiskRetryCaching(true) | ||
@@ -104,2 +105,6 @@ .start(); | ||
} | ||
}, | ||
dispose: async () => { | ||
appInsightsClient?.flush(); | ||
appInsightsClient = undefined; | ||
} | ||
@@ -106,0 +111,0 @@ }; |
@@ -6,9 +6,5 @@ /*--------------------------------------------------------- | ||
export interface TelemetryEventProperties { | ||
readonly [key: string]: string; | ||
readonly [key: string]: string | undefined; | ||
} | ||
export interface RawTelemetryEventProperties { | ||
readonly [key: string]: any; | ||
} | ||
export interface TelemetryEventMeasurements { | ||
@@ -62,2 +58,3 @@ readonly [key: string]: number; | ||
* Sends a raw (unsanitized) telemetry event with the given properties and measurements | ||
* NOTE: This will not be logged to the output channel due to API limitations. | ||
* @param eventName The name of the event | ||
@@ -67,3 +64,3 @@ * @param properties The set of properties to add to the event in the form of a string key value pair | ||
*/ | ||
sendRawTelemetryEvent(eventName: string, properties?: RawTelemetryEventProperties, measurements?: TelemetryEventMeasurements): void; | ||
sendRawTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void; | ||
@@ -73,2 +70,3 @@ /** | ||
* Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development | ||
* NOTE: This will not be logged to the output channel due to API limitations. | ||
* @param eventName The name of the event | ||
@@ -92,2 +90,3 @@ * @param properties The properties to send with the event | ||
* Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development | ||
* NOTE: This will not be logged to the output channel due to API limitations. | ||
* @param eventName The name of the event | ||
@@ -94,0 +93,0 @@ * @param properties The properties to send with the event |
{ | ||
"name": "@vscode/extension-telemetry", | ||
"description": "A module for Visual Studio Code extensions to report consistent telemetry.", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Microsoft Corporation" |
@@ -44,13 +44,2 @@ # [@vscode/extension-telemetry](https://www.npmjs.com/package/@vscode/extension-telemetry) | ||
## Sending Exceptions | ||
Use this method for diagnostics in App Insights. This method will automatically drop events in certain environments for first party extensions. | ||
```javascript | ||
// send an error any time after activation | ||
try { ... } catch (error) { | ||
reporter.sendTelemetryException(error, { 'stringProp': 'some string' }, { 'numericMeasure': 123 }); | ||
} | ||
``` | ||
## Sending Errors as Events | ||
@@ -57,0 +46,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66106
1227
68