-
Notifications
You must be signed in to change notification settings - Fork 44
/
telemetryReporter.d.ts
116 lines (100 loc) · 6.1 KB
/
telemetryReporter.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*---------------------------------------------------------
* 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;
}
/**
* A replacement option for the app insights client. This allows the appender to filter out any sensitive or unnecessary information from the telemetry server.
*/
export interface ReplacementOption {
/**
* A regular expression matching any property to be removed or replaced from the telemetry server.
*/
lookup: RegExp;
/**
* The replacement value for the property. If not present or undefined, the property will be removed.
*/
replacementString?: string;
}
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)
* @param replacementOptions A list of replacement options for the app insights client. This allows the appender to filter out any sensitive or unnecessary information from the telemetry server.
*/
constructor(extensionId: string, extensionVersion: string, key: string, firstParty?: boolean, replacementOptions?: ReplacementOption[]);
/**
* A string representation of the current level of telemetry being collected
*/
telemetryLevel: 'all' | 'error' | 'crash' | 'off';
/**
* 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;
/**
* **DANGEROUS** Given an event name, some properties, and measurements sends a telemetry event without checking telemetry setting
* Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development
* @param eventName The name of the event
* @param properties The properties to send with the event
* @param measurements The measurements (numeric values) to send with the event
* @param sanitize Whether or not to sanitize to the properties and measures, defaults to true
*/
sendDangerousTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, sanitize?: boolean): void;
/**
* Sends a telemetry error event with the given properties, measurements.
* **Note**: The errorProps parameter has been removed since v0.6, if you would like to remove a property please use the replacementOptions parameter in the constructor.
* @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
*/
sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;
/**
* **DANGEROUS** Given an event name, some properties, and measurements sends a telemetry error event without checking telemetry setting
* Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development
* @param eventName The name of the event
* @param properties The properties to send with the event
* @param measurements The measurements (numeric values) to send with the event
* @param sanitize Whether or not to run the properties and measures through sanitiziation, defaults to true
*/
sendDangerousTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, sanitize?: boolean): 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;
/**
* **DANGEROUS** Given an error, properties, and measurements. Sends an exception event without checking the telemetry setting
* Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development
* @param eventName The name of the event
* @param properties The properties to send with the event
* @param measurements The measurements (numeric values) to send with the event
* @param sanitize Whether or not to sanitize to the properties and measures, defaults to true
*/
sendDangerousTelemetryException(error: Error, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, sanitize?: boolean): void
/**
* Disposes of the telemetry reporter. This flushes the remaining events and disposes of the telemetry client.
*/
dispose(): Promise<any>;
}