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

592 Commits

Author SHA1 Message Date
Karl-Aksel Puulmann
6014a4f3b5
Follow-up to breakdowns refactor PR (#5826)
Noticed I missed a comment since the thread got resolved 😅
2021-09-07 16:42:22 +03:00
Tim Glaser
79cb5e645c
fix person modal across multiple dates (#5819)
* fix person modal across multiple dates

* test works for pg but shouldn't for ee

* wrong number

* make it cumulative relevant

Co-authored-by: eric <eeoneric@gmail.com>
2021-09-07 15:17:50 +03:00
Karl-Aksel Puulmann
b6b2508233
Make marking materialized columns as MATERIALIZED stateless (#5831)
This simplifies the operational model a lot
2021-09-07 11:53:57 +00:00
Karl-Aksel Puulmann
4306444c2e
Fix issue with person breakdowns and clashing params (#5815)
* Fix issue with person breakdowns and clashing params

Closes https://github.com/PostHog/posthog/issues/5814

Another PR https://github.com/PostHog/posthog/pull/5807 also fixes this
(incidentally) but this fix won't hurt it + adds a regression test.

* Autoimport Property into shell_plus to speed up debugging

* Remove index
2021-09-07 13:36:14 +03:00
Karl-Aksel Puulmann
17836f80f5
Add command for materializing columns (#5816)
* Add command for materializing columns

Expecting this to get used in both dev as well as when improving
upstream installations

* No clashes in tests

* Solve for feedback

* Comments for clarity
2021-09-07 07:56:29 +00:00
Karl-Aksel Puulmann
35813b3b49
Refactor breakdowns to work with materialized person columns (#5807)
* Make breakdown join with person if needed

* Refactor trends to be purely class-based, don't rely on wonky inheritance

* Extract method

* Improve person join behavior

* Remove unneeded parameter

* Mark a function thats always passed as such

* Add test case demonstrating previous non-join case

* Unify two get_breakdown_prop_values methods

* Add test for materialized columns

* Simplify trends breakdown query

* Unify _breakdown_prop_params for events/person breakdowns

* Use shared column_optimizer

* Typing fix

* Cleanup

* Code style cleanup

* Code style cleanup

* Fix param ordering
2021-09-07 09:05:13 +03:00
Karl-Aksel Puulmann
5d6b083c90
Fix uses_elements_chain (#5810)
Closes https://github.com/PostHog/posthog/issues/5808

I'd love to fix this at the schema level but looked into it for ~20
minutes and it didn't seem like there's a pretty solution that allows to
pass `None` to .objects.create and for the default to be used.

Other solutions would be even more invasive and require manipulating
serializers.

Best leave this to when we refactor all of out `properties` JSONFields
since they all have this issue
2021-09-06 16:55:54 +03:00
Karl-Aksel Puulmann
0df87579ab
Add more materialized column settings (#5806) 2021-09-04 18:07:20 +03:00
Eric Duong
33a3c0e238
try to remove redundant filtering (#5782) 2021-09-01 15:40:27 -04:00
Eric Duong
4ac73045de
add missing table name in query (#5781) 2021-09-01 13:51:33 -04:00
Karl-Aksel Puulmann
8d8705d1bb
Materialize person columns automatically (#5760)
* Hotfix: Use materialized columns on cloud

This was broken since default_kind was different on Distributed tables
on cloud

* Improve __init__.py

* Make reverting DEFAULT column async, only ON CLUSTER for events table
2021-08-28 12:14:30 +03:00
Neil Kakkar
9e909855a0
Treat URLs with trailing slash as equivalent in Paths computation, and some bug fixes (#5763)
* fix some path bugs

* cleanup

* dont remove / when only /

* use appendTrailingChar

* revert back

Co-authored-by: eric <eeoneric@gmail.com>
2021-08-27 15:28:01 -04:00
Eric Duong
8709e17c77
Path end point target (#5746)
* make functions dynamic

* add end test

* add adjustments

* remove reverse
2021-08-27 14:38:19 -04:00
Paolo D'Amico
bcf9837e38
SAML - frontend & enforce (#5758) 2021-08-27 09:37:30 -07:00
Paolo D'Amico
627d493817
SAML support (#5681) 2021-08-27 07:20:49 -07:00
Karl-Aksel Puulmann
b2fe0868d7
Proposal: Set mutations_sync in client.py instead of docker config (#5748)
This avoids weird divergence with prod that we need in ee tests but don't
want in e.g. plugin server tests or while developing.
2021-08-26 20:32:01 -07:00
Karl-Aksel Puulmann
0d5df5d3ba
Hotfix: Use materialized columns on cloud (#5753)
This was broken since default_kind was different on Distributed tables
on cloud
2021-08-26 21:29:00 +03:00
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
Michael Matloka
84dc2b0324
Rework SessionsPlayerButton and clean up Sessions UI (#5745)
* Refactor `PersonModal` and clean related components up a little

* Improve footer button conditions

* Remove unused vars

* Clean up session recordings table

* Rework `SessionsPlayerButton`

* Fix color of play button for viewed recordings

* Fix typing issue

* Fix tests

* Update Sessions.cy-spec.js

* Address feedback

* Simplify button styles

* Add tooltip
2021-08-26 19:17:30 +02:00
Karl-Aksel Puulmann
10a26d3e17
Automatically create materialized properties (#5744)
* Avoid naming collisions when materializing columns

1. Prefix person properties differently. Mixing them up can break
ambigious column issues
2. When name already exists, suffix with random junk :)

* Implement analyze.py

* Add `suggested_columns_to_materialize`

* Add code to backfill a materialized column

* Add tests for backfilling data

* Cleanup

* Add tests for analyze

* WIP: Crontab for materializing columns

* Nooped task for materializing properties

* Use mutations_sync=0 for column tests

* Add comment
2021-08-26 18:48:57 +03: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
James Greenhill
b9dc2d9540
Include users.xml config for dev/test clickhouse instance (#5732) 2021-08-25 01:47:15 +00:00
Eric Duong
7b33153f44
add order clause and test (#5722) 2021-08-24 16:39:51 +00:00
Neil Kakkar
8da25427d5
Add Path Timings (#5693) 2021-08-24 15:22:16 +01: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
9ba4986688
Fix behavior for is_set/is_not_set operator behavior on materialized columns (#5707)
Given that the extracted value is '' if value is not present we need to
leverage that.
2021-08-24 11:58:05 +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
Michael Matloka
6e77872cb1
Fix formula + breakdown combination (#5674)
* Add a test case for the problem

* Fix test case

* Fix problem

* Remove debug line

* Move quirk comment to Python-only
2021-08-23 13:16:19 +00:00
Eric Duong
04b751ebd9
Path step limit param (#5675)
* add step limit param

* step limit test

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-08-23 11:53:44 +00:00
Karl-Aksel Puulmann
fe594c4350
Clean up DebugCHQueries viewset (#5685) 2021-08-23 12:17:12 +02: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
Eric Duong
06c5c6f7a4
New Paths Query (#5646)
* initial implementation

* debug some tests and revert format to original

* some minor cleanup

* add screen handling

* start point handling

* improve indexing so multiple sessions by the same user are handled properly

* all tests passing

* fix type

* fix types

* change types

* more types

* rename base paths

* upgrade start point functionality

* assertEquals, remove inequality

* Revert "assertEquals, remove inequality"

This reverts commit 5eb229fef7.

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-08-20 14:33:21 -04:00
Paolo D'Amico
4afe5999bb
Auth updates & fix login as (#5670) 2021-08-20 10:01:33 -07: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
Michael Matloka
420d8000c1
Support href/text element filters (#5654)
* Fix `icontains` and support `href/`text` element filters

* Test `is_set`/`is_not_set` too

* Require newer `flake8` to support Py 3.8 walrus operator

* Better handle empty mutlivalue operators and support doublequotes

* Polish all element filtering cases

* Roll back general `icontains` fix

* Make minor improvements
2021-08-20 13:53:15 +02:00
Michael Matloka
e590129771
Fix icontains in ClickHouse (#5657) 2021-08-20 10:46:19 +02:00
Neil Kakkar
b484d34c90
Remove unused breakdown query variables (#5655) 2021-08-19 14:04:06 +00:00
Karl-Aksel Puulmann
0f58482a66
Handle denormalized properties everywhere* (#5635)
* WIP: port process_math to support materialized columns

* Add skipped test showing trend breakdowns dont use materialized columns

* Simplify testing and test&fix math property aggregation w/ materialized columns

* Add (failing) test for filtering with materialized action props

* Add test around materialized property filtering

* Refactor entity.math materialization impl

* Make trends breakdowns work with materialized columns

* Simplify process_math further

* Handle denormalized properties in format_action_filter for step.properties

Note the following files all called this method:
ee/clickhouse/views/events.py
ee/clickhouse/views/actions.py
ee/clickhouse/queries/trends/util.py
ee/clickhouse/queries/trends/lifecycle.py
ee/clickhouse/queries/trends/breakdown.py
ee/clickhouse/queries/funnels/base.py
ee/clickhouse/queries/sessions/util.py
ee/clickhouse/queries/clickhouse_stickiness.py
ee/clickhouse/queries/clickhouse_retention.py
ee/clickhouse/models/cohort.py

I verified all of them are OK since they query events table directly
with the passed filter

* Handle materialized $current_url in action step filtering

* Remove now unneeded clause

* Update test helper

* Allow denormalized props for filtering with breakdowns

* Allow denormalized props for filtering with lifecycle

* Allow denormalized props for some views

* Fix entity math yet again

* Query materialized columns in insights > sessions

* Handle breakdown edge case

* Allow denormalized props for more views

* PR feedback

* reformat
2021-08-19 16:09:40 +03:00
Karl-Aksel Puulmann
8b0b4bdf0f
Account for entity properties in stickiness feature (#5641)
Closes https://github.com/PostHog/posthog/issues/5639
2021-08-19 13:21:56 +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
Michael Matloka
d225d6ef8e
Add support for cohort-based cohorts (#5632)
* Add test cases for calculation of cohort-based cohorts

* Add cyclic dependency test

* Add support for cohort-based cohorts

* Reraise error in `calculate_people_ch` to fail loudly

* Use feedback

* Update `test_error_while_calculating`

* Move CH test case to CH suite

* Fix funnels and code formatting
2021-08-19 10:59:03 +02:00
Karl-Aksel Puulmann
44ca474897
Wrap client err before sending to statsd (#5649)
This makes statsd stats more useful on query errors
2021-08-19 10:54:34 +02: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
59c7efdebe
Migrate person_distinct_id table to CollapsingMergeTree (#5563)
* WIP: Migration to migrate person_distinct_id to CollapsingMergeTree

* Improve migrations

* Another attempt at migration

Using nullable otherwise it defaults without the default 😅

* Linter approved

* Update test code

* Fix testing issues
2021-08-18 17:25:02 +03:00
Michael Matloka
49c8ec58b0
Add "KEEP CLICKHOUSE-SERVER VERSION IN SYNC" comment (#5623) 2021-08-17 21:54:47 +02:00
Eric Duong
c79c270f5f
Cumulative person bug (#5572)
* add test and only handle interval if it's non cumulative

* add cumulative to tests that have specific date range
2021-08-17 15:13:24 -04: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