-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Description
Does this issue occur when all extensions are disabled?: Yes/No
- VS Code Version: vscode.dev Version: 1.87.2 (Commit: 863d258)
- OS Version: Mac OS 14.4 (23E214)
I am working on Google and we need this data to be logged. Since you are logging this both in non-browser, and for regular text editors, I think this is just an oversight.
Steps to Reproduce:
- Open a remote repository, for example from Github.
- Make a change to any file.
- Turn on "Set Log Level" to "Trace".
- Open "Output" panel and switch to "Telemetry".
- Open the diff view from the source control view for the change you made in step 2.
- Notice how in the Output panel, a telemetry event 'editorOpened' appears, but it does not have "resource" set, unlike similar events for the regular text editor.
I tracked this down to
vscode/src/vs/workbench/browser/parts/editor/editorGroupView.ts
Lines 666 to 682 in d3877fb
| const resource = EditorResourceAccessor.getOriginalUri(editor); | |
| const path = resource ? resource.scheme === Schemas.file ? resource.fsPath : resource.path : undefined; | |
| if (resource && path) { | |
| let resourceExt = extname(resource); | |
| // Remove query parameters from the resource extension | |
| const queryStringLocation = resourceExt.indexOf('?'); | |
| resourceExt = queryStringLocation !== -1 ? resourceExt.substr(0, queryStringLocation) : resourceExt; | |
| descriptor['resource'] = { mimeType: new TelemetryTrustedValue(getMimeTypes(resource).join(', ')), scheme: resource.scheme, ext: resourceExt, path: hash(path) }; | |
| /* __GDPR__FRAGMENT__ | |
| "EditorTelemetryDescriptor" : { | |
| "resource": { "${inline}": [ "${URIDescriptor}" ] } | |
| } | |
| */ | |
| return descriptor; | |
| } | |
And
vscode/src/vs/workbench/common/editor.ts
Lines 1335 to 1353 in d3877fb
| if (options?.supportSideBySide) { | |
| const { primary, secondary } = this.getSideEditors(editor); | |
| if (primary && secondary) { | |
| if (options?.supportSideBySide === SideBySideEditor.BOTH) { | |
| return { | |
| primary: this.getOriginalUri(primary, { filterByScheme: options.filterByScheme }), | |
| secondary: this.getOriginalUri(secondary, { filterByScheme: options.filterByScheme }) | |
| }; | |
| } else if (options?.supportSideBySide === SideBySideEditor.ANY) { | |
| return this.getOriginalUri(primary, { filterByScheme: options.filterByScheme }) ?? this.getOriginalUri(secondary, { filterByScheme: options.filterByScheme }); | |
| } | |
| editor = options.supportSideBySide === SideBySideEditor.PRIMARY ? primary : secondary; | |
| } | |
| } | |
| if (isResourceDiffEditorInput(editor) || isResourceMultiDiffEditorInput(editor) || isResourceSideBySideEditorInput(editor) || isResourceMergeEditorInput(editor)) { | |
| return undefined; | |
| } |
The issue seems to be that getOriginalUri() is called without passing supportSideBySide, and so undefined is returned for the diff editor (and some other editors). I believe the correct solution is to pass supportSideBySide: SideBySideEditor.BOTH, and then handle the primary and secondary resource. I suggest that the primary resource is logged as resource, the same way it would be for regular text editor. The secondary resource can be logged as resourceSecondary.
I will send a PR for this, then we can discuss the details.