1
>
/*---------------------------------------------------------------------------------------------
errorTelemetry.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { binarySearch } from '../../../base/common/arrays.js';
7
>
import { errorHandler, ErrorNoTelemetry, PendingMigrationError } from '../../../base/common/errors.js';
8
>
import { ListenerLeakError } from '../../../base/common/event.js';
9
>
import { DisposableStore, toDisposable } from '../../../base/common/lifecycle.js';
10
>
import { safeStringify } from '../../../base/common/objects.js';
11
>
import { FileOperationError } from '../../files/common/files.js';
12
>
import { ITelemetryService } from './telemetry.js';
13
>
14
>
export type ErrorEventFragment = {
15
>
owner: 'lramos15, sbatten';
16
>
comment: 'Whenever an error in VS Code is thrown.';
17
>
callstack: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The callstack of the error.' };
18
>
msg?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The message of the error. Normally the first line int the callstack.' };
19
>
file?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The file the error originated from.' };
20
>
line?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The line the error originate on.' };
21
>
column?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The column of the line which the error orginated on.' };
22
>
uncaught_error_name?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'If the error is uncaught what is the error type' };
23
>
uncaught_error_msg?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'If the error is uncaught this is just msg but for uncaught errors.' };
24
>
count?: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'How many times this error has been thrown' };
25
>
};
26
>
27
>
type ListenerLeakDiagEvent = {
28
>
kind?: string;
29
>
listenerCount?: number;
30
>
};
31
>
32
>
type ListenerLeakDiagFragment = {
33
>
kind?: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Whether the leak is dominated by a single subscriber or popular among many.' };
34
>
listenerCount?: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Number of listeners on the emitter when the leak was detected.' };
35
>
};
36
>
37
>
type UnhandledErrorEvent = ErrorEvent & ListenerLeakDiagEvent;
38
>
type UnhandledErrorClassification = ErrorEventFragment & ListenerLeakDiagFragment;
39
>
40
>
export interface ErrorEvent {
41
>
callstack: string;
42
>
msg?: string;
43
>
file?: string;
44
>
line?: number;
45
>
column?: number;
46
>
uncaught_error_name?: string;
47
>
uncaught_error_msg?: string;
48
>
count?: number;
49
>
}
50
>
51
>
export namespace ErrorEvent {
52
>
export function compare(a: ErrorEvent, b: ErrorEvent) {
53
if (a.callstack < b.callstack) {
54
return -1;