* Use proper interval calculation in the funnel trends query
* Add some comments
* Update `test_filter`
* Rework `NULL_SQL` to use CH `INTERVAL` too
* Fix week-based relative `date_from` support not existing
* Make use of `toInterval*` functions and inject less
* Add fallback for `date_from` in `ClickhouseSessionsAvg`
* Improve cached_property typing
Noticed that e.g. `filter.breakdown` was getting inferred to be `Any`
which is not correct. Added generics to fix it :)
* Proposed fix: make filter_test_accounts return a bool always
* Fix warning in clickhouse_sessions.py
* Cast in session.events
* Cast 2x in funnel queries
* Ignore error in session recording
We know the valid values here
* Add assertions in stickiness filters
* Cast in more funnel queries
* Untyped dict where inferred type is wrong
* Add types to abstract methods
* Type prop_vals
* Add a lot of casts
These are correct. We should really validate while parsing instead
* Add more casts to funnel trends
* Last fixes
* Use f-strings in trends/formula
* Make formulas and breakdowns work
Closes issue https://github.com/PostHog/posthog/issues/5390
Previously the query returned a 500 for some breakdowns, with the error
`Arrays passed to arrayMap must have equal size: while executing 'FUNCTION arrayMap`
The issue came from the different subqueries having different breakdowns
- some would break down with values A and B and other would have B and C
After the full outer join, arrays for breakdown values A and C would be empty in some cases. Filling them with zeroes fixes the issue.
* Fix "ambigious column distinct_id"
The problem came in a trends query:
1. Which filters by action having person property filters
2. The overall query having a person property filter
See also the regression test
Closes https://github.com/PostHog/posthog/issues/5388
* Add calculate_events call
* Implement workaround for reading person_distinct_ids
Context under https://github.com/PostHog/product-internal/issues/114
Hopefully a temporary workaround!
* Update query
* use print
* match stickiness test
* match stickiness and trends cohort paths
* bring back distinct_id query
* revert unrelated change
* reutrn to original
* reformat
* run again
* comment out test
Co-authored-by: eric <eeoneric@gmail.com>
* add more options for funnel windowing
* tweaks
* add test
* accomodate any case and make to_dict smaller
* remove import
* change name
* store lower
* fix test
* partial implementation
* working event breakdown
* remove hardcoded fill
* add person test
* remove test unneeded
* use original breakdown implementation
* add cohort handling
* add clause lost on merge
* add median time for conversion steps
* patch tests
* fix time to convert funnel query
* fix strict and unordered
* add median conversion time to base
* fix
* more tests
* fix broken funnel pagination
* account for both return results
* add limit param
* move order
* move the check
* change magic number
* adjust more tests
* Revert "Revert "Add is_deleted column to person_distinct_id (#5151)" (#5193)"
This reverts commit 401268bdba.
* A tweak for docker-compose builds
Co-authored-by: James Greenhill <fuziontech@gmail.com>
* add all steps option
* all steps working; add total and mean time to convert
* change display type checks to use enum
* kea types
* dangling console log
* Add average conversion time to time to convert results
* respond to feedabck
* responsive histogram sizes
* merged @Twixes backend changes; adjust data shape on frontend; add responsiveness to histogram
* add tooltip label
* adjust copy and tooltip
* minor tweaks
* respond to general feedback
* kea auto
* better empty state:
* error handling null time bins
* fix tests
Co-authored-by: Michael Matloka <dev@twixes.com>
Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
* Update PERSONS_ACTIVE_USER_SQL query
* Remove dead import
* Update lifecycle queries
* Update BREAKDOWN_ACTIVE_USER_INNER_SQL to use new persons query
* Update STICKINESS_SQL
* Update STICKINESS_PEOPLE_SQL
* Update STICKINESS_ACTIONS_SQL
* Update paths query
* Update events query
* Update CALCULATE_COHORT_PEOPLE_SQL
* Update retention queries
* Update TOP_PERSON_PROPS_ARRAY_OF_KEY_SQL
* Update EVENT_JOIN_PERSON_SQL
* Update GET_PERSON_ID_BY_ENTITY_COUNT_SQL
* Remove remaining references to old get latest person query
* Update GET_DISTINCT_IDS_BY_PROPERTY_SQL
* Fix code style issue
* Update table engine for person_distinct_id table
* don't select team_id
* Make person deletion work
* Use replacingmergetree over collapsing with is_deleted
Replacing an existing engine is hard, let's not do it
* Update query in test
* add migration
* set database on materialized views
* Update plugin server to 1.1.6
Co-authored-by: James Greenhill <fuziontech@gmail.com>
Co-authored-by: posthog-bot <posthog-bot@users.noreply.github.com>
* JOIN in funnel trends query in a more optimal way
* Reformat funnel trends assert slightly
* Refactor `ClickhouseFunnelTrends` slightly
* Add `ClickhouseFunnelTrendsPersons` code
* Allow parametrization of funnel trends persons query
* Update test_funnel_trends.py
* Clean some funnel analysis code up
* Fix `drop_off` default in `FunnelTrendsPersonsMixin`
* Refactor for `ClickhouseFunnelTrends.get_step_counts_without_aggregation_query`
* Update test_funnel_trends.py
* Add an API test for funnel trends persons
* Use `FUNNEL_PERSONS_BY_STEP_SQL`
* Tests persons some more
* Remove unused imports
* first pass mix and match everything
* cleanup
* small refactoring of get_query
* remove top level filter props
* save the file
* enable person breakdowns querying for regular + strict funnels
* move mixin testing to more appropriate location
* add unordered, testing quality of life improvements
* clean up
* add strict+unordered connectivity test for time to convert
* trim after extracting
* clean up, fix tests, trim everywhere
* Load session events asynchronously from a separate endpoint
This mirrors the behavior of postgres query
* Simplify backend & query
event_count is unused
don't select unused columns in list query
* Rename filter_by_session_recordings to filter_by_session_recordings
This is more in-line with what the function actually does
* Update types, handle start/end url properly
* start_url / end_url to session result
* Update sessions list builder tests
* Remove some `session.events` references
* Remove unneeded code
* Simplify filteredSessions
* Fix type issue
* Add test for session properties
* Test and fix start_url/end_url
* Add test for the new sessions API endpoint
* Improve types
* Update py types again
* Fix bug