Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the matomo tracker's siteID dynamic #316

Closed
Ovid-iu opened this issue Sep 18, 2019 · 7 comments · Fixed by #320
Closed

Changing the matomo tracker's siteID dynamic #316

Ovid-iu opened this issue Sep 18, 2019 · 7 comments · Fixed by #320

Comments

@Ovid-iu
Copy link

Ovid-iu commented Sep 18, 2019

Hello,

I am trying to implement matomo for a particular scenario, but I am unable to make it work.
I am setting up the matomo tracker with a siteID when the app launches, but after that, I would like to allow the user to change the siteID.
If I make the matomo tracker nil, then redo the setup with the same URL but a different siteID, past this point I do not see the events tracked anymore.
Is this a known issue?

@brototyp
Copy link
Member

Hi @Ovid-iu and thanks for opening this question.

No, that's not a known issue and there is no immediate reason that comes to my head why that could happen. Can you try to reproduce this in an empty / example project?

@Ovid-iu
Copy link
Author

Ovid-iu commented Sep 18, 2019

Hey @brototyp ,
I will try to do so in an empty project and see the results.

As a side note, I wrote that the fact that I do not see the events tracked anymore - I didn't actually check to see if the events were tracked on the site, but the logs were not showing anymore after changing the siteID.

@Ovid-iu
Copy link
Author

Ovid-iu commented Sep 19, 2019

First of all, I am sorry, there is no issue when changing the site id, I simply forgot to setup the logger again for the new instance, and this was the reason why I was not seeing the logs anymore - again I apologise.

Secondly, I have found another issue, when setting up the same instance with a new siteId, the timer from the first setup used to dispatch events from the queue remains, so I keep seeing the following message: MatomoTracker [I] No need to dispatch. Dispatch queue is empty.
If I will setup the instance a third time, there will be 3 separate timers that want to dispatch events from their own queues.

Steps to reproduce:

  1. Setup the matomo with the first site id, and call the track method:
    matomo = MatomoTracker(siteId: “siteID1”, baseURL: “baseURL”)
    matomo.logger = DefaultLogger(minLevel: .verbose)
    matomo.track(view: [“LoginScreen”])

  2. Setup the same matomo instance with another siteID and call the track method:
    matomo = MatomoTracker(siteId: “siteID2”, baseURL: “baseURL”)
    matomo.logger = DefaultLogger(minLevel: .verbose)
    matomo.track(view: [“LoginScreen”])

  3. Setup the matomo instance with the third siteID and call the track method:
    matomo = MatomoTracker(siteId: “siteID3”, baseURL: “baseURL”)
    matomo.logger = DefaultLogger(minLevel: .verbose)
    matomo.track(view: [“LoginScreen”])

By doing so, the logs will show: MatomoTracker [I] No need to dispatch. Dispatch queue is empty multiple times - more than it should. Based on the 30 seconds rule used to dispatch events, I could verify the fact that for each instance, the log was displaying as expected.

I tried making the instance nil, but this was of no effect. Is there a way to clear the previous timer/queue?

@brototyp
Copy link
Member

Hey @Ovid-iu, thanks for getting back on that and reporting the other issue. I have the suspicion, there is a retain cycle and the dispatcher is kept.

I'll have a look at it, but it might take a little. Feel free to investigate yourself 😊

@brototyp
Copy link
Member

Hey @Ovid-iu, I found the issue and implemented a fix. Please have a look at #320.

@Ovid-iu
Copy link
Author

Ovid-iu commented Nov 4, 2019

@brototyp Seems about right, when can this be released into a new version?

@brototyp
Copy link
Member

brototyp commented Nov 6, 2019

This was just released in version 7.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants