-
Notifications
You must be signed in to change notification settings - Fork 121
Description
Describe the bug
Right now, we're computing a site's total visitor count in the SiteVisitStats model by adding together the visitor count for each of the intervals within a given period:
| // MARK: Computed Properties | |
| public var totalVisitors: Int { | |
| return items?.map({ $0.visitors }).reduce(0, +) ?? 0 | |
| } | |
| } |
However, calculating the total visitors this way can be inaccurate. As outlined in this support doc:
- A view is counted when a visitor loads or reloads a page.
- A visitor is counted when we see a user or browser for the first time in a selected time frame.
In other words:
If I’m viewing my stats for today, I might see that I’ve had 3 visitors today. I might have 3 visitors every day for a week. However, my total visitors for a week won’t necessarily be a sum of the visitors I had for each day of that week (3 + 3 + 3 + 3 + 3 + 3 + 3 = 21 visitors). If I had 3 visitors every day, but they were the same 3 visitors, my total visitor count for the week should be 3 (instead of 21); this is the total we would get if we retrieved the total visitor count with the week granularity.
See also this internal discussion: pe5pgL-1eR-p2#comment-1286, pe5pgL-1p6-p2