fix: display label as tooltip title on stickiness graph #24728
Merged
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.
Problem
As described in #22209, the
<LineGraph />
component wasn't properly rendering tooltip titles in the context of the stickiness graph. This was due to the fact that the filter interval was undefined so theIntervalType
defaulted today
.posthog/frontend/src/scenes/insights/InsightTooltip/InsightTooltip.tsx
Line 105 in 00bab5e
posthog/frontend/src/scenes/insights/InsightTooltip/insightTooltipUtils.tsx
Line 90 in 261a2f5
Changes
As described in #22440 (comment), the interval value is not present in the api response. Even if it was present, however, it could be argued that
3 weeks (EDT)
,4 weeks (UTC)
, and2 days (PDT)
are not good titles (the presence of the timezone makes no sense in this context). Thus it was decided to avoid the date formatting all together when thedate
value is numeric by returning the label value from thealtTitle
function. This is the same value used on the graph's X axis.Below are some comparisons showing the difference b/w
PostHog:master
andghoti143:bug-tooltip-title
Stickiness graph grouped by week
PostHog:master
ghoti143:bug-tooltip-title
Stickiness graph grouped by day
PostHog:master
ghoti143:bug-tooltip-title
Stickiness graph grouped by hour
PostHog:master
ghoti143:bug-tooltip-title
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Manually tested the Trends graph to ensure that it still renders the titles using the
getFormattedDate()
function and doesn't display the labels.