This repository was archived by the owner on Sep 30, 2024. It is now read-only.
[fix] use same where condition in user analytics as in pings for mau#52306
Merged
Conversation
Previously we used a different condition to calculate the MAU and other stats in user analytics page. Now we use the same condition as we use for pings. We also calculate everything using UTC now, so both should give the same value.
8f868a3 to
676946d
Compare
Contributor
erzhtor
approved these changes
May 26, 2023
erzhtor
left a comment
Contributor
There was a problem hiding this comment.
Thanks for these changes, looks cleaner! Besides minor questions/comments looks good to me!
| SELECT | ||
| CASE WHEN user_id = 0 THEN anonymous_user_id ELSE CAST(user_id AS TEXT) END AS user_id, | ||
| COUNT(DISTINCT DATE(timestamp)) AS days_used | ||
| COUNT(DISTINCT DATE(TIMEZONE('UTC', timestamp))) AS days_used |
Contributor
There was a problem hiding this comment.
Curious, why do we need this? I thought timestamps are stored in UTC anyway, aren't they?
Contributor
Author
There was a problem hiding this comment.
No, the default timezone in the database is whatever the system it is running on default is. So in my case it's using EU timezone.
0xnmn
reviewed
May 26, 2023
| @@ -163,12 +161,7 @@ func (f *Users) MonthlyActiveUsers(ctx context.Context) ([]*MonthlyActiveUsersRo | |||
| prevMonth := now.AddDate(0, -2, 0) // going back 2 months | |||
Contributor
There was a problem hiding this comment.
The previous month timeframe calculations can be troubling too.
0xnmn
approved these changes
May 26, 2023
0xnmn
left a comment
Contributor
There was a problem hiding this comment.
These changes give the exact numbers as the pings?
kopancek
added a commit
that referenced
this pull request
May 30, 2023
This is for usage analytics in the product. Previously we were filtering out the backend events, but as part of #52306 this was removed, because I believed it shold not be there, as it was not part of the BuildCommonUsageConds in the event_logs. However event_logs also add this condition directly in the query string, which I did not notice.
kopancek
added a commit
that referenced
this pull request
May 30, 2023
Fixes MAU calculation in usage analytics in the product. Previously we were filtering out the backend events, but as part of #52306 this was removed, because I believed it shold not be there, as it was not part of the BuildCommonUsageConds in the event_logs. However event_logs also add this condition directly in the query string, which I did not notice. Also, our timestamp calculation suffered from an edge case, where the from time was not calculated right, e.g. on dates like `2023-04-30T23:59:00Z`. ## Test plan Tested locally and with customer data + added unit tests.
kopancek
added a commit
that referenced
this pull request
May 31, 2023
…52306) Previously we used a different condition to calculate the MAU and other stats in user analytics page. Now we use the same condition as we use for pings. We also calculate everything using UTC now, so both should give the same value. ## Test plan Tested locally and also with data from Tinder. The new query for MAU seems to be returning the correct data for us, I manually cross-referenced the old query vs the new. Apart from the timezone difference, the new query is more precise as in it filters the sourcegraph-operator users and non-user events in the same way as we do for the pings. (cherry picked from commit 8d04aa1)
coury-clark
pushed a commit
that referenced
this pull request
May 31, 2023
… pings for mau (#52608) Previously we used a different condition to calculate the MAU and other stats in user analytics page. Now we use the same condition as we use for pings. We also calculate everything using UTC now, so both should give the same value. ## Test plan Tested locally and also with data from Tinder. The new query for MAU seems to be returning the correct data for us, I manually cross-referenced the old query vs the new. Apart from the timezone difference, the new query is more precise as in it filters the sourcegraph-operator users and non-user events in the same way as we do for the pings. <br> Backport 8d04aa1 from #52306 Co-authored-by: Milan Freml <kopancek@users.noreply.github.com>
ErikaRS
pushed a commit
that referenced
this pull request
Jun 22, 2023
…52306) Previously we used a different condition to calculate the MAU and other stats in user analytics page. Now we use the same condition as we use for pings. We also calculate everything using UTC now, so both should give the same value. ## Test plan Tested locally and also with data from Tinder. The new query for MAU seems to be returning the correct data for us, I manually cross-referenced the old query vs the new. Apart from the timezone difference, the new query is more precise as in it filters the sourcegraph-operator users and non-user events in the same way as we do for the pings.
ErikaRS
pushed a commit
that referenced
this pull request
Jun 22, 2023
Fixes MAU calculation in usage analytics in the product. Previously we were filtering out the backend events, but as part of #52306 this was removed, because I believed it shold not be there, as it was not part of the BuildCommonUsageConds in the event_logs. However event_logs also add this condition directly in the query string, which I did not notice. Also, our timestamp calculation suffered from an edge case, where the from time was not calculated right, e.g. on dates like `2023-04-30T23:59:00Z`. ## Test plan Tested locally and with customer data + added unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously we used a different condition to calculate the MAU and other stats in user analytics page. Now we use the same condition as we use for pings. We also calculate everything using UTC now, so both should give the same value.
Test plan
Tested locally and also with data from Tinder. The new query for MAU seems to be returning the correct data for us, I manually cross-referenced the old query vs the new. Apart from the timezone difference, the new query is more precise as in it filters the sourcegraph-operator users and non-user events in the same way as we do for the pings.