Skip to content

Do not show IDE CTAs to users who have these products installed

Administrator requested to merge ps/detect-ide-extensions into main

Created by: philipp-spiess

Fixes https://github.com/sourcegraph/sourcegraph/issues/30843

We do not want to show IDE CTAs for users that we know are already users of our IDE extensions.

In discussions prior to creating this PR we ruled out the option of using VSCE specific logs, most importantly because we noticed that only ~25% of our VSCE users properly have their Sourcegraph account linked (and it's unclear if this is even possible for JetBrains?).

Instead, this PR takes a different approach. We're using the fact that all links coming from an IDE extension and opening in the browser have their UTM tags added. With this we can "tag" the currently logged in user's extension usage (or use localStorage if no one is logged in).

To avoid stale data, we require a link to be opened in the last 30 days in order to count the user as an active extension user.

Test plan

We (@vdavid and I) manually tested this by changing the conditions of the CTA banners to always render and then using the following three example links and verify they correctly store the extension usage in a user's temporary settings:

  • https://sourcegraph.test:3443/-/editor?remote_url=git%40github.com%3Asourcegraph%2Fsourcegraph-jetbrains.git&branch=main&file=src%2Fmain%2Fjava%2FOpenRevisionAction.java&editor=JetBrains&version=v1.2.2&start_row=68&start_col=26&end_row=68&end_col=26&utm_product_name=IntelliJ+IDEA&utm_product_version=2021.3.2
  • https://sourcegraph.test:3443/-/[email protected]:sourcegraph/sourcegraph.git&branch=ps/detect-ide-extensions&file=client/web/src/tracking/util.ts&editor=VSCode&version=2.0.9&start_row=13&start_col=22&end_row=13&end_col=22&utm_campaign=vscode-extension&utm_medium=direct_traffic&utm_source=vscode-extension&utm_content=vsce-commands
  • https://sourcegraph.test:3443/sign-up?editor=vscode&utm_medium=VSCIDE&utm_source=sidebar&utm_campaign=vsce-sign-up&utm_content=sign-up

Additionally, we've added a test for the component:

α sourcegraph (ps/detect-ide-extensions)✗ yarn jest IdeExtensionTracker
yarn run v1.22.17
$ /Users/philipp/dev/sourcegraph/node_modules/.bin/jest IdeExtensionTracker
 PASS   web  client/web/src/IdeExtensionTracker.test.tsx
  IdeExtensionTracker
    ✓ Detects the proper extension for "https://sourcegraph.com/-/editor?remote_url=git%40github.com%3Asourcegraph%2Fsourcegraph-jetbrains.git&branch=main&file=src%2Fmain%2Fjava%2FOpenRevisionAction.java&editor=JetBrains&version=v1.2.2&start_row=68&start_col=26&end_row=68&end_col=26&utm_product_name=IntelliJ+IDEA&utm_product_version=2021.3.2" (13 ms)
    ✓ Detects the proper extension for "https://sourcegraph.com/-/[email protected]:sourcegraph/sourcegraph.git&branch=ps/detect-ide-extensions&file=client/web/src/tracking/util.ts&editor=VSCode&version=2.0.9&start_row=13&start_col=22&end_row=13&end_col=22&utm_campaign=vscode-extension&utm_medium=direct_traffic&utm_source=vscode-extension&utm_content=vsce-commands" (2 ms)
    ✓ Detects the proper extension for "https://sourcegraph.com/sign-up?editor=vscode&utm_medium=VSCIDE&utm_source=sidebar&utm_campaign=vsce-sign-up&utm_content=sign-up" (2 ms)
    ✓ Detects the proper extension for "https://sourcegraph.com/?something=different" (2 ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        1.009 s
Ran all test suites matching /IdeExtensionTracker/i.
✨  Done in 2.00s.

Merge request reports

Loading