Skip to content

Commit 33c88f5

Browse files
committed
Show survey to users after extension is uninstalled
Fixes hypothesis/product-backlog#1599
1 parent 806118e commit 33c88f5

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/background/chrome-api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export function getChromeAPI(chrome = globalThis.chrome) {
5454
requestUpdateCheck: chrome.runtime.requestUpdateCheck
5555
? chrome.runtime.requestUpdateCheck
5656
: null,
57+
58+
setUninstallURL: chrome.runtime.setUninstallURL,
5759
},
5860

5961
permissions: {

src/background/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import { chromeAPI } from './chrome-api';
22
import { Extension } from './extension';
33
import type { ExternalMessage } from './messages';
44

5+
/**
6+
* Link to survey to show users after extension is uninstalled.
7+
*
8+
* See https://github.com/hypothesis/product-backlog/issues/1599.
9+
*/
10+
export const uninstallURL =
11+
'https://docs.google.com/forms/d/e/1FAIpQLSd250Bi4xvxxvL-SgajHRmk8K1LMLZLGRoYkp6WSwT8PDTlLA/viewform?usp=sf_link';
12+
513
/**
614
* Initialize the extension's Service Worker / background page.
715
*
@@ -67,6 +75,9 @@ export async function init() {
6775
);
6876
});
6977

78+
// Show survey to users after they uninstall extension.
79+
chromeAPI.runtime.setUninstallURL(uninstallURL);
80+
7081
await initialized;
7182
}
7283

tests/background/index-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { init, $imports } from '../../src/background';
1+
import { init, uninstallURL, $imports } from '../../src/background';
22

33
let extension;
44

@@ -28,6 +28,7 @@ describe('background/index', () => {
2828
onInstalled: eventListenerStub(),
2929
onMessageExternal: eventListenerStub(),
3030
onUpdateAvailable: eventListenerStub(),
31+
setUninstallURL: sinon.stub().resolves(),
3132
},
3233
management: {
3334
getSelf: sinon.stub().resolves({ installType: 'normal', id: '1234' }),
@@ -73,6 +74,10 @@ describe('background/index', () => {
7374
});
7475
});
7576

77+
it('shows survey to users after extension is uninstalled', () => {
78+
assert.calledWith(fakeChromeAPI.runtime.setUninstallURL, uninstallURL);
79+
});
80+
7681
describe('bouncer (hyp.is) message handling', () => {
7782
it('responds to basic "ping" message', () => {
7883
const sender = {};

0 commit comments

Comments
 (0)