TLDR; if I want to modify the stimulus Application in an asset based rails project so it applies to ALL controllers, where do I do that?
I am working on a basic app that a) uses hotwire, b) does not touch Webpack.
This has been challenging and I’ve had to make compromises (like moving Tailwind compilation to its own project) but I’m really struggling with Sentry. After many hours I found this PR that explained a lot of what I was seeing, because Stimulus is overriding the default Sentry window.onerror.
Now I’m trying to figure out what to do about that. I found this bit about a global error handler (and other similar examples), but these all appear to be using the webpack method of stimulus - loading up via the index.js.
I also found this, which seemed like the correct choice for overriding the default handler to hook up to Sentry. But again, this is using the index.js / webpack method of loading stimulus.
(The index.js thing threw me for a while. I’m not sure why the stimulus:install puts that in there if its an asset pipeline project, since it doesn’t appear to be used. (unless I broke it somehow).)
Note: I do NOT want to have to manually trap errors in my controllers in the global application controller method. To me, this kills the whole point of having Sentry and having it capture errors you completely missed or ones that happen due to unforeseen library conflicts. If I have to use a try / catch and call Sentry manually, I’ve already lost.