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(web-analytics): Choose sensible interval for graphs #18860

Merged
merged 11 commits into from
Nov 30, 2023

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Nov 23, 2023

Problem

Currently if you choose the last 24 hours, you see a daily view, which is not helpful as there is 1 data point.
Additionally if you choose past year, you also get a daily view, which again not helpful as you have hundreds of data points.

Changes

Try to choose a sensible interval based on the date range. For the default options in the date picker, these are already set, but provide a fallback.

Do something similar when changing the interval, if the existing date range is not compatible with the new interval then change the date range.

Note: I could have gone further into this, particularly handling custom date ranges. This is something I'll follow up with in a separate PR when I let people change the interval

Used the dates in trends when comparing to previous periods

Screenshot 2023-11-30 at 11 29 44

How did you test this code?

Some unit tests

@robbie-c robbie-c changed the title Choose sensible interval for graphs feat(web-analytics): Choose sensible interval for graphs Nov 23, 2023
@robbie-c robbie-c marked this pull request as ready for review November 23, 2023 14:27
@robbie-c robbie-c force-pushed the choose-sensible-interval-for-graphs branch from a779d4c to 3fc1a08 Compare November 30, 2023 11:00
Copy link
Contributor

Size Change: +377 B (0%)

Total Size: 1.83 MB

Filename Size Change
frontend/dist/toolbar.js 1.83 MB +377 B (0%)

compressed-size-action

@robbie-c robbie-c requested a review from mariusandra November 30, 2023 11:31
@@ -729,7 +749,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
const geoIpPluginConfig =
isNotNil(geoIpPluginId) &&
pluginsConfigResponse.status === 'fulfilled' &&
pluginsConfigResponse.value.find((plugin) => plugin.id === geoIpPluginId)
pluginsConfigResponse.value.find((plugin) => plugin.plugin === geoIpPluginId)
Copy link
Member Author

Choose a reason for hiding this comment

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

Snuck this change in

Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

Nice! Here's a ✅ , though it might be worth adding (or letting chatgpt add) a few more tests to utils.test.ts? You added a few new functions, but tests only for getDefaultInterval. Or you think e.g. testing dateStringToComponents via dateStringToDayJs is good enough? I don't feel too strongly here, so happy to merge without.

@robbie-c robbie-c force-pushed the choose-sensible-interval-for-graphs branch from cb662e3 to 0f1728c Compare November 30, 2023 13:10
@robbie-c robbie-c force-pushed the choose-sensible-interval-for-graphs branch from 6d4b806 to 6d652e6 Compare November 30, 2023 15:40
@robbie-c robbie-c enabled auto-merge (squash) November 30, 2023 15:49
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 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.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 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.

@robbie-c robbie-c merged commit c2dcb29 into master Nov 30, 2023
77 checks passed
@robbie-c robbie-c deleted the choose-sensible-interval-for-graphs branch November 30, 2023 17:05
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.

3 participants