UNPKG

3.08 kBTypeScriptView Raw
1/*---------------------------------------------------------
2 * Copyright (C) Microsoft Corporation. All rights reserved.
3 *--------------------------------------------------------*/
4
5export interface TelemetryEventProperties {
6 readonly [key: string]: string;
7}
8
9export interface RawTelemetryEventProperties {
10 readonly [key: string]: any;
11}
12
13export interface TelemetryEventMeasurements {
14 readonly [key: string]: number;
15}
16export default class TelemetryReporter {
17 /**
18 * @param extensionId The id of your extension
19 * @param extensionVersion The version of your extension
20 * @param key The app insights key
21 * @param firstParty Whether or not the telemetry is first party (i.e from Microsoft / GitHub)
22 */
23 constructor(extensionId: string, extensionVersion: string, key: string, firstParty?: boolean);
24
25 /**
26 * Sends a telemetry event with the given properties and measurements
27 * Properties are sanitized on best-effort basis to remove sensitive data prior to sending.
28 * @param eventName The name of the event
29 * @param properties The set of properties to add to the event in the form of a string key value pair
30 * @param measurements The set of measurements to add to the event in the form of a string key number value pair
31 */
32 sendTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
33
34 /**
35 * Sends a raw (unsanitized) telemetry event with the given properties and measurements
36 * @param eventName The name of the event
37 * @param properties The set of properties to add to the event in the form of a string key value pair
38 * @param measurements The set of measurements to add to the event in the form of a string key number value pair
39 */
40 sendRawTelemetryEvent(eventName: string, properties?: RawTelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
41
42 /**
43 * Sends a telemetry error event with the given properties, measurements, and errorProps
44 * @param eventName The name of the event
45 * @param properties The set of properties to add to the event in the form of a string key value pair
46 * @param measurements The set of measurements to add to the event in the form of a string key number value pair
47 * @param errorProps A list of case sensitive properties to drop, if excluded we drop all properties but still send the event
48 */
49 sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, errorProps?: string[]): void;
50
51 /**
52 * Sends an exception which includes the error stack, properties, and measurements
53 * @param error The error to send
54 * @param properties The set of properties to add to the event in the form of a string key value pair
55 * @param measurements The set of measurements to add to the event in the form of a string key number value pair
56 */
57 sendTelemetryException(error: Error, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
58 dispose(): Promise<any>;
59}