Skip to content

Update browser extention installation detection logic on web

Created by: erzhtor

Closes https://github.com/sourcegraph/sourcegraph/issues/30842.

Description

This PR changes the way how we detect if a browser extension is installed or not.

  • Previously we were using extension marker DOM element. However, there were 2 issues with it:
    1. It waited up to 3 seconds and then assumed that there is no extension if it loaded later
    2. For self-hosted instances browser extension might not have access to the web and thus not be able to inject any marker element.
  • New approach:
    1. Uses the extension marker DOM element or browser extension UTM markers to detect and saves flag (timestamp) in local storage (updates every time when detected)
    2. It uses a local storage flag for up to a week and then only assumes there is no browser extension installed
Screenshots image image

Test plan

  1. sg start web-standalone 2 Check that Browser extension CTA is shown
    1. Disable browser extension (Right-click > "Manage extension > disable toggle)
    2. Open any search result page or file page:
      1. for example search result page
      2. for example file page
    3. It should show up on every mod 6th cadence
  2. Check that Browser extension CTA is NOT shown if bext is installed and enabled
    1. Enable browser extension
    2. Open any search result page or file page:
      1. for example search result page
      2. for example file page
    3. Check that bext CTA is not shown anymore
  3. Check that Browser extension CTA is NOT shown if UTM was detected
    1. Disable browser extension (Right-click > "Manage extension > disable toggle)
    2. Remove integrations.browser.lastDetectionTimestamp localStorage item
    3. Open any page with ?utm_source=chrome-extension parameters
    4. Open any search result page or file page:
      1. for example search result page
      2. for example file page
    5. Check that bext CTA is not shown anymore
  4. Check that install browser extension popup is not shown on "View in codehost (Github/Gitlab)" button click
    1. Disable browser extension
    2. Remove has-dismissed-browser-ext-popup and integrations.browser.lastDetectionTimestamp local storage items
    3. Open any file page
    4. Click on "View on Github" button on the top-right corner
    5. It should show popup to install bext
    6. Enable browser extension and try the same, popup should not show anymore

Merge request reports

Loading