Skip to content

Add configurable timeout or error handling for Matomo script loading #118

@officinaMusci

Description

@officinaMusci

When using mode: 'deferred', if the Matomo server can’t be reached (e.g. network outage or a self‑hosted instance down), the <script> load never resolves and the Angular app appears stuck in “infinite loading”. I couldn’t find any documented option to set a load timeout or handle load errors, so I may be missing something.

Reproduction

  1. Configure provideMatomo({ mode: 'deferred', … }) in an Angular app (v20.1.2) with ngx-matomo-client@8.0.0.
  2. Point trackerUrl to an invalid or downed Matomo endpoint.
  3. Serve the app and see in the console:
    Loading failed for the <script> with source “https://…/matomo.js”.
    
  4. The app’s bootstrap never completes, preventing further rendering.

Expected behaviour

  • Ideally there’d be a documented way to specify a timeout for the injected <script> (for example, 5 seconds).
  • On timeout or load error, the library could:
    1. Stop waiting for the script.
    2. Log a warning or emit an event/observable.
    3. Allow the Angular bootstrap to finish normally.
  • Even better, if script injection and its error handling were fully non‑blocking, so a Matomo load issue wouldn’t hold up app initialization.

Thanks for any guidance or for considering this enhancement!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions