-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Description
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:
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.
