THIS Line of Code Should be in ALL Chrome Extensions
A very simple line of code can provide necessary user feedback for your extension.
Table of Contents 📖
Getting User Feedback
User feedback is necessary to improve any software. Chrome extensions make it easy to receive user feedback by handling uninstalls. In other words, when a user uninstalls a chrome extension, we can send them to a form for feedback. This is done by setting an uninstall URL on the user. This is a URL that the user is sent to when they uninstall the chrome extension. At this URL, we can return a form asking the user about their experience, why they uninstalled the extension, etc.
The Code
The best place to set this URL is in the onInstalled event of the service worker. This event is fired when the extension is first installed, updated to a new version, or when Chrome is updated to a new version.
{
"manifest_version": 3,
"name": "Sample Extension",
"version": "1.0.0",
"description": "Sample extension",
"background": {
"service_worker": "service.js",
"type": "module"
}
}
chrome.runtime.onInstalled.addListener(() => {
chrome.runtime.setUninstallURL('http://localhost:3000/uninstall');
});
Now when a user uninstalls the extension, they will be sent to localhost:3000/uninstall. A common practice is to serve up a form asking why the user uninstalled the extension.