nuxt-modules / plausible

🎟️ Plausible Analytics integration for Nuxt
https://plausible.io
MIT License
102 stars 5 forks source link

Loads of Sentry "Failed to fetch" errors #25

Closed toniengelhardt closed 1 month ago

toniengelhardt commented 1 month ago

I'm getting loads of "Failed to fetch" errors in Sentry when calling useTrackEvent (see screenshot).

Is this a known issue? Might it be caused by browser extensions that prevent tracking or smth like that?

Related info from Sentry: https://sentry.io/answers/how-do-i-fix-the-typeerror-failed-to-fetch-error-in-javascript/

Screenshot 2024-06-06 at 17 46 23
toniengelhardt commented 1 month ago

If somebody stumbles upon this, as a workaround we can wrap the useTrackEvent composable like so to avoid the Sentry events:

import type { EventName, EventOptions } from '@barbapapazes/plausible-tracker'

/** Wrap original Plausible useTrackEvent composable to catch errors. */
export function usePlausibleEvent(eventName: EventName, options?: EventOptions) {
  try {
    useTrackEvent(eventName, options)
  }
  catch (error) {
    console.info('Could not send Plausible event', error)
  }
}
toniengelhardt commented 1 month ago

Turns out, the errors seem to be unrelated to this module. It's just that it triggers a lot of them. The workaround above effectively prevents them.

Closing...