Skip to content

Conversation

nirinchev
Copy link
Contributor

@nirinchev nirinchev commented Mar 20, 2025

Description

Adds a URI handler that can be invoked with a command and optional query arguments, which will then execute said command. The following commands have been updated to accept arguments:

  • connectWithURI
    • connectionString: connection string to connect with. If not supplied, a prompt will be shown
    • reuseExisting: true/false whether to always create a new connection or connect to an existing one with matching connection string.
    • name: optional name to assign to the connection
  • removeConnection - only one of id/name/connectionString must be provided
    • connectionString: connection string to remove
    • name: name of connection to remove
    • id: id of connection to remove
    • force: true/false whether to prompt the user before removing

The URI handler will:

  • Parse the supplied URI into the following components:
    • path will be mapped to command. The mdb. prefix will be automatically added if not present, so both /connectWithURI and /mdb.connectWithURI resolve to the same command.
    • query will be mapped to a params object which will be supplied as the only argument to executeCommand. Numbers and booleans will be parsed to their corresponding data type, everything else will be mapped to a string.
  • Throw an error if the command is not exposed by the extension - that is, arbitrary commands cannot be executed that way.
  • Report telemetry for each deeplink URI it processes, regardless of whether it's a success or not.
    • Event type is Deep Link Handled
    • Properties are { command: string, source?: string }
    • source is populated by the utm_source query argument, which is removed from the params passed to the command after it has been processed.

Checklist

  • New tests and/or benchmarks are included

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@nirinchev nirinchev requested a review from gagik March 20, 2025 12:51
* main:
  chore(telemetry): append user anonymousId & connectionId to appName passed to server COMPASS-8591 (#982)
  chore(deps): bump @mongodb-js/connection-info from 0.11.5 to 0.11.6 (#992)
  chore(deps): bump @mongodb-js/mongodb-constants from 0.10.4 to 0.11.0 (#991)
  chore(deps): bump mongodb from 6.14.2 to 6.15.0 in the driver group (#990)
  chore(deps): bump mongodb-schema from 12.5.0 to 12.5.2 (#988)
Copy link
Contributor

@gagik gagik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, minor note about the URL format.

@nirinchev nirinchev requested review from gagik and cveticm March 24, 2025 14:22
Copy link

@cveticm cveticm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the quick work and all the additions! 🚀

@nirinchev nirinchev changed the title feat: handle deep links to commands VSCODE-683 feat: handle deep links to commands VSCODE-683 VSCODE-684 VSCODE-685 Mar 25, 2025
Copy link

@cveticm cveticm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀 Thanks for adding telem and warning messaging!

@nirinchev nirinchev merged commit b02de34 into main Mar 26, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants