Skip to content

Commit

Permalink
feat: display feedback form on extension uninstall (#799)
Browse files Browse the repository at this point in the history
closes #468
  • Loading branch information
lidel committed Oct 25, 2019
1 parent 60a68b5 commit f8449f7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion add-on/src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

const browser = require('webextension-polyfill')
const { onInstalled } = require('../lib/on-installed')
const { getUninstallURL } = require('../lib/on-uninstalled')
const { optionDefaults } = require('../lib/options')

// register onInstalled hook early, otherwise we miss first install event
// register lifecycle hooks early, otherwise we miss first install event
browser.runtime.onInstalled.addListener(onInstalled)
browser.runtime.setUninstallURL(getUninstallURL(browser))

// init add-on after all libs are loaded
document.addEventListener('DOMContentLoaded', async () => {
Expand Down
4 changes: 4 additions & 0 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ module.exports = async function init () {
return state
},

get runtime () {
return runtime
},

get dnslinkResolver () {
return dnslinkResolver
},
Expand Down
14 changes: 14 additions & 0 deletions add-on/src/lib/on-uninstalled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'
/* eslint-env browser */

const stableChannels = new Set([
'ipfs-firefox-addon@lidel.org', // firefox (for legacy reasons)
'nibjojkomfdiaoajekhjakgkdhaomnch' // chromium (chrome web store)
])

const stableChannelFormUrl = 'https://docs.google.com/forms/d/e/1FAIpQLSfLF7uzaxRKiF4XpPL9_DvkdaQHoRnDihRTZ1uVL6ceQwIrtg/viewform'

exports.getUninstallURL = (browser) => {
// on uninstall feedback form shown only on stable channel
return stableChannels.has(browser.runtime.id) ? stableChannelFormUrl : ''
}

0 comments on commit f8449f7

Please sign in to comment.