I am trying to detect whether my extension was uninstalled.
I can't use
chrome.management.onUninstalled because it will be fired on other extension.
Google Chrome, unlike Firefox, doesn’t allow to detect when the user uninstalls the extension, which is quite useful to understand user behaviour. There is a feature request on crbug.com with a discussion of this feature but it has not been implemented yet.
As of Chrome 41, you can now open a URL when the extension is uninstalled. That could contain an exit survey or track the uninstall event as some sort of analytics.
You can call
chrome.runtime.setUninstallURL("www.example.com/survey") and redirect user to a url. Unfortunately, as soon as the extension is removed, the background script is removed too, and you can't do anything like log event or send hit to google analytics.
What I did is to set the redirect url to my server endpoint, and do some tasks like logging event to my own db, or sending hit to google analytics (ga hit builder). Then call
res.status(301).redirect("www.example.com/survey") to some survey url. Finally I can send the uninstall event to google analysis.
©2020 All rights reserved.