-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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: Added cumulative stickiness #28642
base: master
Are you sure you want to change the base?
Conversation
Size Change: -5 B (0%) Total Size: 1.21 MB ℹ️ View Unchanged
|
📸 UI snapshots have been updated14 snapshot changes in total. 0 added, 14 modified, 0 deleted:
Triggered by this commit. |
2b05d96
to
7c82e06
Compare
a604d6c
to
a426298
Compare
Hey @Sriram-bk! 👋 |
There was a problem hiding this 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 adds cumulative stickiness functionality to PostHog, allowing users to view how many users were active for at least N days rather than exactly N days.
Key changes:
- Added new
StickinessComputationMode
enum withNonCumulative
(default) andCumulative
options in schema - Created
CumulativeStickinessFilter
component with clear tooltips explaining the computation modes - Modified
StickinessQueryRunner
to calculate cumulative values by summing data points from current index to end when in cumulative mode - Added comprehensive test coverage for cumulative stickiness including hourly intervals, property filtering, and edge cases
- Updated actor query logic to use greater-than-or-equal comparison instead of exact match when in cumulative mode
9 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
onChange={(value) => { | ||
updateInsightFilter({ | ||
computedAs: value, | ||
}) | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider adding type safety for the value parameter in onChange. TypeScript could infer it from StickinessComputationModes
export const StickinessComputationModes = { | ||
NonCumulative: 'non_cumulative', | ||
Cumulative: 'cumulative', | ||
} as const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using an enum instead of a const object for better type safety and IDE support
for i in range(len(data)): | ||
total_for_days = sum(data[i:]) | ||
cumulative_data.append(total_for_days) | ||
data = cumulative_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: potential off-by-one error in cumulative calculation - verify that i:end slicing gives correct totals for edge cases
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
Problem
This PR allows users to view stickiness cumulatively over a period of time.
Changes
Non-Cumulative
Cumulative
👉 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?
Added unit tests and tested the visual changes locally.