Floating-Dartists / matomo-tracker

A fully cross-platform wrap of the Matomo tracking client for Flutter, using the Matomo API.
https://pub.dev/packages/matomo_tracker
MIT License
26 stars 28 forks source link

Call to trackDimensions doesn't work as expected #49

Closed adgeg closed 1 year ago

adgeg commented 1 year ago

Hi,

Fist of all, thanks for your great job.

Describe the bug When we call trackDimensions() method, the following calls to trackEvent(), trackScreen() etc… do not set dimensions, and we don't have any dimensions available in Matomo dashboard.

To Reproduce Steps to reproduce the behavior:

  1. Call MatomoTracker.instance.trackDimensions({'dimension1' : 'value1'});
  2. Call MatomoTracker.instance.trackScreen(context, eventName : 'screen1');
  3. With Flutter DevTools > Network, see the content of request to Matomo. Not any dimension query param is present.

Expected behavior After a call to trackDimensions, dimensions should be usable in Matomo dashboard.

Additional context Matomo tracker version : 2.0.0

TesteurManiak commented 1 year ago

Have you tried to track the dimension like this instead ?

MatomoTracker.instance.trackScreen(
  context,
  eventName : 'screen1',
  dimensions: {'dimension1' : 'value1'},
);
adgeg commented 1 year ago

Hello @TesteurManiak , it works the way you propose, and that's what we do now. But the comprehension of the method trackDimensions is misleading if we still need to call dimensions parameter later in following trackScreen/Event…. Furthermore, in the pub.dev page of your library, it is mentioned that it should work "at a visit level" if we call trackDimensions.


If you want to track Visit or Action dimensions you can either use the trackDimensions (if it's a Visit level dimension) or provide data in the optional dimensions param of trackEvent (if it's an Action level dimension):

Maybe I am doing something wrong, but currently it's not working at a visit level at all.

TesteurManiak commented 1 year ago

Yeah you are right, I'll take a deeper look on this method, this feature was implemented by someone who is not a maintainer on the repo.

petcupaula commented 1 year ago

Hmm. And you have defined the dimension as a visit level dimension in Matomo?

I just tested on version 2.0.0 and seems to be sending fine the visit dimension using trackDimension, and for that matter also with trackEvent, in the main.dart of my flutter app.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 5 days.

adgeg commented 1 year ago

Hello @petcupaula, sorry I just see your message now. Dimensions were properly set on our project for a very long time. Before using your library ,we made a fork of dart-matomo to achieve dimensions. And it used to work perfectly fine.

We don't really use trackEvent, but for the trackScreen methods, when I inspect network requests, not any information about previously set dimensions are present.

Now we use the dimensions parameter of the track methods, and it work as expected, even if we add to adjust in some way our calls:

void setDimensions(Map<String, String> dimensions) {
    _dimensions = dimensions.map((key, value) => MapEntry('dimension$key', Uri.encodeComponent(value)));
  }

BTW, our project is open-source, so here is the "wrapping" we have achieved for our goals.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.