poitch / dart-matomo

A Dart Matomo Client
MIT License
20 stars 39 forks source link

Problem with '#' in contentBase #20

Open sohail-bakhtiari opened 3 years ago

sohail-bakhtiari commented 3 years ago

I moved MatomoTracker().initialize() out of main.dart into some other page, where the 'visitorId' where known to be set.

The Android build works fine, but the PWA can not track events. The problem is that 'contentBase' is set to something like "http://localhost:36673/#loading/null" (this is from chrome debug). When the url is built and posted in the 'send' method, that '#' causes the parameters after url be truncated! So there is no e_c, e_a, and e_n in the sent request.

This took me some hours to find out and I solved my problem by adding contentBaseUrl parameter in initialize().

May be better if some kind of url encoding added when the url has been created in the 'send' method, before posting. Or in the initialize() at: contentBase = html.window.location.href;