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

feat: Add human friendly comparison periods toggle #27176

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

rafaeelaudibert
Copy link
Member

Problem

Some customers have seasonal data, where data repeats on specific days of the month/year and they'd like to compare against them. The problem is that if you set "compare against last year" but look at data day to day, then it will be misaligned because the days of the week aren't the same year after year.

Changes

This toggle allows us to do "human friendly" comparisons, i.e. consider month as 52 weeks and month as 4 weeks. This makes the comparison table slightly nicer to look at, at the cost of not aligning 100% of the time because a month = 30d and a year=365s are slightly more than 4 weeks and 52 weeks, respectively

I've put the configuration inside "Product Analytics" rather than "Web Analytics" because this applies globally - it's a team-based setting.

image

Does this work well for both Cloud and self-hosted?

Yep

How did you test this code?

Automated tests + manual UI testing

@rafaeelaudibert
Copy link
Member Author

https://github.com/PostHog/posthog/actions/runs/12520844708/job/34927105170?pr=27176 is failing but this is wrong. We can safely add a non-null field with a default on Postgres v11+ - which we are. See https://www.reddit.com/r/programming/comments/bw0vgm/psa_postgresql_11_allows_you_to_create_a_nonnull/

How can we sort this out?

@rafaeelaudibert rafaeelaudibert force-pushed the human-friendly-month-and-year-comparison-periods branch from 0460a11 to a298ea9 Compare December 27, 2024 23:54
@PostHog PostHog deleted a comment from posthog-bot Dec 27, 2024
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

16 snapshot changes in total. 0 added, 16 modified, 0 deleted:

  • chromium: 0 added, 16 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

This toggle in the backend allows us to do "human friendly" comparisons, i.e. consider month as 52 weeks and month as 4 weeks. This makes the comparison table slightly nicer to look at, at the cost of not aligning 100% of the time because a month = 30d and a year=365s are slightly more than 4 weeks and 52 weeks, respectively

Follow-up commit will add the toggle to the UI
You can now toggle that in the UI on `settings/environment-product-analytics#human-friendly-comparison-periods`
@rafaeelaudibert rafaeelaudibert force-pushed the human-friendly-month-and-year-comparison-periods branch from 455be0d to 603eeba Compare December 28, 2024 03:40
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

16 snapshot changes in total. 0 added, 16 modified, 0 deleted:

  • chromium: 0 added, 16 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

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

Successfully merging this pull request may close these issues.

2 participants