matomo-org / matomo-sdk-ios

Matomo iOS, tvOS and macOS SDK: a Matomo tracker written in Swift
MIT License
388 stars 164 forks source link

Page view time often recorded as 0 seconds when batched #299

Closed notjosh closed 5 years ago

notjosh commented 5 years ago

My "page visit time" generally looks like:

  1. page 1: 0sec
  2. page 2: 0sec
  3. page 3: 0sec
  4. page 4: 30sec

(where dispatchInterval is the default 30)

I've confirmed locally it's sending the timestamps as we'd expect on each page view, but from what I can tell, the server uses its own time when the events are received to set the page visit time. When the events are batched, they all seem to get the same timestamp.

I saw #177, but I don't think that's the issue here. i.e. setting dispatchInterval to 1 gets me closer to what I want. Obviously that's got some battery implications though :(

Is there any way to get the server to respect client timestamps from the clients? Any help/advice/thoughts?

Matomo server version: 3.9.1 matomo-sdk-ios version: 6.0.1

brototyp commented 5 years ago

Hi @notjosh, thanks for the splendid bug report. I just checked on the "official demo server" to make sure this isn't a server installation or configuration issue and could see the same issue.

@mattab Do you know if this is a known issue? The iOS SDK currently passes the local time to the server using the h, m and s parameter. Should we use the cdt parameter as well?

notjosh commented 5 years ago

Has there been any update to this behind the scenes? It might start being an issue for us soon(ish), so trying to keep our team in the loop.

brototyp commented 5 years ago

Hey @notjosh, noting from my side to report. I have one thought though: We could simply try to add the cdt parameter and check if that works. I'll try to provide a testing branch as soon as possible, but that could take as long as the end of the week. Feel free to patch one yourself if that's more critical to you.

notjosh commented 5 years ago

🙌 That did the trick! I've opened a PR over at #301 if you want. Feel free to implement it yourself if you have different ideas!

(Sort of related, I found Prior Artâ„¢ of this issue, but on web over here, so the cdt value is confirmed to be what we want).

brototyp commented 5 years ago

This was implemented and will be part of the next release.