Skip to content

openExternalUri as a middleware #115167

@TylerLeonhardt

Description

@TylerLeonhardt

Testing #114962

I had a thought that an extension might wanna track when users opt to open an external Uri over.. say.. some UI experience in VS Code. I could see an implementation of this that just sets up a registerExternalUriOpener that acts as a middleware:

        context.subscriptions.push(vscode.window.registerExternalUriOpener(openerId, {
		canOpenExternalUri(uri: vscode.Uri) {
                         // Important logic goes here
			return vscode.ExternalUriOpenerPriority.Preferred;
		},
		async openExternalUri(resolveUri: vscode.Uri) {
                         // log to magic telemetry service
			telemetryService.log(`ended up going here: ${resolveUri.toString()}`);
                         // open Uri as planned
			await vscode.env.openExternal(resolveUri);
		}
	}, {
		schemes: ['https'],
		label: 'Do the thing'
	}));

the only problem with this idea is that you get this dialog twice, which is bad:

image

maybe there can be some mechanism for passing the Uri to the next ExternalUriOpener or maybe just the default implementation (opening in the user's browser.

This could either be done in a separate function (interceptExternalUri bad, but you get the idea) or allow openExternalUri to take in a second paramter called next that is a function that will pass the resolveUri to the next middleware or default implementation.

This is similar to how expressjs does middleware: http://expressjs.com/en/guide/using-middleware.html

I suggest this since the ExternalUriOpener is more-or-less a router.

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalityopenerOpener service issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions