File tree Expand file tree Collapse file tree 3 files changed +13
-29
lines changed Expand file tree Collapse file tree 3 files changed +13
-29
lines changed Original file line number Diff line number Diff line change @@ -17,9 +17,6 @@ import { EXTENSION_ROOT_DIR } from '../constants';
17
17
*/
18
18
@injectable ( )
19
19
export class Extensions implements IExtensions {
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- private _cachedExtensions ?: readonly Extension < any > [ ] ;
22
-
23
20
constructor ( @inject ( IFileSystem ) private readonly fs : IFileSystem ) { }
24
21
25
22
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -35,16 +32,6 @@ export class Extensions implements IExtensions {
35
32
return extensions . getExtension ( extensionId ) ;
36
33
}
37
34
38
- private get cachedExtensions ( ) {
39
- if ( ! this . _cachedExtensions ) {
40
- this . _cachedExtensions = this . _cachedExtensions || extensions . all ;
41
- extensions . onDidChange ( ( ) => {
42
- this . _cachedExtensions = this . _cachedExtensions || extensions . all ;
43
- } ) ;
44
- }
45
- return this . _cachedExtensions ;
46
- }
47
-
48
35
/**
49
36
* Code borrowed from:
50
37
* https://github.com/microsoft/vscode-jupyter/blob/67fe33d072f11d6443cf232a06bed0ac5e24682c/src/platform/common/application/extensions.node.ts
@@ -64,8 +51,7 @@ export class Extensions implements IExtensions {
64
51
} )
65
52
. filter ( ( item ) => item && ! item . toLowerCase ( ) . startsWith ( pythonExtRoot ) )
66
53
. filter ( ( item ) =>
67
- // Use cached list of extensions as we need this to be fast.
68
- this . cachedExtensions . some (
54
+ this . all . some (
69
55
( ext ) => item ! . includes ( ext . extensionUri . path ) || item ! . includes ( ext . extensionUri . fsPath ) ,
70
56
) ,
71
57
) as string [ ] ;
Original file line number Diff line number Diff line change @@ -125,20 +125,16 @@ export function buildProposedApi(
125
125
const extensions = serviceContainer . get < IExtensions > ( IExtensions ) ;
126
126
const envVarsProvider = serviceContainer . get < IEnvironmentVariablesProvider > ( IEnvironmentVariablesProvider ) ;
127
127
function sendApiTelemetry ( apiName : string , args ?: unknown ) {
128
- setTimeout ( ( ) =>
129
- extensions
130
- . determineExtensionFromCallStack ( )
131
- . then ( ( info ) => {
132
- sendTelemetryEvent ( EventName . PYTHON_ENVIRONMENTS_API , undefined , {
133
- apiName,
134
- extensionId : info . extensionId ,
135
- } ) ;
136
- traceVerbose (
137
- `Extension ${ info . extensionId } accessed ${ apiName } with args: ${ JSON . stringify ( args ) } ` ,
138
- ) ;
139
- } )
140
- . ignoreErrors ( ) ,
141
- ) ;
128
+ extensions
129
+ . determineExtensionFromCallStack ( )
130
+ . then ( ( info ) => {
131
+ sendTelemetryEvent ( EventName . PYTHON_ENVIRONMENTS_API , undefined , {
132
+ apiName,
133
+ extensionId : info . extensionId ,
134
+ } ) ;
135
+ traceVerbose ( `Extension ${ info . extensionId } accessed ${ apiName } with args: ${ JSON . stringify ( args ) } ` ) ;
136
+ } )
137
+ . ignoreErrors ( ) ;
142
138
}
143
139
disposables . push (
144
140
discoveryApi . onChanged ( ( e ) => {
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ suite('Proposed Extension API', () => {
99
99
} ) ;
100
100
101
101
teardown ( ( ) => {
102
+ // Verify each API method sends telemetry regarding who called the API.
103
+ extensions . verifyAll ( ) ;
102
104
sinon . restore ( ) ;
103
105
} ) ;
104
106
You can’t perform that action at this time.
0 commit comments