diff --git a/src/background/chrome-api.ts b/src/background/chrome-api.ts index 02b3b2b3..5848b75b 100644 --- a/src/background/chrome-api.ts +++ b/src/background/chrome-api.ts @@ -54,6 +54,8 @@ export function getChromeAPI(chrome = globalThis.chrome) { requestUpdateCheck: chrome.runtime.requestUpdateCheck ? chrome.runtime.requestUpdateCheck : null, + + setUninstallURL: chrome.runtime.setUninstallURL, }, permissions: { diff --git a/src/background/index.ts b/src/background/index.ts index a5d1465b..38d3e9b8 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -2,6 +2,14 @@ import { chromeAPI } from './chrome-api'; import { Extension } from './extension'; import type { ExternalMessage } from './messages'; +/** + * Link to survey to show users after extension is uninstalled. + * + * See https://github.com/hypothesis/product-backlog/issues/1599. + */ +export const uninstallURL = + 'https://docs.google.com/forms/d/e/1FAIpQLSd250Bi4xvxxvL-SgajHRmk8K1LMLZLGRoYkp6WSwT8PDTlLA/viewform?usp=sf_link'; + /** * Initialize the extension's Service Worker / background page. * @@ -67,6 +75,9 @@ export async function init() { ); }); + // Show survey to users after they uninstall extension. + chromeAPI.runtime.setUninstallURL(uninstallURL); + await initialized; } diff --git a/tests/background/index-test.js b/tests/background/index-test.js index 408e7441..e2b40454 100644 --- a/tests/background/index-test.js +++ b/tests/background/index-test.js @@ -1,4 +1,4 @@ -import { init, $imports } from '../../src/background'; +import { init, uninstallURL, $imports } from '../../src/background'; let extension; @@ -28,6 +28,7 @@ describe('background/index', () => { onInstalled: eventListenerStub(), onMessageExternal: eventListenerStub(), onUpdateAvailable: eventListenerStub(), + setUninstallURL: sinon.stub().resolves(), }, management: { getSelf: sinon.stub().resolves({ installType: 'normal', id: '1234' }), @@ -73,6 +74,10 @@ describe('background/index', () => { }); }); + it('shows survey to users after extension is uninstalled', () => { + assert.calledWith(fakeChromeAPI.runtime.setUninstallURL, uninstallURL); + }); + describe('bouncer (hyp.is) message handling', () => { it('responds to basic "ping" message', () => { const sender = {};