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:
- It waited up to 3 seconds and then assumed that there is no extension if it loaded later
- 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:
- 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)
- It uses a local storage flag for up to a week and then only assumes there is no browser extension installed
Test plan
-
sg start web-standalone
2 Check that Browser extension CTA is shown- Disable browser extension (Right-click > "Manage extension > disable toggle)
- Open any search result page or file page:
- for example search result page
- for example file page
- It should show up on every mod 6th cadence
- Check that Browser extension CTA is NOT shown if bext is installed and enabled
- Enable browser extension
- Open any search result page or file page:
- for example search result page
- for example file page
- Check that bext CTA is not shown anymore
- Check that Browser extension CTA is NOT shown if UTM was detected
- Disable browser extension (Right-click > "Manage extension > disable toggle)
- Remove
integrations.browser.lastDetectionTimestamp
localStorage item - Open any page with
?utm_source=chrome-extension
parameters - Open any search result page or file page:
- for example search result page
- for example file page
- Check that bext CTA is not shown anymore
- Check that install browser extension popup is not shown on "View in codehost (Github/Gitlab)" button click
- Disable browser extension
- Remove
has-dismissed-browser-ext-popup
andintegrations.browser.lastDetectionTimestamp
local storage items - Open any file page
- Click on "View on Github" button on the top-right corner
- It should show popup to install bext
- Enable browser extension and try the same, popup should not show anymore