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

Improve instance status report #2271

Merged
merged 7 commits into from
Nov 10, 2020
Merged

Improve instance status report #2271

merged 7 commits into from
Nov 10, 2020

Conversation

macobo
Copy link
Contributor

@macobo macobo commented Nov 9, 2020

Checklist

  • All querysets/queries filter by Organization, Team, and User (if this PR affects ANY querysets/queries).
  • Django backend tests (if this PR affects the backend).
  • Cypress end-to-end tests (if this PR affects the frontend).

@timgl timgl temporarily deployed to posthog-status-report-e-ycl7vp November 9, 2020 07:33 Inactive
Copy link
Contributor

@paolodamico paolodamico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, kudos on adding tests!

Considering we're improving this report & following @timgl's comment & #1954, think it might be worth considering splitting each team's calculation into a separate celery task and then just send a report per team?

def fetch_events_count_by_name(params: Tuple[Any, ...]) -> dict:
results = fetch_sql(
"""
SELECT event as name, COUNT(*) as count
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's related to this PR, but maybe we should obfuscate the name if the user has selected to anonymize their data?

def fetch_events_count_by_name(params: Tuple[Any, ...]) -> dict:
results = fetch_sql(
"""
SELECT event as name, COUNT(*) as count
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if it's related to this PR but wondering if we should obfuscate the event names if the users chose to anonymize their data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file an issue - there was no semantic change to the previous behavior here, I'd like to avoid ballooning this into a bigger deal.

"period": {"start_inclusive": period_start.isoformat(), "end_inclusive": period_end.isoformat()},
}

report["users_who_logged_in"] = [
{"id": user.id, "distinct_id": user.distinct_id}
if user.anonymize_data
else {"id": user.id, "distinct_id": user.distinct_id, "first_name": user.first_name, "email": user.email}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is unrelated, but adding it here as this PR is an improvement on this code. I don't think it ever makes sense to send the user's first name and email, we're just adding PII here that it'll be very hard to keep track of. With the distinct ID we should be able to get their name if they haven't anonymized their data.

Also maybe send the total number of registered users too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file a separate issue with a suggestion how to anonymize. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll make a PR for this after this one is merged

@macobo
Copy link
Contributor Author

macobo commented Nov 10, 2020

Considering we're improving this report & following @timgl's comment & #1954, think it might be worth considering splitting each team's calculation into a separate celery task and then just send a report per team?

Maybe, but I'd like to see the problem before 'fixing' it. I'll update the task to handle failures in a way that reaches us.

@macobo macobo temporarily deployed to posthog-status-report-e-ycl7vp November 10, 2020 07:55 Inactive
Copy link
Contributor

@paolodamico paolodamico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! think the only last point that might bring up is if it's worth changing COUNT(*) to COUNT(1) (timgl suggestion)

@macobo macobo temporarily deployed to posthog-status-report-e-ycl7vp November 10, 2020 08:06 Inactive
@macobo macobo temporarily deployed to posthog-status-report-e-ycl7vp November 10, 2020 08:46 Inactive
@macobo macobo merged commit 30cb3d6 into master Nov 10, 2020
@macobo macobo deleted the status-report-enhancements branch November 10, 2020 13:42
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 this pull request may close these issues.

Instance status report task reports wrong numbers
3 participants