0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00
Commit Graph

78 Commits

Author SHA1 Message Date
Karl-Aksel Puulmann
a8a33251a9
Use materialized person properties in trends & funnels (#5705)
* ColumnOptimizer: Add functionality for person materialized columns

* WIP: Use person properties in trends/funnels

* Test person materialized props in trends cohort breakdown query

* Make use of materialized person properties in breakdowns

* Mark some cases working with materialized columns

* Test and fix breakdown by person props without filtering

* Make filtering by entity/person props on a join work better

By not assuming everything is under `properties`

* Add test case around breakdown with person properties

* Add test cases around materialization

* Add another materialization test

* Test cohorts and fix breakdowns with person filter

This exposes a limitation in the current implementation

* Fix some cohort tests

* Fix event query tests

* Get a funnel materialized column test running

* Cover more funnel breakdown tests with materialized

* Handle person property breakdowns in funnels

* Fixup funnel typo

* Add tests, fix an indentation issue

* TestFunnelPersons with materialized columns

* Test funnels against actions with person filters

* Add failing test for entity filtering failing

* Add test case for filtering with entity properties

* Show my 'broken' test is actually doing a subquery

* Resolve linting issues
2021-08-26 18:00:49 +00:00
Neil Kakkar
6b916c986b
Enable customising which events to consider on Paths (#5741)
* merge master

* allow inclusion and exclusions on Paths

* fix test
2021-08-26 09:34:07 +00:00
Eric Duong
bf51de1162
Funnel persons path (#5699)
* initial implementation

* add basic test

* move timestamp select

* fix tests and types

* fix test
2021-08-25 12:02:49 +01:00
Karl-Aksel Puulmann
71e724bb1a
Proposal: Make funnel entity list unique (#5734)
Looking at the generated SQL it has bothered me that the list of entity
names is not unique for funnels in queries like `event IN [somearray]`

This tries to fix that.
2021-08-25 11:36:28 +02:00
Tim Glaser
92bd10ffa5
Speed up EE tests by not destroying tables (#5715)
* Speed up EE tests by not destroying tables

* Fix broken tests

* Speed up tests by not running migrations

* Fix last test

* req file?

* caching

* Parallel

* revert exp

* debug without parallel

* Revert "debug without parallel"

This reverts commit 83b3ad633f.

* Undo parallel tests

* Speed up more tests

* use final

* correct final

* print exception

* more prints

* move test

* add filter

* remove duplicate test

* prints here

* test wait

* set variable in query

* remove mutations_sync

* cleanup

Co-authored-by: eric <eeoneric@gmail.com>
2021-08-25 10:58:09 +02:00
Neil Kakkar
8158ccb0b3
Respect conversion window for conversion time (#5688)
* count conversion time only when within conversion window
* tests
2021-08-24 11:59:49 +01:00
Karl-Aksel Puulmann
c9003a8260
Better test coverage for materialized columns (#5682)
* Remove dead argument

* Make allow_denormalized_props always explicit

* Change prop_clauses default

* Create a testing decorator for checking materialized columns

This makes it easier to have proper test coverage for materialized
columns and make sure no bugs creep up :)

* Fix event_query

* Test more materialized columns in trends

* Add materialized column tests for funnels

* Cleanup path_event_query

* Fix default

* Fix issue with clashing parameter names
2021-08-23 17:17:24 +03:00
Neil Kakkar
da305f8000
Error out on exclusion event being same as funnel step (#5668)
* error out on exclusion event being same as funnel step

* remove import
2021-08-23 09:20:34 +02:00
Michael Matloka
4e02411eda
Fix fetching event-based breakdown values with LIMIT (#5496)
* Fix fetching event-based breakdown values with `LIMIT`

* Improve test comment

* Limit prop clauses inclusion to breakdown queries

* Address feedback partly

* Fix imports

* Remove non-3.7-compatible `Literal`

* Don't try to import `Literal`

* Fix oversight

* Always include prop filters in `get_entity_filtering_params`

* Revert "Always include prop filters in `get_entity_filtering_params`"

This reverts commit 4f61edd19a.

* Add and test handling of actions in addition to events

* Update test_funnel.py

* Move new tests to `breakdown_cases`
2021-08-20 16:48:00 +02:00
Karl-Aksel Puulmann
0f0241e01d
Funnels: support breaking down by "All users" pseudo-cohort (#5651)
This already works in trends, but had a bug in funnels. Unified the
implementations as well.

Closes https://github.com/PostHog/posthog/issues/5566
2021-08-19 13:23:07 +03:00
Karl-Aksel Puulmann
020cb3b085
Only query event columns that are needed (#5610)
* Cache action lookups on entity

* Avoid mutating filters

* Single-line a long query line

* Calculate columns to select from table dynamically

* Rename class to ColumnOptimizer

* Improve typing

* Set logic

* Rename var

* Fetch funnel top values via materialized columns

* Add a cast

* Simplify, fix

* Move types to more logical place

* Add tests for ColumnOptimizer

* Tidy code

* Test whether elements_chain is needed or not

* No caching in tests

* Use `ColumnOptimizer` in trends

* Prepend commas

* Fix event_query tests

* Handle another edge case around elements_chain

* Handle funnel exclusions

* Add documentation around trickier pieces of logic

* Comment out a broken case for now
2021-08-19 10:17:40 +03:00
Karl-Aksel Puulmann
4ba8249cb5
Handle materialized properties in more cases (#5523)
* Extract method from funnels code

* Add failing test case for using denormalized property in a funnel breakdown

* Handle materialized event properties in funnel breakdown

* Refactor property lookups

* Use denormalized properties in paths

* Update validation tests

* Update validation tests

* Fix a broken test

* Move test around
2021-08-17 12:30:28 +03:00
Neil Kakkar
a245c15c94
Group reamining breakdown values into "Other" for funnels (#5538)
* breakdown grouping

* resolve pagination woes

* explain the offset override

* document assumption
2021-08-12 13:38:28 +00:00
Eric Duong
de7ff476c5
Allow cohort breakdown to show on funnel (#5495)
* allow cohort breakdown to show

* Sanitize `order` in `Entity.__init__`

* Remove kludge from #5485 by making `entity.order` useful in practice

* Use synthetic `index` instead of user-provided `order`

* Fix `processed_entities` sorting

* Update frontend/src/scenes/funnels/funnelLogic.ts

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>

* change type guard and add number back

* remove typeguard and add correct types for cohorts

* remove type change

* working cohort breakdowns ui

* one more type fix

* adjust tests

* adjust tests

* more test adjustmenet

* minor syntax change

* use breakdown type

* add comment

* remove leakover

Co-authored-by: Michael Matloka <dev@twixes.com>
Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
Co-authored-by: Sam Winslow <sammywinslow@gmail.com>
2021-08-11 13:56:49 -04:00
Karl-Aksel Puulmann
a860da9e90
Dynamic materialized columns (#5458)
* Add migration marking existing columns as materialized with a comment

* Add method to allow looking up materialized columns

* Add test for fetching and creating materialized columns

* Disable caching in tests

* Remove some callsites to CLICKHOUSE_DENORMALIZED_PROPERTIES

* Fixup caching logic

* Add (currently broken) test for denormalizing person properties

* Update funnel event query to work with new functionality

* Update other tests/queries

* Remove now-unused setting
2021-08-09 10:11:36 +03:00
Michael Matloka
c2bc2fecd0
Use proper interval calculation in the funnel trends query (#5467)
* 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`
2021-08-06 11:29:35 +02:00
Karl-Aksel Puulmann
a1dd96e47d
Improve cached_property typing (#5465)
* 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
2021-08-05 22:31:31 +03:00
Eric Duong
24a708c259
Funnel trends all date range (#5420)
* implementation and test

* change to escape params
2021-08-04 10:33:39 -04:00
Neil Kakkar
5d3eb59807
Update default breakdown limit in funnels (#5426)
* Update default breakdown limit in funnels

https://github.com/PostHog/posthog/issues/5341#issuecomment-891743574

* update test

* add default to breakdown limit property

* address comments
2021-08-03 14:18:20 +01:00
Neil Kakkar
a5d9953dc1
Make Breakdown limit customizable and Allow empty breakdown value in trends and funnels (#5357)
* breakdown limits update

* include null in limit

* clean breakdowns for trends & peeps
2021-08-03 10:59:09 +01:00
Neil Kakkar
796fa106fe
Add missing interval value (#5398) 2021-08-02 14:25:13 +01:00
Neil Kakkar
06db796376
Constrain trends results to generated values (#5368)
Similar to: https://github.com/PostHog/posthog/pull/5316
2021-07-29 14:30:40 +03:00
Eric Duong
a01a5edca2
Add more options for funnel windowing (#5329)
* 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
2021-07-27 13:09:29 -04:00
Eric Duong
708ce2bb59
Funnel trends breakdown (#5232)
* 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
2021-07-27 12:17:14 -04:00
Eric Duong
37ac7feffe
Fix derivative step bug for funnels (#5337)
* add includes method and tests for derivative steps

* make suggested changes

* return to original and add comment

* change name
2021-07-27 15:07:48 +00:00
Neil Kakkar
421732b652
Allow Excluding Multiple Events + events in unordered funnels (#5150)
* clean up, more tests, docs

* ensure correct filter values get saved to cache

* exclusion in unordered funnels
2021-07-27 10:10:37 +01:00
Alex Gyujin Kim
e7f89597d5
Standardize date and time formatting across app (#5332)
* standardize dates and times across app

* fix tests

* fix postgres tests

* some more fixed tests
2021-07-27 01:46:20 +00:00
Neil Kakkar
259d12d6cf
Ensure time_to_convert bins stay uniform (#5316)
* ensure bins stay uniform

* rm offending line
2021-07-23 10:40:17 -04:00
Karl-Aksel Puulmann
0c5852f586
Update comment style to be copyable (#5281) 2021-07-23 13:15:59 +03:00
Eric Duong
f6e5a2b6a8
Make sure values are populated and persons paginate properly (#5305) 2021-07-23 10:47:48 +01:00
Neil Kakkar
ca724e1f81
Resolve errors with time to convert bins (#5283)
* time to convert test

* rworkaround for time to convert bins

* address comment
2021-07-22 14:04:05 +00:00
Neil Kakkar
b8c946cf99
Fix Funnel Trends Persons with month/week granularity (#5277)
* resolve #5275

* address comment
2021-07-22 11:49:15 +00:00
Neil Kakkar
a0b99facec
Fix issues with step conversion times (#5174)
* general conversion time cases

* clean cases

* remove ch bug test for now
2021-07-22 09:31:47 +01:00
Eric Duong
39416b7e94
Revert "Run broken down analyses with a single SQL query (#5186)" (#5272)
This reverts commit 3e5b073ade.
2021-07-21 19:29:27 -04:00
Michael Matloka
3e5b073ade
Run broken down analyses with a single SQL query (#5186)
* Remove unused imports

* Rework breakdowns for CTEs instead of separate queries

* Increase happiness of mypy

* Fix formula trends

* remove repeated team_condition

* remove print

Co-authored-by: eric <eeoneric@gmail.com>
2021-07-21 14:00:34 -04:00
Eric Duong
cedf33c891
Add median time for funnel conversion data (#5203)
* 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
2021-07-20 13:36:22 -04:00
Eric Duong
993278ad46
Fix single cohort bug (#5225)
* fix single cohort bug

* fix test name
2021-07-20 16:27:41 +00:00
Eric Duong
8b6b6ae9bb
Fix broken funnel pagination (#5178)
* fix broken funnel pagination

* account for both return results

* add limit param

* move order

* move the check

* change magic number

* adjust more tests
2021-07-20 11:34:15 -04:00
Michael Matloka
72f67b1fc4
Fix funnel trends step indexes (#5172)
* Fix funnel trends `to_step` default

* Make steps 0-indexed in funnel trends too
2021-07-20 11:06:24 +01:00
Alex Gyujin Kim
d9973c7e5d
Add all steps option to time conversion funnel (#5142)
* 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>
2021-07-19 12:00:59 -07:00
Eric Duong
7a325c79bd
Add default conditions properly to time to convert params (#5154)
* add default conditions properly

* run again
2021-07-15 14:55:09 -04:00
Li Yi Yu
973af368cd
Return correct chart tooltip date (#5135) 2021-07-15 12:05:36 -05:00
Neil Kakkar
8a1bd1c80e
Add Support for Excluding Events from Funnels (#5104)
* finish for ordered

* clean up, more tests, docs

* ensure correct filter values get saved to cache
2021-07-15 13:42:40 +01:00
Michael Matloka
3ca42efd87
Allow time to convert across multiple steps (or whole funnel) (#5110)
* Allow time to convert across multiple steps (or whole funnel)

* Update comments
2021-07-14 13:17:24 +02:00
Eric Duong
bcffcde783
Add a test to make sure funnel cohort persons is returned (#5103)
* add a test to make sure funnel cohort persons is returned

* delete comment

* checking persons on cohort return in original test
2021-07-13 11:15:12 -04:00
Tim Glaser
543d567c5b
Fix denormalised props funnels (#5101)
* Fix denormalised props funnels

* fix settings

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-07-13 13:13:45 +00:00
Michael Matloka
871024f8c6
Funnel trends persons (#5060)
* 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
2021-07-13 09:57:19 +00:00
Eric Duong
ec53a13e1c
Funnel cohort breakdown (#5053)
* index the cohort params

* remove extra condition

* cohort working
2021-07-13 09:52:36 +01:00
Eric Duong
ad90717903
funnel bug if breakdown_type not passed (#5082)
* handle if brekadown type not passed

* move breakdown tests
2021-07-13 09:30:38 +01:00
Neil Kakkar
c554bb5e55
Enable person breakdowns querying for all ordering funnels (#5043)
* 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
2021-07-12 18:53:26 +02:00