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(retention): graph UX updates #29270

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

Conversation

anirudhpillai
Copy link
Contributor

Problem

Closes #23911
Lot of UX changes highlighted below

Changes

Option to show retention graph in dashboards
image

Option for bar chart instead of line graph (will add more enhancements to bar chart in future PRs)
image

New section for 'Retention calculation options', buttons around chart only control display configs (eventually will move mean to the side as well, once Sri's changes are merged in)
image

Selecting retention reference actually updates the table now (previously only changed the line graph)
image

Added tooltips for cumulative retention
image

image

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

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

How did you test this code?

@anirudhpillai anirudhpillai requested a review from a team February 26, 2025 20:09
@anirudhpillai anirudhpillai enabled auto-merge (squash) February 26, 2025 20:09
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR enhances the retention graph UX with multiple visualization and display options for better dashboard integration.

  • Added RetentionOptions component that separates retention calculation settings from display controls
  • Created RetentionChartPicker allowing users to switch between line and bar chart visualizations
  • Implemented RetentionDashboardDisplayPicker with options to show table-only, graph-only, or both in dashboards
  • Replaced checkbox with RetentionCumulativeButton using segmented controls with improved tooltips
  • Modified RetentionContainer to conditionally render components based on dashboard display preferences

20 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +27 to +32
const showLineGraph =
!vizSpecificOptions?.hideLineGraph &&
(!inCardView ||
(!!retentionFilter?.dashboardDisplay && // for backwards compatibility as we were hiding the graph on dashboards before adding this property
retentionFilter?.dashboardDisplay !== RetentionDashboardDisplayType.TableOnly))

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The showLineGraph logic has a potential issue with the double negative (!vizSpecificOptions?.hideLineGraph). When inCardView is true but retentionFilter.dashboardDisplay is undefined (for existing dashboards), the graph will be hidden. This matches the comment about backwards compatibility, but might be confusing for users upgrading.

Copy link
Contributor

github-actions bot commented Feb 26, 2025

Size Change: +813 B (+0.01%)

Total Size: 9.73 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 9.73 MB +813 B (+0.01%)

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

anirudhpillai and others added 3 commits February 26, 2025 21:53
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Copy link
Contributor

@thmsobrmlr thmsobrmlr left a comment

Choose a reason for hiding this comment

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

Cool thing!

Some remarks:

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems odd to me that the numbers would change in visual regression tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating retention reference updates the table as well now (previously only changed the line graph). This would mean some numbers changed, but is there a way to tell if this snapshot was created with a different retention reference?

Copy link
Contributor

@thmsobrmlr thmsobrmlr Feb 27, 2025

Choose a reason for hiding this comment

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

The snapshots come from storybook and the query for that is mocked in https://github.com/PostHog/posthog/tree/master/frontend/src/mocks/fixtures/api/projects/team_id/insights.

Mocks still have filters in them, could that cause an issue as well? - Happy to pair on this, if easier.

@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.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)
  • 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

12 snapshot changes in total. 0 added, 12 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retention series chart on the dashboard
3 participants