Closed toniengelhardt closed 4 months ago
We're not using the Plausible tracker package anymore, since it has been abandoned for years. Instead, we use a fork by @Barbapapazes. Maybe he can tell use more why wrapping the composable won't catch a failing fetch
promise? 👀
Hello 👋,
It's related to this function https://github.com/Barbapapazes/plausible-tracker/blob/main/src/event.ts#L72
Do you think I should add a .catch
and let the dev passing a callback to handle it?
And @toniengelhardt, I think the try...catch
does not work because I do not await
the event
Do you know if every request fails or if it is only some of them (like someone using a blocker) or does Plausible change something to their API?
@johannschopplich @Barbapapazes thanks for investigating 🙏🏽
Only very few events fail – not sure if bc of a blocker or bc the Plausible API drops them for some reason – but with a couple thousand events this still leads to quite some noise in Sentry (and unfortunately fetch errors are hard to decipher there).
For me, awaiting the event would make a lot of sense, so that wrapping the composable like in the example would work. But it might be also useful to be able to pass an error handler, ideally globally in the config and directly in the useTrackEvent
composable in case it is only needed occasionally.
A failSilently
flag would also work, but is probably the most limiting solution.
Any of the above would work for my use case as long as I can somehow prevent errors from being thrown.
I will need to tackle this in my fork because there trackEvent
does not return a promise.
@toniengelhardt I think you can use the patch (do no hesitate to ping me if it's not working for you) in the issue above because I'll need to add tests to ensure the quality and the future of this fork (and it could takes some times)
Thanks @Barbapapazes 🙏🏽
You can follow the progression with this PR: https://github.com/Barbapapazes/plausible-tracker/pull/13
Test have been merged, I can now fix this issue.
This should be resolved with the latest version v1.0.1, which uses the latest version of @Barbapapazes's tracker library. Thanks for the updates!
I'm getting a lot of
TypeError: Failed to fetch
in Sentry from failing Plausible fetch requests:I tried wrapping the
useTrackEvent
composable into a try/catch like so:But the events still get logged and spam Sentry.
Not sure why exactly the requests to the Plausible API fail, but is there a way to properly catch/handle/ignore them?
Might be an upstream issue in plausible-tracker?