Skip to content

In Browser, 'editorOpened' telemetry event does not contain any 'resource' descriptor for the diff view #208187

@rehmsen

Description

@rehmsen

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:

  1. Open a remote repository, for example from Github.
  2. Make a change to any file.
  3. Turn on "Set Log Level" to "Trace".
  4. Open "Output" panel and switch to "Telemetry".
  5. Open the diff view from the source control view for the change you made in step 2.
  6. 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

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

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.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code InsiderstelemetryTelemetry system issuesverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions