forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathindex.ts
1655 lines (1636 loc) · 60.8 KB
/
index.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// tslint:disable:no-reference no-any import-name no-any function-name
/// <reference path="./vscode-extension-telemetry.d.ts" />
import { JSONObject } from '@phosphor/coreutils';
import { basename as pathBasename, sep as pathSep } from 'path';
import * as stackTrace from 'stack-trace';
import TelemetryReporter from 'vscode-extension-telemetry';
import { DiagnosticCodes } from '../application/diagnostics/constants';
import { IWorkspaceService } from '../common/application/types';
import { AppinsightsKey, EXTENSION_ROOT_DIR, isTestExecution, PVSC_EXTENSION_ID } from '../common/constants';
import { traceError, traceInfo } from '../common/logger';
import { TerminalShellType } from '../common/terminal/types';
import { StopWatch } from '../common/utils/stopWatch';
import { JupyterCommands, NativeKeyboardCommandTelemetry, NativeMouseCommandTelemetry, Telemetry } from '../datascience/constants';
import { DebugConfigurationType } from '../debugger/extension/types';
import { ConsoleType, TriggerType } from '../debugger/types';
import { AutoSelectionRule } from '../interpreter/autoSelection/types';
import { InterpreterType } from '../interpreter/contracts';
import { LinterId } from '../linters/types';
import { TestProvider } from '../testing/common/types';
import { EventName, PlatformErrors } from './constants';
import { LinterTrigger, TestTool } from './types';
/**
* Checks whether telemetry is supported.
* Its possible this function gets called within Debug Adapter, vscode isn't available in there.
* Withiin DA, there's a completely different way to send telemetry.
* @returns {boolean}
*/
function isTelemetrySupported(): boolean {
try {
// tslint:disable-next-line:no-require-imports
const vsc = require('vscode');
// tslint:disable-next-line:no-require-imports
const reporter = require('vscode-extension-telemetry');
return vsc !== undefined && reporter !== undefined;
} catch {
return false;
}
}
/**
* Checks if the telemetry is disabled in user settings
* @returns {boolean}
*/
export function isTelemetryDisabled(workspaceService: IWorkspaceService): boolean {
const settings = workspaceService.getConfiguration('telemetry').inspect<boolean>('enableTelemetry')!;
return settings.globalValue === false ? true : false;
}
let telemetryReporter: TelemetryReporter | undefined;
function getTelemetryReporter() {
if (!isTestExecution() && telemetryReporter) {
return telemetryReporter;
}
const extensionId = PVSC_EXTENSION_ID;
// tslint:disable-next-line:no-require-imports
const extensions = (require('vscode') as typeof import('vscode')).extensions;
// tslint:disable-next-line:no-non-null-assertion
const extension = extensions.getExtension(extensionId)!;
// tslint:disable-next-line:no-unsafe-any
const extensionVersion = extension.packageJSON.version;
// tslint:disable-next-line:no-require-imports
const reporter = require('vscode-extension-telemetry').default as typeof TelemetryReporter;
return (telemetryReporter = new reporter(extensionId, extensionVersion, AppinsightsKey));
}
export function clearTelemetryReporter() {
telemetryReporter = undefined;
}
export function sendTelemetryEvent<P extends IEventNamePropertyMapping, E extends keyof P>(
eventName: E,
durationMs?: Record<string, number> | number,
properties?: P[E],
ex?: Error
) {
if (isTestExecution() || !isTelemetrySupported()) {
return;
}
const reporter = getTelemetryReporter();
const measures = typeof durationMs === 'number' ? { duration: durationMs } : durationMs ? durationMs : undefined;
if (ex && (eventName as any) !== 'ERROR') {
// When sending `ERROR` telemetry event no need to send custom properties.
// Else we have to review all properties every time as part of GDPR.
// Assume we have 10 events all with their own properties.
// As we have errors for each event, those properties are treated as new data items.
// Hence they need to be classified as part of the GDPR process, and thats unnecessary and onerous.
const props: Record<string, string> = {};
props.stackTrace = getStackTrace(ex);
props.originalEventName = (eventName as any) as string;
reporter.sendTelemetryEvent('ERROR', props, measures);
}
const customProperties: Record<string, string> = {};
if (properties) {
// tslint:disable-next-line:prefer-type-cast no-any
const data = properties as any;
Object.getOwnPropertyNames(data).forEach(prop => {
if (data[prop] === undefined || data[prop] === null) {
return;
}
try {
// If there are any errors in serializing one property, ignore that and move on.
// Else nothign will be sent.
// tslint:disable-next-line:prefer-type-cast no-any no-unsafe-any
(customProperties as any)[prop] = typeof data[prop] === 'string' ? data[prop] : data[prop].toString();
} catch (ex) {
traceError(`Failed to serialize ${prop} for ${eventName}`, ex);
}
});
}
reporter.sendTelemetryEvent((eventName as any) as string, customProperties, measures);
if (process.env && process.env.VSC_PYTHON_LOG_TELEMETRY) {
traceInfo(`Telemetry Event : ${eventName} Measures: ${JSON.stringify(measures)} Props: ${JSON.stringify(customProperties)} `);
}
}
// tslint:disable-next-line:no-any function-name
export function captureTelemetry<P extends IEventNamePropertyMapping, E extends keyof P>(eventName: E, properties?: P[E], captureDuration: boolean = true, failureEventName?: E) {
// tslint:disable-next-line:no-function-expression no-any
return function (_target: Object, _propertyKey: string, descriptor: TypedPropertyDescriptor<any>) {
const originalMethod = descriptor.value;
// tslint:disable-next-line:no-function-expression no-any
descriptor.value = function (...args: any[]) {
if (!captureDuration) {
sendTelemetryEvent(eventName, undefined, properties);
// tslint:disable-next-line:no-invalid-this
return originalMethod.apply(this, args);
}
const stopWatch = new StopWatch();
// tslint:disable-next-line:no-invalid-this no-use-before-declare no-unsafe-any
const result = originalMethod.apply(this, args);
// If method being wrapped returns a promise then wait for it.
// tslint:disable-next-line:no-unsafe-any
if (result && typeof result.then === 'function' && typeof result.catch === 'function') {
// tslint:disable-next-line:prefer-type-cast
(result as Promise<void>)
.then(data => {
sendTelemetryEvent(eventName, stopWatch.elapsedTime, properties);
return data;
})
// tslint:disable-next-line:promise-function-async
.catch(ex => {
// tslint:disable-next-line:no-any
properties = properties || ({} as any);
(properties as any).failed = true;
sendTelemetryEvent(failureEventName ? failureEventName : eventName, stopWatch.elapsedTime, properties, ex);
});
} else {
sendTelemetryEvent(eventName, stopWatch.elapsedTime, properties);
}
return result;
};
return descriptor;
};
}
// function sendTelemetryWhenDone<T extends IDSMappings, K extends keyof T>(eventName: K, properties?: T[K]);
export function sendTelemetryWhenDone<P extends IEventNamePropertyMapping, E extends keyof P>(
eventName: E,
promise: Promise<any> | Thenable<any>,
stopWatch?: StopWatch,
properties?: P[E]
) {
stopWatch = stopWatch ? stopWatch : new StopWatch();
if (typeof promise.then === 'function') {
// tslint:disable-next-line:prefer-type-cast no-any
(promise as Promise<any>).then(
data => {
// tslint:disable-next-line:no-non-null-assertion
sendTelemetryEvent(eventName, stopWatch!.elapsedTime, properties);
return data;
// tslint:disable-next-line:promise-function-async
},
ex => {
// tslint:disable-next-line:no-non-null-assertion
sendTelemetryEvent(eventName, stopWatch!.elapsedTime, properties, ex);
return Promise.reject(ex);
}
);
} else {
throw new Error('Method is neither a Promise nor a Theneable');
}
}
function sanitizeFilename(filename: string): string {
if (filename.startsWith(EXTENSION_ROOT_DIR)) {
filename = `<pvsc>${filename.substring(EXTENSION_ROOT_DIR.length)}`;
} else {
// We don't really care about files outside our extension.
filename = `<hidden>${pathSep}${pathBasename(filename)}`;
}
return filename;
}
function sanitizeName(name: string): string {
if (name.indexOf('/') === -1 && name.indexOf('\\') === -1) {
return name;
} else {
return '<hidden>';
}
}
function getStackTrace(ex: Error): string {
// We aren't showing the error message (ex.message) since it might
// contain PII.
let trace = '';
for (const frame of stackTrace.parse(ex)) {
let filename = frame.getFileName();
if (filename) {
filename = sanitizeFilename(filename);
const lineno = frame.getLineNumber();
const colno = frame.getColumnNumber();
trace += `\n\tat ${getCallsite(frame)} ${filename}:${lineno}:${colno}`;
} else {
trace += '\n\tat <anonymous>';
}
}
// Ensure we always use `/` as path seperators.
// This way stack traces (with relative paths) comming from different OS will always look the same.
return trace.trim().replace(/\\/g, '/');
}
function getCallsite(frame: stackTrace.StackFrame) {
const parts: string[] = [];
if (typeof frame.getTypeName() === 'string' && frame.getTypeName().length > 0) {
parts.push(frame.getTypeName());
}
if (typeof frame.getMethodName() === 'string' && frame.getMethodName().length > 0) {
parts.push(frame.getMethodName());
}
if (typeof frame.getFunctionName() === 'string' && frame.getFunctionName().length > 0) {
if (parts.length !== 2 || parts.join('.') !== frame.getFunctionName()) {
parts.push(frame.getFunctionName());
}
}
return parts.map(sanitizeName).join('.');
}
// Map all events to their properties
export interface IEventNamePropertyMapping {
/**
* Telemetry event sent when providing completion items for the given position and document.
*/
[EventName.COMPLETION]: never | undefined;
/**
* Telemetry event sent with details 'python.autoComplete.addBrackets' setting
*/
[EventName.COMPLETION_ADD_BRACKETS]: {
/**
* Carries boolean `true` if 'python.autoComplete.addBrackets' is set to true, `false` otherwise
*/
enabled: boolean;
};
/**
* Telemetry event captured when debug adapter executable is created
*/
[EventName.DEBUG_ADAPTER_USING_WHEELS_PATH]: {
/**
* Carries boolean
* - `true` if path used for the adapter is the debugger with wheels.
* - `false` if path used for the adapter is the source only version of the debugger.
*/
usingWheels: boolean;
};
/**
* Telemetry captured before starting debug session.
*/
[EventName.DEBUG_SESSION_START]: {
/**
* Trigger for starting the debugger.
* - `launch`: Launch/start new code and debug it.
* - `attach`: Attach to an exiting python process (remote debugging).
* - `test`: Debugging python tests.
*
* @type {TriggerType}
*/
trigger: TriggerType;
/**
* Type of console used.
* -`internalConsole`: Use VS Code debug console (no shells/terminals).
* - `integratedTerminal`: Use VS Code terminal.
* - `externalTerminal`: Use an External terminal.
*
* @type {ConsoleType}
*/
console?: ConsoleType;
};
/**
* Telemetry captured when debug session runs into an error.
*/
[EventName.DEBUG_SESSION_ERROR]: {
/**
* Trigger for starting the debugger.
* - `launch`: Launch/start new code and debug it.
* - `attach`: Attach to an exiting python process (remote debugging).
* - `test`: Debugging python tests.
*
* @type {TriggerType}
*/
trigger: TriggerType;
/**
* Type of console used.
* -`internalConsole`: Use VS Code debug console (no shells/terminals).
* - `integratedTerminal`: Use VS Code terminal.
* - `externalTerminal`: Use an External terminal.
*
* @type {ConsoleType}
*/
console?: ConsoleType;
};
/**
* Telemetry captured after stopping debug session.
*/
[EventName.DEBUG_SESSION_STOP]: {
/**
* Trigger for starting the debugger.
* - `launch`: Launch/start new code and debug it.
* - `attach`: Attach to an exiting python process (remote debugging).
* - `test`: Debugging python tests.
*
* @type {TriggerType}
*/
trigger: TriggerType;
/**
* Type of console used.
* -`internalConsole`: Use VS Code debug console (no shells/terminals).
* - `integratedTerminal`: Use VS Code terminal.
* - `externalTerminal`: Use an External terminal.
*
* @type {ConsoleType}
*/
console?: ConsoleType;
};
/**
* Telemetry captured when user code starts running after loading the debugger.
*/
[EventName.DEBUG_SESSION_USER_CODE_RUNNING]: {
/**
* Trigger for starting the debugger.
* - `launch`: Launch/start new code and debug it.
* - `attach`: Attach to an exiting python process (remote debugging).
* - `test`: Debugging python tests.
*
* @type {TriggerType}
*/
trigger: TriggerType;
/**
* Type of console used.
* -`internalConsole`: Use VS Code debug console (no shells/terminals).
* - `integratedTerminal`: Use VS Code terminal.
* - `externalTerminal`: Use an External terminal.
*
* @type {ConsoleType}
*/
console?: ConsoleType;
};
/**
* Telemetry captured when starting the debugger.
*/
[EventName.DEBUGGER]: {
/**
* Trigger for starting the debugger.
* - `launch`: Launch/start new code and debug it.
* - `attach`: Attach to an exiting python process (remote debugging).
* - `test`: Debugging python tests.
*
* @type {TriggerType}
*/
trigger: TriggerType;
/**
* Type of console used.
* -`internalConsole`: Use VS Code debug console (no shells/terminals).
* - `integratedTerminal`: Use VS Code terminal.
* - `externalTerminal`: Use an External terminal.
*
* @type {ConsoleType}
*/
console?: ConsoleType;
/**
* Whether user has defined environment variables.
* Could have been defined in launch.json or the env file (defined in `settings.json`).
* Default `env file` is `.env` in the workspace folder.
*
* @type {boolean}
*/
hasEnvVars: boolean;
/**
* Whether there are any CLI arguments that need to be passed into the program being debugged.
*
* @type {boolean}
*/
hasArgs: boolean;
/**
* Whether the user is debugging `django`.
*
* @type {boolean}
*/
django: boolean;
/**
* Whether the user is debugging `flask`.
*
* @type {boolean}
*/
flask: boolean;
/**
* Whether the user is debugging `jinja` templates.
*
* @type {boolean}
*/
jinja: boolean;
/**
* Whether user is attaching to a local python program (attach scenario).
*
* @type {boolean}
*/
isLocalhost: boolean;
/**
* Whether debugging a module.
*
* @type {boolean}
*/
isModule: boolean;
/**
* Whether debugging with `sudo`.
*
* @type {boolean}
*/
isSudo: boolean;
/**
* Whether required to stop upon entry.
*
* @type {boolean}
*/
stopOnEntry: boolean;
/**
* Whether required to display return types in debugger.
*
* @type {boolean}
*/
showReturnValue: boolean;
/**
* Whether debugging `pyramid`.
*
* @type {boolean}
*/
pyramid: boolean;
/**
* Whether debugging a subprocess.
*
* @type {boolean}
*/
subProcess: boolean;
/**
* Whether debugging `watson`.
*
* @type {boolean}
*/
watson: boolean;
/**
* Whether degbugging `pyspark`.
*
* @type {boolean}
*/
pyspark: boolean;
/**
* Whether using `gevent` when debugging.
*
* @type {boolean}
*/
gevent: boolean;
/**
* Whether debugging `scrapy`.
*
* @type {boolean}
*/
scrapy: boolean;
};
/**
* Telemetry event sent when attaching to child process
*/
[EventName.DEBUGGER_ATTACH_TO_CHILD_PROCESS]: never | undefined;
/**
* Telemetry event sent when attaching to a local process.
*/
[EventName.DEBUGGER_ATTACH_TO_LOCAL_PROCESS]: never | undefined;
/**
* Telemetry sent after building configuration for debugger
*/
[EventName.DEBUGGER_CONFIGURATION_PROMPTS]: {
/**
* The type of debug configuration to build configuration for
*
* @type {DebugConfigurationType}
*/
configurationType: DebugConfigurationType;
/**
* Carries `true` if we are able to auto-detect manage.py path for Django, `false` otherwise
*
* @type {boolean}
*/
autoDetectedDjangoManagePyPath?: boolean;
/**
* Carries `true` if we are able to auto-detect .ini file path for Pyramid, `false` otherwise
*
* @type {boolean}
*/
autoDetectedPyramidIniPath?: boolean;
/**
* Carries `true` if we are able to auto-detect app.py path for Flask, `false` otherwise
*
* @type {boolean}
*/
autoDetectedFlaskAppPyPath?: boolean;
/**
* Carries `true` if user manually entered the required path for the app
* (path to `manage.py` for Django, path to `.ini` for Pyramid, path to `app.py` for Flask), `false` otherwise
*
* @type {boolean}
*/
manuallyEnteredAValue?: boolean;
};
/**
* Telemetry event sent when providing completion provider in launch.json. It is sent just *after* inserting the completion.
*/
[EventName.DEBUGGER_CONFIGURATION_PROMPTS_IN_LAUNCH_JSON]: never | undefined;
/**
* Telemetry is sent when providing definitions for python code, particularly when [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
* and peek definition features are used.
*/
[EventName.DEFINITION]: never | undefined;
/**
* Telemetry event sent with details of actions when invoking a diagnostic command
*/
[EventName.DIAGNOSTICS_ACTION]: {
/**
* Diagnostics command executed.
* @type {string}
*/
commandName?: string;
/**
* Diagnostisc code ignored (message will not be seen again).
* @type {string}
*/
ignoreCode?: string;
/**
* Url of web page launched in browser.
* @type {string}
*/
url?: string;
/**
* Custom actions performed.
* @type {'switchToCommandPrompt'}
*/
action?: 'switchToCommandPrompt';
};
/**
* Telemetry event sent when we are checking if we can handle the diagnostic code
*/
[EventName.DIAGNOSTICS_MESSAGE]: {
/**
* Code of diagnostics message detected and displayed.
* @type {string}
*/
code: DiagnosticCodes;
};
/**
* Telemetry event sent with details just after editor loads
*/
[EventName.EDITOR_LOAD]: {
/**
* The conda version if selected
*/
condaVersion: string | undefined;
/**
* The python interpreter version if selected
*/
pythonVersion: string | undefined;
/**
* The type of interpreter (conda, virtualenv, pipenv etc.)
*/
interpreterType: InterpreterType | undefined;
/**
* The type of terminal shell created: powershell, cmd, zsh, bash etc.
*
* @type {TerminalShellType}
*/
terminal: TerminalShellType;
/**
* Number of workspace folders opened
*/
workspaceFolderCount: number;
/**
* If interpreters found for the main workspace contains a python3 interpreter
*/
hasPython3: boolean;
/**
* If user has defined an interpreter in settings.json
*/
usingUserDefinedInterpreter: boolean;
/**
* If interpreter is auto selected for the workspace
*/
usingAutoSelectedWorkspaceInterpreter: boolean;
/**
* If global interpreter is being used
*/
usingGlobalInterpreter: boolean;
};
/**
* Telemetry event sent when substituting Environment variables to calculate value of variables
*/
[EventName.ENVFILE_VARIABLE_SUBSTITUTION]: never | undefined;
/**
* Telemetry Event sent when user sends code to be executed in the terminal.
*
*/
[EventName.EXECUTION_CODE]: {
/**
* Whether the user executed a file in the terminal or just the selected text.
*
* @type {('file' | 'selection')}
*/
scope: 'file' | 'selection';
/**
* How was the code executed (through the command or by clicking the `Run File` icon).
*
* @type {('command' | 'icon')}
*/
trigger?: 'command' | 'icon';
};
/**
* Telemetry Event sent when user executes code against Django Shell.
* Values sent:
* scope
*
*/
[EventName.EXECUTION_DJANGO]: {
/**
* If `file`, then the file was executed in the django shell.
* If `selection`, then the selected text was sent to the django shell.
*
* @type {('file' | 'selection')}
*/
scope: 'file' | 'selection';
};
/**
* Telemetry event sent with details when formatting a document
*/
[EventName.FORMAT]: {
/**
* Tool being used to format
*/
tool: 'autopep8' | 'black' | 'yapf';
/**
* If arguments for formatter is provided in resource settings
*/
hasCustomArgs: boolean;
/**
* Carries `true` when formatting a selection of text, `false` otherwise
*/
formatSelection: boolean;
};
/**
* Telemetry event sent with the value of setting 'Format on type'
*/
[EventName.FORMAT_ON_TYPE]: {
/**
* Carries `true` if format on type is enabled, `false` otherwise
*
* @type {boolean}
*/
enabled: boolean;
};
/**
* Telemetry event sent when sorting imports using formatter
*/
[EventName.FORMAT_SORT_IMPORTS]: never | undefined;
/**
* Telemetry event sent when Go to Python object command is executed
*/
[EventName.GO_TO_OBJECT_DEFINITION]: never | undefined;
/**
* Telemetry event sent when providing a hover for the given position and document for interactive window using Jedi.
*/
[EventName.HOVER_DEFINITION]: never | undefined;
/**
* Telemetry event sent with details when tracking imports
*/
[EventName.HASHED_PACKAGE_NAME]: {
/**
* Hash of the package name
*
* @type {string}
*/
hashedName: string;
};
[EventName.HASHED_PACKAGE_PERF]: never | undefined;
/**
* Telemetry event sent with details of selection in prompt
* `Prompt message` :- 'Linter ${productName} is not installed'
*/
[EventName.LINTER_NOT_INSTALLED_PROMPT]: {
/**
* Name of the linter
*
* @type {LinterId}
*/
tool?: LinterId;
/**
* `select` When 'Select linter' option is selected
* `disablePrompt` When 'Do not show again' option is selected
* `install` When 'Install' option is selected
*
* @type {('select' | 'disablePrompt' | 'install')}
*/
action: 'select' | 'disablePrompt' | 'install';
};
/**
* Telemetry event sent when installing modules
*/
[EventName.PYTHON_INSTALL_PACKAGE]: {
/**
* The name of the module. (pipenv, Conda etc.)
*
* @type {string}
*/
installer: string;
};
/**
* Telemetry sent with details immediately after linting a document completes
*/
[EventName.LINTING]: {
/**
* Name of the linter being used
*
* @type {LinterId}
*/
tool: LinterId;
/**
* If custom arguments for linter is provided in settings.json
*
* @type {boolean}
*/
hasCustomArgs: boolean;
/**
* Carries the source which triggered configuration of tests
*
* @type {LinterTrigger}
*/
trigger: LinterTrigger;
/**
* Carries `true` if linter executable is specified, `false` otherwise
*
* @type {boolean}
*/
executableSpecified: boolean;
};
/**
* Telemetry event sent after fetching the OS version
*/
[EventName.PLATFORM_INFO]: {
/**
* If fetching OS version fails, list the failure type
*
* @type {PlatformErrors}
*/
failureType?: PlatformErrors;
/**
* The OS version of the platform
*
* @type {string}
*/
osVersion?: string;
};
/**
* Telemetry is sent with details about the play run file icon
*/
[EventName.PLAY_BUTTON_ICON_DISABLED]: {
/**
* Carries `true` if play button icon is not shown (because code runner is installed), `false` otherwise
*/
disabled: boolean;
};
/**
* Telemetry event sent with details after updating the python interpreter
*/
[EventName.PYTHON_INTERPRETER]: {
/**
* Carries the source which triggered the update
*
* @type {('ui' | 'shebang' | 'load')}
*/
trigger: 'ui' | 'shebang' | 'load';
/**
* Carries `true` if updating python interpreter failed
*
* @type {boolean}
*/
failed: boolean;
/**
* The python version of the interpreter
*
* @type {string}
*/
pythonVersion?: string;
/**
* The version of pip module installed in the python interpreter
*
* @type {string}
*/
pipVersion?: string;
};
[EventName.PYTHON_INTERPRETER_ACTIVATION_ENVIRONMENT_VARIABLES]: {
/**
* Carries `true` if environment variables are present, `false` otherwise
*
* @type {boolean}
*/
hasEnvVars?: boolean;
/**
* Carries `true` if fetching environment variables failed, `false` otherwise
*
* @type {boolean}
*/
failed?: boolean;
};
/**
* Telemetry event sent when getting activation commands for active interpreter
*/
[EventName.PYTHON_INTERPRETER_ACTIVATION_FOR_RUNNING_CODE]: {
/**
* Carries `true` if activation commands exists for interpreter, `false` otherwise
*
* @type {boolean}
*/
hasCommands?: boolean;
/**
* Carries `true` if fetching activation commands for interpreter failed, `false` otherwise
*
* @type {boolean}
*/
failed?: boolean;
/**
* The type of terminal shell to activate
*
* @type {TerminalShellType}
*/
terminal: TerminalShellType;
/**
* The Python interpreter version of the active interpreter for the resource
*
* @type {string}
*/
pythonVersion?: string;
/**
* The type of the interpreter used
*
* @type {InterpreterType}
*/
interpreterType: InterpreterType;
};
/**
* Telemetry event sent when getting activation commands for terminal when interpreter is not specified
*/
[EventName.PYTHON_INTERPRETER_ACTIVATION_FOR_TERMINAL]: {
/**
* Carries `true` if activation commands exists for terminal, `false` otherwise
*
* @type {boolean}
*/
hasCommands?: boolean;
/**
* Carries `true` if fetching activation commands for terminal failed, `false` otherwise
*
* @type {boolean}
*/
failed?: boolean;
/**
* The type of terminal shell to activate
*
* @type {TerminalShellType}
*/
terminal: TerminalShellType;
/**
* The Python interpreter version of the interpreter for the resource
*
* @type {string}
*/
pythonVersion?: string;
/**
* The type of the interpreter used
*
* @type {InterpreterType}
*/
interpreterType: InterpreterType;
};
[EventName.PYTHON_INTERPRETER_AUTO_SELECTION]: {
/**
* The rule used to auto-select the interpreter
*
* @type {AutoSelectionRule}
*/
rule?: AutoSelectionRule;
/**
* If cached interpreter no longer exists or is invalid
*
* @type {boolean}
*/
interpreterMissing?: boolean;
/**
* Carries `true` if next rule is identified for autoselecting interpreter
*
* @type {boolean}
*/
identified?: boolean;
/**
* Carries `true` if cached interpreter is updated to use the current interpreter, `false` otherwise
*
* @type {boolean}
*/
updated?: boolean;
};
/**
* Sends information regarding discovered python environments (virtualenv, conda, pipenv etc.)
*/
[EventName.PYTHON_INTERPRETER_DISCOVERY]: {
/**
* Name of the locator
*/
locator: string;
/**
* The number of the interpreters returned by locator
*/
interpreters?: number;
};
/**
* Telemetry event sent with details when user clicks the prompt with the following message
* `Prompt message` :- 'We noticed you're using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we suggest the "terminal.integrated.inheritEnv" setting to be changed to false. Would you like to update this setting?'
*/
[EventName.CONDA_INHERIT_ENV_PROMPT]: {
/**
* `Yes` When 'Yes' option is selected
* `No` When 'No' option is selected
* `More info` When 'More Info' option is selected
*/
selection: 'Yes' | 'No' | 'More Info' | undefined;
};
/**
* Telemetry event sent with details when user clicks a button in the virtual environment prompt.
* `Prompt message` :- 'We noticed a new virtual environment has been created. Do you want to select it for the workspace folder?'
*/
[EventName.PYTHON_INTERPRETER_ACTIVATE_ENVIRONMENT_PROMPT]: {
/**
* `Yes` When 'Yes' option is selected
* `No` When 'No' option is selected
* `Ignore` When 'Do not show again' option is clicked
*
* @type {('Yes' | 'No' | 'Ignore' | undefined)}
*/
selection: 'Yes' | 'No' | 'Ignore' | undefined;
};
/**
* Telemetry event sent with details when user clicks a button in the following prompt
* `Prompt message` :- 'We noticed you are using Visual Studio Code Insiders. Would you like to use the Insiders build of the Python extension?'
*/
[EventName.INSIDERS_PROMPT]: {
/**
* `Yes, weekly` When user selects to use "weekly" as extension channel in insiders prompt
* `Yes, daily` When user selects to use "daily" as extension channel in insiders prompt
* `No, thanks` When user decides to keep using the same extension channel as before
*/
selection: 'Yes, weekly' | 'Yes, daily' | 'No, thanks' | undefined;
};
/**
* Telemetry event sent with details when user clicks a button in the following prompt
* `Prompt message` :- 'It looks like you were previously in the Insiders Program of the Python extension. Would you like to opt into the program again?'
*/
[EventName.OPT_INTO_INSIDERS_AGAIN_PROMPT]: {
/**
* `Yes, weekly` When user selects to use "weekly" as extension channel
* `Yes, daily` When user selects to use "daily" as extension channel
* `No, thanks` When user decides to keep using the same extension channel as before
*/
selection: 'Yes, weekly' | 'Yes, daily' | 'No, thanks' | undefined;
};
/**
* Telemetry event sent with details when user clicks a button in the 'Reload to install insiders prompt'.
* `Prompt message` :- 'Please reload Visual Studio Code to use the insiders build of the extension'
*/
[EventName.INSIDERS_RELOAD_PROMPT]: {
/**