Skip to content

Commit

Permalink
Show survey to users after extension is uninstalled
Browse files Browse the repository at this point in the history
  • Loading branch information
robertknight committed Dec 20, 2024
1 parent 806118e commit 33c88f5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/background/chrome-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export function getChromeAPI(chrome = globalThis.chrome) {
requestUpdateCheck: chrome.runtime.requestUpdateCheck
? chrome.runtime.requestUpdateCheck
: null,

setUninstallURL: chrome.runtime.setUninstallURL,
},

permissions: {
Expand Down
11 changes: 11 additions & 0 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -67,6 +75,9 @@ export async function init() {
);
});

// Show survey to users after they uninstall extension.
chromeAPI.runtime.setUninstallURL(uninstallURL);

await initialized;
}

Expand Down
7 changes: 6 additions & 1 deletion tests/background/index-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { init, $imports } from '../../src/background';
import { init, uninstallURL, $imports } from '../../src/background';

let extension;

Expand Down Expand Up @@ -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' }),
Expand Down Expand Up @@ -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 = {};
Expand Down

0 comments on commit 33c88f5

Please sign in to comment.