In WebExtension API, what is proper way to detect an application install?

The runtime.OnInstalled event is not supported in Firefox.
I’m not sure if it will be in the future, but for now, what is the preferred method to achieve this?

The easiest was is probably to put a key isInstalled in the browser.storage.local.
If it is not present at startup, then you run your install script and save the key in the storage.

I have implemented a framework that does that, and also runs scripts on browser and extension updates. Unfortunately the documentation is outdated, most importantly the folder structure is now split into thee folders, extension, synced and (which is ‘firefox’ for Firefox):

If you are interested I can update the documentation.

The problem with this approach (which I have tried) is that if the same user clears their cached data (cookies, storage, etc) which is a pretty common behavior that key will be lost and the next time the extension initializes it will report a “new install” which is clearly not.

Well, I am using this approach in one of my extensions, and as it happens I have Firefox configured to clear all stored information on restart.
But since browser.storage is not affected by this, I only saw my installation notification once, and not at every startup.
As far as I know, only uninstalling the extension or deleting the .json file that holds the storage will clear browser.storage.