I am developing an extension for local. I am using these hooks found in extension development documentation. Unfortunately it does not work.
Doc link: Actions | Local Add-on API
This is definitely an area where the Addon documentation could be improved – namely, we would do a better job of indicating what context the hooks are run as (main thread vs renderer thread).
In this case, I the siteStarted and siteStopped actions are run within the main thread context, so the above code won’t work.
I think what you’ll need to do a couple of things:
Move the hook registration to the main.ts file
Change alert() to something else, like console.log(). The reason for this change is that this isn’t a browser context, so alert() won’t work, but other, more node-y things should be just fine
Here’s a screenshot with an example implementation within main.ts, along with the resulting lines in the Local log: