SocialGouv / matomo-next

Matomo for Next.js applications
Apache License 2.0
155 stars 22 forks source link

Adding a callback to know when the script can't load #124

Closed totakoko closed 6 months ago

totakoko commented 7 months ago

Hey :wave:

I would like to know when the Matomo script cannot be loaded and may be ad-blocked. My use case is that I do AB tests using the Matomo plugin and I need to detect when to use a fallback if the script does not load. Of course I don't want to run a setTimeout manually and would like to rely on events instead. :grin: I already use the matomoAbTestingAsyncInit callback to know when I can use Matomo but I have nothing yet to be notified when It was blocked.

I did a POC by adding an onerror listener on the scriptElement to be inserted. It seems to be working as I expect. May I open a PR?

revolunet commented 7 months ago

Yes thanks please share this new feature !

github-actions[bot] commented 6 months ago

:tada: This issue has been resolved in version 1.9.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: