vscode-extension-telemetry
Version:
A module for first party microsoft extensions to report consistent telemetry.
60 lines (52 loc) • 3.08 kB
TypeScript
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
export interface TelemetryEventProperties {
readonly [key: string]: string;
}
export interface RawTelemetryEventProperties {
readonly [key: string]: any;
}
export interface TelemetryEventMeasurements {
readonly [key: string]: number;
}
export default class TelemetryReporter {
/**
* @param extensionId The id of your extension
* @param extensionVersion The version of your extension
* @param key The app insights key
* @param firstParty Whether or not the telemetry is first party (i.e from Microsoft / GitHub)
*/
constructor(extensionId: string, extensionVersion: string, key: string, firstParty?: boolean);
/**
* Sends a telemetry event with the given properties and measurements
* Properties are sanitized on best-effort basis to remove sensitive data prior to sending.
* @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
*/
sendTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
/**
* Sends a raw (unsanitized) telemetry event with the given properties and measurements
* @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: string, properties?: RawTelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
/**
* Sends a telemetry error event with the given properties, measurements, and errorProps
* @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
* @param errorProps A list of case sensitive properties to drop, if excluded we drop all properties but still send the event
*/
sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, errorProps?: string[]): void;
/**
* Sends an exception which includes the error stack, properties, and measurements
* @param error The error to send
* @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
*/
sendTelemetryException(error: Error, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
dispose(): Promise<any>;
}