0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 09:16:49 +01:00
Commit Graph

1003 Commits

Author SHA1 Message Date
Paolo D'Amico
87e91e1352
Remove legacy sessions (#7401)
Co-authored-by: Rick Marron <rcmarron@gmail.com>
2021-11-29 21:11:10 -08:00
Rick Marron
fd150761ec
Materialize has_full_snapshot in session_recording_events (#7281)
* materialize has_full_snapshot

* add basic backfill command

* some clean up

* bug fix

* use comment function

* remove unneeded column check

* add to test for get_materialized_columns

* update test

* ClickhouseDestroyTablesMixin resets session_recording_events

* remove backfill command
2021-11-29 16:18:08 -08:00
Yakko Majuri
aedb28f12a
support uuid in event payloads (#7226)
* support uuid in payloads

* typing shenanigans

* add statsd metric
2021-11-29 13:12:51 +00:00
Karl-Aksel Puulmann
065947877e
Groups: Make test_account_filters work with groups (sessions, lifecycle support) (#7387)
* Extract common subquery into a variable

* BE: handle group properties in more cases

* Add tests for lifecycle and sessions query changes

* Better docs

* Stable date range
2021-11-29 14:41:10 +02:00
Paul D'Ambra
3ceb234e37
938 wire in the FE for multi property breakdown funnels (#7353)
* wip

* normalise to breakdown and breakdowns on the way out of the API

* read from breakdowns or breakdown property of filters

* wip

* wip

* delete a console.log

* remove console.log and speculative multi breakdown changes

* remove empty test

* remove console log

* more tidying

* more tidying

* more tidying

* simplify funnel logic slightly

* a test for the data transformations with no breakdown

* can test data transformation with a single property breakdown

* keep expanding the test to see why multi prop doesn't display

* don't throw key error if there is no breakdown property to pop from the multi property API response

* funnel step table can detect breakdown without relying on filter

* try to highlight the differences in the paths through TaxonomicBreakdownFilter

* better behaviour when adding and removing multi property breakdowns

* displays multi property breakdown in old style steps funnel views

* it is safe to always show breakdown in new vertical layout

* resolve multi property breakdown typehinting

* updates comment

* updates comment

* don't print breakdown value twice

* tooltip for long values and prettier pill

* convert tests to journeys_for

* fix multi breakdown helper

* better behaviour when navigating between trends and funnels

* Refactor the multi property breakdown helper to calm the mypy type checker down

* safer access to dict in multi property helper

* makes clean filters feature flags aware and keeps breakdown values when switching between trends and funnels

* test fix

* remove overly verbose data tests

* add some more specific tests to multi prop breakdown

* obey mypy

* remove the breakdown type from the backend which was causing serialization issues
2021-11-26 15:42:33 +00:00
Karl-Aksel Puulmann
82bb4797a5
Groups: Hide some property definitions from the API (#7328)
* Hide some property definitions from the API

https://github.com/PostHog/posthog/issues/7126

* Update the test
2021-11-25 14:17:57 +02:00
Karl-Aksel Puulmann
55bf75a40a
Make KAFKA_EVENTS_PLUGIN_INGESTION_TOPIC configurable (#7349)
This is for razorpay - they're planning to hook into this with spark
2021-11-25 11:47:20 +01:00
Neil Kakkar
12a2804ee9
Make cohorts filtering with funnels work again (#7324)
* Make cohorts filtering with funnels work again

* rm unused import
2021-11-24 13:34:25 +00:00
Eric Duong
976e49053a
[groups persons] Funnels groups persons query backend 2 (#7194)
* working for unique_groups math

* fix types

* add null check

* update snapshots

* update payload

* update snapshots

* use constructor

* adjust queries

* introduce base class

* consolidate querying

* shared serializer and typed

* sort imports

* snapshots

* typing

* change name

* Add group model

```sql
BEGIN;
--
-- Create model Group
--
CREATE TABLE "posthog_group" ("id" serial NOT NULL PRIMARY KEY, "group_key" varchar(400) NOT NULL, "group_type_index" integer NOT NULL, "group_properties" jsonb NOT NULL, "created_at" timestamp with time zone NOT NULL, "properties_last_updated_at" jsonb NOT NULL, "properties_last_operation" jsonb NOT NULL, "version" bigint NOT NULL, "team_id" integer NOT NULL);
--
-- Create constraint unique team_id/group_key/group_type_index combo on model group
--
ALTER TABLE "posthog_group" ADD CONSTRAINT "unique team_id/group_key/group_type_index combo" UNIQUE ("team_id", "group_key", "group_type_index");
ALTER TABLE "posthog_group" ADD CONSTRAINT "posthog_group_team_id_b3aed896_fk_posthog_team_id" FOREIGN KEY ("team_id") REFERENCES "posthog_team" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "posthog_group_team_id_b3aed896" ON "posthog_group" ("team_id");
COMMIT;
```

* Remove a dead import

* Improve typing for groups

* Make groups updating more generic, avoid mutation

This simplifies using the same logic for groups

Note there's a behavioral change: We don't produce a new kafka message
if nothing has been updated anymore.

* Rename a function

* WIP: Handle group property updates

... by storing them in postgres

Uses identical pattern to person property updates, except we handle
first-seen case within updates as well.

* Get rid of boolean option

* WIP continued

* fetchGroup() and upsertGroup()

* Test more edge cases

* Add tests for upsertGroup() in properties-updater

* Rename to PropertyUpdateOperation

* Followup

* Solve typing issues

* changed implementation to use pg

* unusd

* update type

* update snapshots

* rename and remove inlining

* restore bad merge code

* adjust types

* add flag

* remove var

* misnamed

* change to uuid

* make sure to use string when passing result

* remove from columnoptimizer logic and have group join logic implemented by event query classes per insight

* add flag to funnel event query

* remove unnecessary logic

* typing

* working actors func

* fix typos

* remove unused func

* use serialized result

* wrong var

* use actors

* remove dead imports

* remove verbosity

* update snapshots

* typos

* remove signals

* remove plugin excess

* update typing

* clean up

* use actor func for all funnel persons

* types

* make sure limits are set

* remove functions

* fix limits

* funnel trends

* types

* indexing

* moved basic funnel tests

* unordered test

* remove duplicate test

* check ids

* more test adjustments

* sort

* change class names

* sort

* reformat

* change string to int

* remove duplicate

* update comment

* use actor result to paginate not serialized

* adjust tests after merging

* simplify typing

* don't import removed func

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2021-11-23 09:49:52 -05:00
Paul D'Ambra
a710279955
Person URLs in Funnels (#7287)
* don't add leading slash to absolute url with no protocol

* don't add a base uri in only one funnel instantiation - will probably break tests

* remove console logs

* every API verb normalises URLs
2021-11-23 12:25:20 +00:00
Karl-Aksel Puulmann
c7c42b1a64
Groups: feature flag support for aggregating by groups (#7202)
* Tiny rename

* Minor refactor

* Test on FeatureFlagMatcher

* Add a field to feature_flag indicating if aggregating by groups

* Use f-strings

* Handle property filter building for group property

* Rename is_person_query

* Add message

* Tests for property_to_Q changes

* Add tests for groups w/ rollout

* Add comment for my_flags

* Hook up decide with groups

* New test helper for snapshotting pg queries

* Add snapshot tests for feature flags

* More is_simple_flag tests

* Add decide endpoint tests

* move conftest for ee tests to work

* Fix typo

* conftest troubles
2021-11-23 13:18:28 +02:00
Rick Marron
2c417ed1e1
Use session_id in recordings query when possible (#7218)
* query for events with matching session_id if possible

* move test to clickhouse

* move event list to list instead of set for flaky test snapshot

* comment to clarify test
2021-11-22 13:23:08 -08:00
Paul D'Ambra
ab737dcf76
Moves a test to exercise the system under test from a more stable interface (#7263)
* original behaviour was to set breakdown_values regardless of if it was truthy

* add a test for the bug

* ensmallen the test case

* lift tested interface up a level
2021-11-22 20:49:29 +00:00
Karl-Aksel Puulmann
98a58648e2
Add benchmarks for session recording page (#7251) 2021-11-22 20:10:09 +00:00
Neil Kakkar
b76236e25b
Exclude action events from correlation results (#7258)
* Exclude action events from correlation results

* update snapshots

* make test specific
2021-11-22 16:20:30 +00:00
Paul D'Ambra
7881d1ca47
original behaviour was to set breakdown_values regardless of if it wa… (#7260)
* original behaviour was to set breakdown_values regardless of if it was truthy

* add a test for the bug

* ensmallen the test case
2021-11-22 15:37:36 +00:00
Paul D'Ambra
c4bc7d7193
Multi property breakdown for person and event queries on Funnels (#7074)
* implement multi property breakdown as an array from the spike

* correct type hint on method

* really resolve the conflict

* don't break groups

* refactor test assertions for breakdown cases

* adds a test to prove that funnels can receive a string and not an array

* protect saved dashboards from multi property changeover

* WIP

* multi breakdown working with funnel step breakdown

* prove funnel step person breakdown works with multi property breakdown

* don't need to protect cached dashboards from multi property breakdowns when they can't be set from the UI

* capitalise keywords in SQL

* convert a single test to journey helper

* wip

* account for funnel step breakdown sometimes being an array sent as a string

* safer handling of funnel step breakdown

* convert a test

* revert commits that made things worse

* simpler handling of funnel step breakdown

* no need to change funnel step breakdown type hint

* update imports

* guard against integer properties

* compare funnel step breakdown differently now there are arrays involved

* look for strict intersection for funnel step breakdown

* update test snapshots

* need to set breakdown_values earlier in processing

* remove tests that cover speculative functionality

* update snapshot

* move setup of breakdown values back out of update_filters

* update snapshots

* remove a sql parameter that was never assigned to

* Update ee/clickhouse/models/test/test_property.py

Co-authored-by: Harry Waye <harry@posthog.com>

* Update ee/clickhouse/queries/funnels/base.py

Co-authored-by: Harry Waye <harry@posthog.com>

* address review comment to simplify reading json expressions for breakdown

* clarify why some uses of get_property_string_expr escape params before passing

* add keyword arguments for calls to getting property string expressions in funnels

* switch to keyword arguments in test helper method

* fix parameterised test

* add multi property materialized column tests

* introduce the shim to allow new API for breakdown properties

* can't remove the naive funnel step breakdown list detection

* move funnel step breakdown list handling

* better handling of numeric funnel step breakdown values

* update snapshots

Co-authored-by: Harry Waye <harry@posthog.com>
2021-11-22 11:20:01 +00:00
Paul D'Ambra
50b12d9bb7
Set debug, test, and primary_db env variables based on context (#7250)
* set debug, test, and primary_db env variables based on context

* remove unnecessary print

* also use pytest.ini for some tests run straight from pytest at the CLI
2021-11-20 17:18:39 +00:00
Harry Waye
60961ae78b
refactor(retention): Adds people_urls to retention trends response (#7184)
* Addtest for people_urls in retention trend response

* Add people_urls to retention trend response

* Run black formater

* sort imports

* Add default value for base_uri

* Let type be missing in EventPattern in tests

TypedDict is so rubbish in not allowing missing attributes 🤷

* fix typing

* refactor creation helper functions

* revert docker compose change
2021-11-19 10:25:58 +00:00
Rick Marron
9b9b12088a
Add 'active segments' to recording metadata endpoint (#7179)
* remove redundant query

* add include_active_segments query parameter to metadata endpoint

* bug fix

* type fixes

* respond to feedback

* add back in query snapshot
2021-11-18 11:32:10 -08:00
Eric Duong
7979f52e8a
[groups persons] API for returning groups based on trend results (#7144)
* working for unique_groups math

* fix types

* add null check

* update snapshots

* update payload

* update snapshots

* use constructor

* adjust queries

* introduce base class

* consolidate querying

* shared serializer and typed

* sort imports

* snapshots

* typing

* change name

* Add group model

```sql
BEGIN;
--
-- Create model Group
--
CREATE TABLE "posthog_group" ("id" serial NOT NULL PRIMARY KEY, "group_key" varchar(400) NOT NULL, "group_type_index" integer NOT NULL, "group_properties" jsonb NOT NULL, "created_at" timestamp with time zone NOT NULL, "properties_last_updated_at" jsonb NOT NULL, "properties_last_operation" jsonb NOT NULL, "version" bigint NOT NULL, "team_id" integer NOT NULL);
--
-- Create constraint unique team_id/group_key/group_type_index combo on model group
--
ALTER TABLE "posthog_group" ADD CONSTRAINT "unique team_id/group_key/group_type_index combo" UNIQUE ("team_id", "group_key", "group_type_index");
ALTER TABLE "posthog_group" ADD CONSTRAINT "posthog_group_team_id_b3aed896_fk_posthog_team_id" FOREIGN KEY ("team_id") REFERENCES "posthog_team" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "posthog_group_team_id_b3aed896" ON "posthog_group" ("team_id");
COMMIT;
```

* Remove a dead import

* Improve typing for groups

* Make groups updating more generic, avoid mutation

This simplifies using the same logic for groups

Note there's a behavioral change: We don't produce a new kafka message
if nothing has been updated anymore.

* Rename a function

* WIP: Handle group property updates

... by storing them in postgres

Uses identical pattern to person property updates, except we handle
first-seen case within updates as well.

* Get rid of boolean option

* WIP continued

* fetchGroup() and upsertGroup()

* Test more edge cases

* Add tests for upsertGroup() in properties-updater

* Rename to PropertyUpdateOperation

* Followup

* Solve typing issues

* changed implementation to use pg

* unusd

* update type

* update snapshots

* rename and remove inlining

* restore bad merge code

* adjust types

* add flag

* remove var

* misnamed

* change to uuid

* make sure to use string when passing result

* remove from columnoptimizer logic and have group join logic implemented by event query classes per insight

* remove unnecessary logic

* typing

* remove dead imports

* remove verbosity

* update snapshots

* typos

* remove signals

* remove plugin excess

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2021-11-18 11:58:48 -05:00
Harry Waye
5fdeef664f
dev(clickhouse): use prebuild arm64 clickhouse image (#7187)
I built this image a while ago, it's built with `yarn
arm64:build:clickhouse`, then I did a multipart build to copy only one
binary over and symlinking the various incantations (eg. server, client
etc) to keep the size down.
2021-11-18 08:43:43 +00:00
James Greenhill
df3c159522
Revert "Resurrect "Persons table schema migration" (#7199)" (#7200)
This reverts commit 5c1baa039b.
2021-11-17 23:28:39 -08:00
James Greenhill
5c1baa039b
Resurrect "Persons table schema migration" (#7199)
* Revert "Revert "Persons table schema migration (#6667)" (#7198)"

This reverts commit 311452bca5.

* CREATE TABLE AS

* ON CLUSTER

* prefix database
2021-11-17 23:09:11 -08:00
James Greenhill
311452bca5
Revert "Persons table schema migration (#6667)" (#7198)
This reverts commit 54f23498dc.
2021-11-17 22:29:38 -08:00
Yakko Majuri
54f23498dc
Persons table schema migration (#6667)
* WIP persons table schema migration

* add version to create_person

* test increased timeout

* Update ee/clickhouse/migrations/0019_person_table_version_column.py

* remove flaky kafka test

* format

* test a new approach - make this a non-large migration?

* Update ee/clickhouse/migrations/0021_person_table_version_column.py

* update
2021-11-17 21:19:50 -08:00
Tim Glaser
1d7477f512
Make project based permissioning an enterprise feature (#7163) 2021-11-17 08:08:31 -06:00
Karl-Aksel Puulmann
88db4845f4
Speed up stickiness queries & allow aggregating/filtering by groups (#7117)
* Refactor stickiness to have its own event_query

This will speed up queries significantly and allow for filtering by
group properties

* Use same event_query for stickiness people

* Minor cleanup

* Add tests (and missing file) to group filtering in stickiness

* Allow aggregating by groups in stickiness

* Show group property filters in FE for stickiness
2021-11-17 12:49:49 +02:00
Paul D'Ambra
626efb9490
Convert funnel tests to journey helper (#7111)
* convert the smallest of the funnel test files

* convert unorder funnel person test to journey for helper

* convert another file

* convert another file

* convert another file

* convert another file

* convert another file

* undelete snapshot files

* undelete snapshot files

* Revert "convert another file"

This reverts commit ef08511509.
2021-11-17 08:18:16 +00:00
Eric Duong
b7667f528f
fix issue when breaking down on group property and trying to return persons (#7145) 2021-11-16 09:39:48 +02:00
Rick Marron
c55e834bc1
include elements chain in recordings query when needed (#7147) 2021-11-15 18:35:45 -08:00
Rick Marron
60545e9c93
Recording query improvements (#7006)
* seperate clickhouse and postgres queries

* move to single query

* remove ununsed imports

* fix cohort + subquery issues

* some cleanup

* fix mypy issue

* fixes to query + tests

* add test for person and cohort properties

* remove cruft

* fix api tests

* Remove cohort + person prop filter from postgres

* move cohort and person property tests to clickhouse

* Filter down events

* typing fix

* fix test

* remove unneeded snapshot

* tests working with snapshots

* switch limit to property

* use materialized columns

* move to new distinct_id query

* add snapshots

* fix materialized column bug

* support cohort and person prop filters

* add person and cohort filtering

* remove cohort filtering from clickhouse

* small tweaks

* Lint fix
2021-11-15 16:15:37 -08:00
Harry Waye
a9e615cf45
feat(funnels): update frontend to use new people_urls in response (#7099)
* remove cohort comment

* feat(funnels): update frontend to use new people_urls in response

This change updates the `FunnelBarGraph` and `FunnelStepTable`
components to use the new `converted_people_url` and
`dropped_poeple_url` in the funnels response.

I need to check that this covers all the cases for funnels. I've only
added people urls for funnels of type step for ordered/unordered/strict
and haven't yet touched the time bins and conversion time funnel
endpoint variants.

* add /some/people/url/ to tests

* chore: add action back, update tests to reference it

* fix typing
2021-11-15 18:32:23 +00:00
Eric Duong
c7158fc895
[testing] Organize api tests (#7110)
* move tests

* update compare test

* use latest format

* typing
2021-11-15 13:12:18 -05:00
Karl-Aksel Puulmann
bf28d14aed
Add some benchmarks for stickiness (#7116)
* Add benchmarks for stickiness

* Don't require get_earliest_timestamp always

* Improve benchmark
2021-11-15 13:38:11 +02:00
Li Yi Yu
e0fe499a05
Groups pages table (#7039)
* wip

* get list of groups

* move backend endpoints

* frontend wip

* fix routes for groups

* add groups file

* try to fix tab nav

* fix groups query

* reformat results, add limits and offsets and next url

* move groups pages logic into own file

* fix and clean up tabs

* account for pagination and response reformatting

* lint fixes

* optional prev input

* typescript errors

* typescript fixes

* address feedback comments

* groups list logic test

* render properties expandable row

* fix test and lints

* prettier

* simplify table column title

* Fix a typing issue

* Use enum > boolean parameter

This makes what's going on more explicit

* Turn off pagination at the bottom of the table

* Rename table column

* Make pagination in groups work

Quite bugs fixed:
1. `previous` page was always shown, even if going into negative offsets
2. query_result could never be larger than `limit` with the code

* Cleanup code

* Make sidenav active under persons

* Use the correct query

* Add tests for pagination

* Update wording again

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2021-11-15 11:08:13 +02:00
Paul D'Ambra
3a323f361d
batch insert events in the test journey helper (#7108) 2021-11-12 19:33:55 +00:00
Eric Duong
48a6302f6f
[trends] Cumulative fix (#7041)
* cumulative dau for non breakdown

* breakdown case

* clean up test

* add trends request util

* use simpler test util

* types

* insight tests

* add snapshots

* black
2021-11-12 14:27:28 -05:00
Harry Waye
31b4919177
Make get people test ids sorted, remove flakiness (#7107)
I introduced some flakiness in introducing this, it seems indeterministic so need to sort before compare
2021-11-12 18:48:35 +00:00
Paul D'Ambra
19fd07dc87
Convert breakdown_cases to new test helper (#7098)
* adds a first draft of a test helper for clearer event setup in tests

* one spelling of journeys

* obey the type checker

* convert all of breakdown_cases to the new test helper

* Removes unused helper method
2021-11-12 18:33:20 +00:00
Eric Duong
f2108564e2
[trends] Fix compare persons onclick (#7075)
* fix frontend

* temp test
2021-11-12 13:12:23 -05:00
Harry Waye
2550fb26c6
feat(funnel-people): return converted/dropped people url in funnel (#7057)
* test(funnel-people): add tests for converted/dropped people urls

As per https://github.com/PostHog/posthog/issues/6935 we are adding urls
to responses to attempt to improve consistency between insight responses
and the people we display in the UI.

This simply adds tests for these urls, just for funnel step response
shape. The other two types of response will be handled separately.

* feat(funnel-people): return converted/dropped people url in funnel

Here I have simply added converted / dropped urls in the base funnel.
This touches both clickhouse and postgres functionality, so I will
probably add in tests for postgres also, or just disable to postgres.

It doesn't pass yet as there is an issue in that the order appears to be
ignored by the people endpoint.

* fix(funnels): actually use strict/unordered persons querying

Previously we were always using the standard `ClickhouseFunnelPersons`
class for retrieving people from the `/api/persons/funnel/` endpoint.
This change selects from the unordered and strict variants based on the
`funnel_order_type` setting.

Refers to https://github.com/PostHog/posthog/issues/7058 although there
is a frontend component to add that will truely resolve the issue.

* feat(funnel-people): add people urls for funnels with breakdown

In this I have also removed any changes from the non-clickhouse code.
Note that there are two places I've added the url generation code, one
in the `ClickhouseFunnelBase` and another in the `ClickhouseFunnel`

I think the former covers the unordered and strict cases, and the later
for the breakdown case. I think there are further test that I'll need to
add to validate e.g. if breakdown + strict work as expected.

* Fix people urls for unordered funnels + breakdown

* test: add test for strict breakdown with people urls

* make funnel response assertions not check people url equality

* fix typing

* fix tests

* remove new line in postgres funnel.py

* clear cache on insight test start

* no really, clear the cache

* remove flakiness from strict funnel test

* correct the unordered test

* use absolute uris

* use step.index not step.order

* remove out of date comment

* use step.index, not step.order

* use step.index, remove unordered funnels comment

* use journeys_for instead of create_events
2021-11-12 14:50:39 +00:00
Karl-Aksel Puulmann
6344db46a5
Validate group_type_index in properties/entities (#7087)
* Validate group_type_index in properties/entities

This avoids injection-like problems

* Update import path

* No circular import
2021-11-12 14:31:55 +02:00
Paul D'Ambra
1458f07163
Adds a first draft of a test helper for clearer event setup in tests (#7095)
* adds a first draft of a test helper for clearer event setup in tests

* one spelling of journeys

* obey the type checker
2021-11-12 12:26:07 +00:00
Neil Kakkar
13a93098cc
Enable different Property lists based on group type for Property Correlations (#7093)
* Enable different property lists based on group type

* fix test again
2021-11-12 11:45:31 +00:00
Neil Kakkar
7a5bb93e2a
Enable Correlations for Groups (#7056)
* enable correlations for groups

* address comments, refactor bits

* address comments
2021-11-12 11:32:55 +00:00
Eric Duong
d6d924af1d
[funnel] remove funnel persons on data return (#7044)
* remove funnel persons on data return

* remove person checks

* update tests

* remove comment

* add comment

* snapshots
2021-11-11 13:19:20 -05:00
Paul D'Ambra
f319948b2e
Add test helper method (#7053)
* add test_helper_methods

* move all the tests where the properties are the same for all events to the journey helper

* compare funnel results without caring about person order

* spell words correcterly

* Revert "spell words correcterly"

This reverts commit befb83b183.

* Revert "compare funnel results without caring about person order"

This reverts commit 268927b8ba.

* correct types for test props
2021-11-11 13:34:13 +00:00
Neil Kakkar
200caa6b6a
Correlation Persons for properties (#7052)
* Introduce funnel correlation person properties endpoint

* add snapshots

* address comments
2021-11-11 11:31:14 +00:00
Eric Duong
e5503cfd26
remove changing timestamp (#7046) 2021-11-11 11:30:50 +00:00
Eric Duong
74777d1bee
missing indent (#7042) 2021-11-10 23:52:48 +00:00
Eric Duong
5d264b6c7d
[insights—persons] Trends person urls (#6966)
* basic backend implementation

* fix backend url formatting

* frontend

* provide params alongside url

* remove console log

* remove load function

* aggregate handling

* aggregate test

* update tests

* add pie handling

* type

* aggregate breakdown

* check jsonextract on properties

* make all tests work

* actionsbarvalue

* use new function

* remove url

* typing and cleanup

* use api.get

* typing

* cumulative

* add breakdown
2021-11-10 16:54:51 -05:00
Li Yi Yu
cd10555607
Groups property values (#6967)
* add groups property values

* update groups property tests

* newline

* fix

* update test

* python black

* clean up tests

* rename to endpoint in operator value select

* add empty property values test

* do not return in an array

* fix
2021-11-10 12:03:17 -05:00
Harry Waye
7989fd24b8
Revert "Revert "feat(correlation): use people_url to load people modal (#6992)" (#7029)" (#7032)
This reverts commit de15fcda3f.
2021-11-10 15:50:32 +00:00
Harry Waye
de15fcda3f
Revert "feat(correlation): use people_url to load people modal (#6992)" (#7029)
This reverts commit 7bca1b78c1.
2021-11-10 14:09:45 +00:00
Harry Waye
7bca1b78c1
feat(correlation): use people_url to load people modal (#6992)
* feat(correlation): use people_url to load people modal

This change adds a new method to the `personsModelLogic` to allow for
specifying a url to be used to retrieve people from. I've avoided
overloading the existing `loadPeople` and rather added a new one,
`lostPeopleFromUrl`.

Currenlty this is only being used by correlations, but the intention is
to extend it's usage to anywhere else that is performing drilldowns to
people from, for instance, the trends aggregation.

* add paycard back

* make labels look right

* remove unused code

* fix typing in test

* fix typing in personsModelLogic

* refactor to make eventUsageLogic work

* fix typing

* fix typing again

* remove some funnel stories

* get storybook working with paycard

* cleaned up the interface a little

* chore(correlation): use `api.get` for fetching people

This updates to use api.get, and also converts the returned uri from the
correlation endpoint to an absolut uri, instead of just an absolute
path.

The `api.get` method expects either an abolute uri, or a relative path.
I'd rather not use an relative path as it's not obvious what it should
be relative to.

* fix tests

* make storybook uris absolute
2021-11-10 12:54:48 +00:00
Neil Kakkar
62af72bf22
Paths filtering by Groups backend (#7008)
* Paths filtering by groups backend

* update correlation tests, now that CTEs are included in sqls

* use decorator for materialising to ensure clean up happens

* cleanup offending tests
2021-11-10 09:47:02 +00:00
Harry Waye
d8e1799ed1
feat(correlations): add people by property to correlation response (#6951)
* feat(correlation): add people drill down urls for event correlation

This change simply adds urls in the response of the correlation endpoint
for each correlation returned. Note that this only adds support when
using correlation_type=events, as the
correlation_type=events_with_properties requires further changes that
I'd like the separate out to keep this PR small.

* feat(correlations): add people by property to correlation response

This commit covers the PROPERTIES case for making sure we return a url
that can be used to retrieve the people associated with a correlation,
either success or failure. This case is a completely different url than
for the events people endpoint as we are reusing the funnel people
endpoint, and filtering by "funnel_step_breakdown".

I'm uncertain if this is actually the correct url at this point in time,
as I have just attempted to copy what I have seen in the request from
the live running app.

* fix test

* Remove another param

* fix mypy typing

* Fix tests

* Add url response support for event_with_properties

* remove type assertion

* remove variable hack

* Remove funnel_steps

* use with_data and to_params

* Remove comment regarding complexity, it seems to pass the tests so...

* Add autocapture support for people url

* refactor people url construction a little

* remove properties attr for event people request

* fix if

* no really, fix if not None

* Remove _assert_never, mypy needs updating

* Fix no return mypy error

* Remove json.dumps
2021-11-09 12:10:40 +00:00
Karl-Aksel Puulmann
34264e697f
Log cohort recalculations on clickhouse (#6973)
* Log cohort recalculations on clickhouse

This should help debug both cohort-related data quality issues.

* Modify test query a bit
2021-11-09 12:36:58 +02:00
Neil Kakkar
bd5c74ef03
Funnel groups breakdown (#6944)
* Enable breakdowns

* update team

* clean up

* run all breakdown tests, address review comments
2021-11-09 09:12:17 +00:00
Neil Kakkar
82352c4a62
Funnel Groups filtering (#6940)
* enable groups filtering

* rerun snapshots

* update team

* fix tests
2021-11-09 08:32:55 +00:00
Rick Marron
b78499d61a
Ingest window_id for recordings (#6806)
* add window-id to ingestion

* move window_id into snapshot data

* Add tests

* add window_id to snapshot_data only if included in the event

* add window_id to session_recording_events table

* revert ph-js downgrade

* fix data generator

* remove partition change

* update window_id defaults for tests

* missed one window_id default

* rename migration for conflict
2021-11-08 14:29:54 -08:00
Eric Duong
06bdd1d486
[local testing] Track executed migrations when locally testing (#6915)
* experiment with saving a migrations table

* change flow

* change names

* missing var
2021-11-08 10:40:05 -05:00
Karl-Aksel Puulmann
a39596c092
Groups: Use materialized columns for groups (#6938)
* Migration to use materialized columns for groups

Workaround for https://github.com/PostHog/posthog/issues/6422

* Use groups materialized columns in queries

* Update mat column creation tests

* Simplify aggregation_target_field

* Fix migration

* Update snapshots
2021-11-08 15:49:39 +02:00
Neil Kakkar
d2fe491bfc
Funnel Groups: Rename person_id to aggregation_target (#6939)
* smallest change to make aggregation work

* address comments

* add snapshot

* move function to groups model

* update funnel snapshot

* rename person_id to aggregation_target

* update snapshots as well

* dont support persons query mods for now

* update snapshot

* make array orders deterministic
2021-11-08 14:45:13 +02:00
Neil Kakkar
a400296266
Backend: Groups Aggregation on Funnels (#6937)
* smallest change to make aggregation work
* use team in filter
2021-11-08 11:29:56 +00:00
Karl-Aksel Puulmann
0353b2f26f
BE (Groups/Trends): Testing follow-up PR (#6923)
* Improve process_math

* Add test for overlapping group keys

* Improve event query tests

* Add test for filtering by person properties together with groups

* Avoid flaky tests due to cohort_id changing

* Update queries and snapshots
2021-11-08 10:52:10 +02:00
Karl-Aksel Puulmann
7493f76802
BE (Groups/Retention): Support aggregating by groups (#6922)
* Add groups stuff

* Rename column from person_id to `target` in retention queries

No behavioral change, preparing for groups work :)

* Remove dead if statement

* WIP: Retention aggregation by groups

* Handle aggregation by groups in retention

Also handles the case where not every event has a property defined

* Test groups validation mixin

* Reformat

* Improve test for aggregation in retention
2021-11-08 09:23:02 +02:00
Karl-Aksel Puulmann
d5d5fcd32b
WIP: Groups FE filtering (#6764)
* Add /api/projects/@current/groups/property_definitions

To load property definitions for groups

* Add routes for fetching group types

* FE: Group analytics feature flag

* FE: Group analytics base types for properties

* FE: Initial implementation of fetching logics

* add group tabs to filter

* make sure group properties populate and refactor things

* prettier

* disable unused vars

* allow indexing objects by number

* mount group properties logic

Co-authored-by: Li Yi Yu <li@posthog.com>
2021-11-05 10:21:28 -04:00
Karl-Aksel Puulmann
ea956fecae
Support filtering by group properties in retention (#6904) 2021-11-05 13:56:27 +02:00
Karl-Aksel Puulmann
42192e07c7
BE (Groups/Trends): Make breakdowns work with groups (#6899)
* Extract GroupsJoinQuery

* Add test for breakdown filtering

* Unify breakdown mixins

* Allow passing breakdown_type == 'group' with breakdown_group_type_index

* Allow breakdown by group props in trends

* Add tests for trends breakdown_props function on group breakdowns

* Solve common issues

* Output snapshot diff into console

* Clean up materialized columns after tests

* Add zero protection

* Solve test failure
2021-11-05 13:47:41 +02:00
Karl-Aksel Puulmann
fa79f8ea67
BE (Groups/Trends): Allow aggregating by groups (#6894)
* Type math in Entity

* Allow passing group_type_index from FE to BE

* Get a initial query running

* Add group value filter if aggregating by groups

* Add snapshot testing for trends queries

* isort

* Update tests

* Add test for column_optimizer

* Update ee/clickhouse/queries/trends/util.py

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-11-05 13:08:32 +02:00
Eric Duong
d423a3ad09
[proposal] suggestion for reducing runtimes (#6725)
* suggestion for reducing runtimes

* refactor tests ingestion

* django tests

* fix types

* add comment
2021-11-04 11:34:40 -04:00
Paul D'Ambra
28aca38e5b
Make the API safe to introduce multi-property breakdown (#6757)
* adds a test to prove that without any changes the API receives a string and returns one see #938

* put a guard in place so that funnel query can be shifted to arrays without affecting existing clients

* make checking for single property breakdowns safer

* sort imports

* sort imports

* reformat files

* Revert "reformat files"

This reverts commit 58530f134f191d53b927abe6fb6f5d2d384cb255.

* expand short variable names

* corrects a typo

* it wasn't a typo it was a logic error
2021-11-04 10:49:49 +00:00
Tim Glaser
0f7de25f33
Fix cohort creation from trends (#6636)
* Fix cohort creation from trends

* REVERT debug issue

* fix nit

* Revert "REVERT debug issue"

This reverts commit ea50db28ce.

* REVERT try debugging issue

* REVERT Try final

* Don't insert into clickhouse twice

* remove unused var

* debug

* fix and revert

* test mixin

* fix black

* fix

* Update ee/tasks/test/test_calculate_cohort.py

Co-authored-by: Michael Matloka <dev@twixes.com>

Co-authored-by: Michael Matloka <dev@twixes.com>
2021-11-04 11:46:08 +01:00
Karl-Aksel Puulmann
273228cdcf
BE: Allow filtering by group properties in trends (#6761)
* Add group type, group_type_index

* Raise an error when handling unsupported properties in CH

* Improve repr

* Fix is_superset function

This was previously broken - sorting and zipping doesn't really work for
this intent.

* Add group_type_index to analysis results

* Add `group_types_to_query`

* Minor typing fixes

* Create groups tables in tests

* Simple first filter by groups query

* isort

* Use snapshot testing in event_query tests, add test for groups
2021-11-03 20:43:22 +02:00
Neil Kakkar
5963a93d15
Introduce pay gate for correlation analysis (#6720)
Co-authored-by: Marcus Hyett (PostHog) <85295485+marcushyett-ph@users.noreply.github.com>
Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-11-03 11:41:16 -06:00
Harry Waye
b7c898d23e
feat(correlation): load exclude properties from team settings (#6715)
* feat(correlation): add team wide person property exclusion list

This change just adds the exclusion list to the `Team` model and checks
that it can be updated. Separately we can:

 1. add interface for the Project page to display
 2. pull and update this list from the funnels correlation page

NOTE: We don't perform any validation on the structure, :fingerscrossed:
this won't be an issue. Alternative would be to use ArrayField, but use
of JSONField is consistent with other fields.

* test(correlation): add test checking exclude properties pulled from team

* feat(correlation): load exclude properties from team settings

Previously we were loading exclude properties from local storage, so we
would not be sharing the exclusion list between users. This change
simply plugs the `excludePropertyNames` into the `teamLogic` for the
purpose of persisting and loading the values.

* use [teamLogic.actionTypes.loadCurrentTeamSuccess]

* get tests passing

* switch frontend to using `correlation_config`

* refactor: use Team.correlation_config for persistence

* add project settings for correlation

* fix lint

* ensure excluded properties are saved to project config

* Add default excluded properties

* format

* make propertyCorrelations not null

* ensure excluded property names config is unique

* rename excludeProperty to excludePropertyFromProject

* update var names

* change to targetProperties

* remove null special casing

* update to filter client side on exclude from project clicked

* update test name to reflect new functionality

* fix tests
2021-11-02 11:12:13 +00:00
Karl-Aksel Puulmann
8ac9c590ec
Proposal: Use unique topic names for kafka in test (#6746)
Without this, to run plugin-server tests you need to reset all
containers every time since otherwise both test- and non-test clickhouse
would attempt to read from the same topic.
2021-11-01 11:42:56 +02:00
Neil Kakkar
283319adfc
Modify query to not use properties for autocapture (#6711)
* modify query to not use properties for autocapture

* address comments

* add benchmark test to check if worth materialising
2021-10-28 13:12:26 +01:00
Michael Matloka
b0aa8f0c91
Migrate cohort-related logics to be project-based (#6683)
* Migrate cohort-related logics to be project-based

* Fix `cohortsDetail`

* Remove `teamId` param from `determineEndpoint` methods
2021-10-28 13:29:53 +02:00
Alex Gyujin Kim
32b828e26d
Next url dates broken on api/events endpoint + missing order_by on CH (#6681)
* fix next url

* remove unused import

* make faster test

* remove irrelevant file

* remove unnecessary order param
2021-10-28 09:10:34 +02:00
Tim Glaser
97b85b76a4
Revert "Update the docker-compose dev environment to reflect prod better (include pgbouncer) (#6558)" (#6692) 2021-10-27 05:54:48 -07:00
Eric Duong
df583d528b
6331 pie chart persons bug (#6642)
* backend fixes and test

* add breakdown value to pie chart

* adjust test

* fix faulty test

* fill param

* fix formula tests

* more date passing

* more cleanup

* all tests working

* make test data explicit and add better checks

* support both ee and postgres

* length checks
2021-10-26 14:53:34 -04:00
Neil Kakkar
850075979c
Add event with properties benchmark (#6666) 2021-10-26 17:19:24 +01:00
Neil Kakkar
a95e47a80f
Enable exclusions on all kinds of correlations (#6654)
* Enable exclusions on all kinds of correlations

* rm action

* address comment
2021-10-26 13:56:30 +01:00
Tim Glaser
9cc430c190
Fix before url in events api (#6639)
* Fix before url in events api

* Fix clickhosue
2021-10-26 11:00:14 +02:00
James Greenhill
0937f0b0df
Add retries to kafka producer to mitigate event loss (#6638) 2021-10-25 22:40:32 -07:00
Rick Marron
f2076f4008
Paginate recording compression (#6563)
* paginate recording compression

* some tests

* more accurate duration calculation

* add tests and types

* tons of decompression fixes

* rename test file to avoid conflict

* move decompression to helper

* add test for helper

* type fix

* rename method

* simplify paginated decomression

* handle case where offset exceeds length

* clean up

* test fixes

* clean up on aisle 12

* Add surrounding object for metadata response
2021-10-25 12:59:54 -07:00
Michael Matloka
710a21a74e
Don't return/show forbidden projects at all (#6622)
* Don't return/show forbidden projects at all

* Fix missing `lookup_field`
2021-10-25 16:17:53 +02:00
Michael Matloka
d5d497f11f
Migrate dashboard-related logics to be project-based (#6623)
* Migrate dashboard-related logics to be project-based

* Update test_personal_api_keys.py

* Update dashboard.py

* Update test_dashboard.py

* Make mypy happy
2021-10-25 16:16:55 +02:00
Neil Kakkar
6ab4b2673a
Backend support for autocapture elements chain in Correlations (#6627)
* Backend support for autocapture elements chain properties

* address some comments
2021-10-25 13:21:57 +01:00
Karl-Aksel Puulmann
cef2af5e4c
Group analytics: Initial schema (#6462)
* Add table for group_type_mapping

* Remove materialized columns from events table schema

These are not used and not needed w/ new mat columns work

* WIP: Migration to add group analytics columns

* Remove event table changes temporarily
2021-10-25 15:05:58 +03:00
Michael Matloka
165ffcaffb
Migrate event-related logics to be project-based (#6566)
* Instrument legacy endpoint debugging

* Add `currentTeamId` to `teamLogic`

* Add logics utils

* Update annotations endpoint in the frontend

* Limit legacy endpoint logging to DEBUG

* Fix `annotationsTableLogic` usage

* Update test_annotation.py

* Add `test_deleting_annotation_of_other_team_prevented`

* Comment out debug code

* Migrate actions-related code to project-based approach

* Fix `infiniteTestLogic`

* Rework approach

* Remove redundant lines

* Fix mixup

* Fix non-logged-in scenes

* Fix Python cast

* Align approach to `teamLogic`-based

* Fix logic tests

* Clean up code

* Fix stupid omission

* Restore `props` in `connect`s

* Fix capitalization

* Fix action creation

* Fix `ActionEdit` props type

* Migrate events-related code to project-based approach

* Remove `MOCK_ORGANIZATION_ID`

* Update sessionsPlayLogic.test.ts

* Fix logic tests

* Fix duplicate imports

* Reduce duplication in URL test instrumentation

* Update API interception paths in tests

* Fix `Person.cy-spec.js`

* Add comments in `posthog/api/__init__.py`

* reduce test noise

* Update infiniteListLogic.ts

* Simplify `teamLogic` seeding

* Simplify `teamLogic` seeding better

* Fix `organizationLogic` tests

* Migrate feature flags-related logics to be project-based (#6603)

* Migrate feature flags-related logics to be project-based

* Add comment

* Migrate insight-related logics to be project-based (#6574)

* Migrate insight-related logics to be project-based

* Migrate over the rest and fix logic tests

* Update funnelLogic.ts

* Fix URL formatting in tests

* Update dashboardLogic.tsx

* Remove now redundant `initTeamLogic`

* Add tracking comments

Co-authored-by: Marius Andra <marius.andra@gmail.com>
2021-10-22 18:32:58 +02:00
Eric Duong
1f143d109e
Path cleaning integration (#6488)
* initial refactoring

* popup UI

* refactor path cleaning logic

* add nullable

* all ui working

* fix migration

* use regex replacement from team object

* add flag

* add switch

* fix type

* fix type

* UI update

* restore removed arg

* add local path cleaning filters to api

* add test for local path filters

* working new UI

* reduced repeated code

* fix numbering

* minor refactoring

* update copy

* add under advanced features

* address comments, minor cleanup

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-10-22 11:51:45 -04:00
Michael Matloka
8ca4c26c4e
Migrate action-related and some insight-related logics to be project-based (#6464)
* Instrument legacy endpoint debugging

* Add `currentTeamId` to `teamLogic`

* Add logics utils

* Update annotations endpoint in the frontend

* Limit legacy endpoint logging to DEBUG

* Fix `annotationsTableLogic` usage

* Update test_annotation.py

* Add `test_deleting_annotation_of_other_team_prevented`

* Comment out debug code

* Migrate actions-related code to project-based approach

* Fix `infiniteTestLogic`

* Rework approach

* Remove redundant lines

* Fix mixup

* Fix non-logged-in scenes

* Fix Python cast

* Align approach to `teamLogic`-based

* Fix logic tests

* Clean up code

* Fix stupid omission

* Restore `props` in `connect`s

* Fix capitalization

* Fix action creation

* Fix `ActionEdit` props type

* Fix duplicate imports

* Update infiniteListLogic.ts

* Update ActionsTable.tsx

* Fix link to new action in Toolbar
2021-10-22 15:42:11 +02:00
Neil Kakkar
d92ca6ee44
Enable persons modal for properties correlation (#6611)
* Enable persons modal for properties correlation

* adjust header

* fix typings
2021-10-22 14:37:17 +01:00
Neil Kakkar
c87aae2338
Backend for querying persons given an event (#6588)
* Backend for querying persons given an event

* address comments

* add test
2021-10-21 13:40:19 +01:00
Sam Winslow
62cc72684e
Capture exception if organization user is not found (#6528) 2021-10-20 01:18:51 +01:00
James Greenhill
721657ff90
Update the docker-compose dev environment to reflect prod better (include pgbouncer) (#6558)
* Update the docker-compose dev environment to reflect prod better (include pgbouncer)

* update backend tests to use PGB
2021-10-19 12:41:58 -07:00
Harry Waye
43de375d44
fix(correlation): fix recursion limit error if no steps provided (#6548)
Previously we would attempt to generate a response even though there
were no steps. There appears to be some code paths that blow up if this
happens, so instead we return as soon as we can in this case. This
appears to be the behaviour elsewhere also.

This resolves the sentry error found here:
https://sentry.io/organizations/posthog/issues/2718768248/
2021-10-19 14:38:36 +00:00
Neil Kakkar
f85da24f49
Add backend for correlation event properties (#6539)
* Add backend for event properties

* address comments
2021-10-19 13:55:54 +00:00
Paolo D'Amico
4248d52800
Paths pay gate (#6463)
* create new advanced feature

* remove all advanced features

* pay card basic

* dismiss pay gate

* pay card story component

* address feedback

* restricted paths step too
2021-10-18 09:17:54 +02:00
James Greenhill
0c77788e46
Fix EnvVar for MATERIALIZED_COLUMNS_ENABLED (#6503) 2021-10-17 16:42:37 +00:00
James Greenhill
507015b95e
Add Env var switch for Materialized Columns (#6498)
* Add Env var switch for Materialized Columns

* Disable Mat Cols for now

* false -> 0
2021-10-17 07:49:45 -07:00
Karl-Aksel Puulmann
e098219f1b
Allow filtering /api/events by cohort filter (#6471)
This broke due to the cohort refactoring - query constructed did not
have access to `person_id`

Closes https://github.com/PostHog/posthog/issues/6427
2021-10-15 14:25:40 +03:00
Alex Gyujin Kim
074d633c53
Make Sessions Recording faster!! (#6270)
* paginate session recording events api

* code quality

* don't rerender replayer every time events get loaded

* refactor session recordings, make it backwards compatible, add bunch of tests

* move limit and offset to after decompress

* change limit

* add caching of recording

* add duration

* fix a few tests

* fix api tests

* add partial chunk test

* fix default limit test

* code quality

* typing

* fix backend tests

* mypy fixes and signature

* remove circular dependency

* mypy and sessionsplaylogic tests

* fix migration

* make single migration

* revert mypy typing

* remove require react resolve

* fix loading state to persist across multi chunks and add test'

* cleanup

* duration to ms

* fix duration tests

* remove require react resolve

* fix test

* bump rrweb player

* change cache behavior plus more

* fix frontend tests and make duration calculation more robust

* fix timestamp in ms bug in tests

* fix duration 0 test

* fix compatibility with rrweb-player

* update lockfile

* yarn unlink

* resolve kea-test-utils changes

* another one

* remove caching for now (leave as todo) and change limit to 100
2021-10-15 02:41:47 +00:00
Eric Duong
276200429d
Paths: API for regex replacement (#6397)
* api for regex replacement

* typing

* change to None for default
2021-10-14 13:15:01 -04:00
Sam Winslow
95746b9bce
Send event for license usage by organization (#6333) 2021-10-14 12:42:14 -04:00
Tim Glaser
fbb805be8f
Add scale plan in license.py (#6416) 2021-10-14 15:13:37 +03:00
Karl-Aksel Puulmann
457e151f58
Push person predicates down (#6346)
* Refactor column_optimizer to work differently

* WIP: Use counter over set

* Handle person filters in person query

* Remove a dead argument

* Use enum over parameter for determining behavior

* Allow excluding person properties mode when handled in person query

* Fix _get_person_query type

* Use correct table for funnel_event_query

* Remove unneeded override

* Add extra typing

* Filter by entity.properties in person query for trends

* Handle error 184 due to naming clash

* Better default for prop_filter_json_extract

* Update column_optimizer tests for Counter

* Handle person_props as extra_fields

* Handle breakdowns and person property filter pushdown

* Transform values correctly

* Simplify get_entity_filtering_params

* Fix funnel correlations

* Solve caching issues in trend people queries

* Remove @skip test

* Add syrupy tests for parse_prop_clauses

Can update these via --snapshot-update

* Add snapshot tests for person queries

* Add a few notes

* Update test to avoid collision

* Kill dead code

* Handle PR comments

* Update ee/clickhouse/queries/person_query.py

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-10-13 14:00:47 +00:00
Michael Matloka
ec0f7ef880
Add slug field to Organization (#6395)
* Add `slug` fields to `Organization` and `Team`

* Expose slugs to user

* Add slug autogeneration for new orgs/projects

* Improve slug UX

* Remove slug from settings

* Update org/team instance creation plus add tests

* Only require project slug to be unique for org, not globally

* Fix `get_prep_value`

* Test organization slugification

* Deslugify `Team`

* Clean up changes

* Update test_user.py

* Apply suggestions from code review

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Random 4 letter suffixes for the win

* Fix import

* Ignore `test_migrations_are_null`

* Fix `RunSQL` query being empty

* Fix `generate_random_short_suffix` testing

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-10-13 14:09:40 +02:00
Karl-Aksel Puulmann
b5e00e44da
Skip a flaky funnel test (#6379)
This seems to be semi-consistently failing locally for me and
inconsistently on CI. The cause is unknown - debugging locally, this
seems more of a query correctness issue than a test data incomplete
issue.
2021-10-12 10:57:34 +03:00
Karl-Aksel Puulmann
becaee3abd
Add benchmarks for trends + actions (#6354) 2021-10-12 10:18:23 +03:00
Rick Marron
63d127df13
Filter session recordings (#6162)
* fix bug where session recording is split by new distinct_id

* fix query bug to allow distinct_id clause

* Basic query filtering by events on clickhouse

* add duration filtering

* Add multiple action/event filters

* Move to using person_id + optimize query

* add postgres support and querying on person_id

* move back to distinct_ids

* remove lots of duplicated logic

* Add pagination to backend

* Pagination

* Add duration and date filter

* Use person header is list view

* type fixes

* bug fix

* bugs and tests

* test fixes

* style filters

* logic tests

* Add another test for team leakage

* fix flaky test

* UX changes

* UX tweaks

* auto focus filter box on open

* add test for recording viewed change

* move duration filter to using a tested logic

* move to clsx

* add debounce breakpoint

* Small style change

* fix debounce

* fix breakpoint

* move test to defaultAPIMocks (merging changes)

* react to url change
2021-10-11 13:15:05 -07:00
Michael Matloka
e97c20ad33
Purge PLUGIN_SERVER_ACTION_MATCHING flag (#6358)
* Remove `PLUGIN_SERVER_ACTION_MATCHING` flag

* Fix action bug

* Try to fix mocking
2021-10-11 21:33:48 +02:00
Harry Waye
fe07bc1d9b
dev(arm): use x86 kafka image even on arm (#6357)
We'll be using qemu that ships with docker for mac. I'd updated this at
the same time as zookeeper but obviously never removed the kafka
container from before somehow.
2021-10-11 15:01:48 +00:00
Neil Kakkar
10ae7ca6e3
Enable running correlations over all properties and respect conversio… (#6352)
* Enable running correlations over all properties and respect conversion window

* address comments
2021-10-11 11:13:26 +00:00
Yakko Majuri
3ec5cc0d3b
Capture Endpoint Refactor (#6230)
* WIP refactor capture endpoint + DLQ

* fix typing

* more testing

* add comments

* format

* refactor get_event into smaller modular functions

* move functions to utils

* add typing

* fixes + more tests

* add test for extract_data_from_request util

* fix typing

* remove comment

* format

* remove dlq code

* determine_team_from_request -> get_team

* extract_data_from_request -> get_data

* minor fixes

* extract get_distinct_id, parse_event

* add test

* Add dead letter queue to capture endpoint (#6311)

* Add dead letter queue to capture endpoint

This reverts commit 34e7441493.

* try except kafka produce

* format

* statsd + log for dlq produce error

* fix types

* fix

* fix

* legit fix

* ignore type

* handle now timestamp

* remove test code
2021-10-11 10:38:45 +00:00
Neil Kakkar
7ff7c5b7cc
Update param name in benchmarks (#6324) 2021-10-08 14:44:00 +03:00
Neil Kakkar
d468ed32bf
Discard low significance items, alter odds definition, mention skewed… (#6329)
* Discard low significance items, alter odds definition, mention skewed results

* add test for insignificance

* address comment
2021-10-08 11:27:50 +00:00
Karl-Aksel Puulmann
7461f90153
Simplify cohort filters (#6277)
* WIP: Create new property types for simplified cohorts

* Add documentation on simplified_cohort_filter_properties

* Handle static-cohort/precalculated-cohort property types

* Handle new property filters properly

* Add casting

* Test cohorts in more cases

* Fix a bug

* Fix benchmark simplifying

* Avoid redoing work every setup for benchmarks

* Update typing;

* Remove unneeded scope

* Add tests for simplifying and cohorts

* Roll more of "do we need to join persons table" behavior into ClickhousePersonQuery class

* Handle precalculated cohort logic in sessions

* Simplify event query

* More tests without any JSONExtract

* Simplify entity properties as well

* Improve docstring

* Add test for breakdown & precalculated cohorts

* Add test for filtering sessions by precalculated cohorts

* Reset unneeded change

* Update cohort

* Solve some typing issues

* Update benchmarking

* Fix cohort filtering tests

* Fix cohort tests

* Fix a caching issue

* Typecheck

* Handle exclusion filters
2021-10-08 10:51:11 +03:00
Karl-Aksel Puulmann
ef7f31c482
Simplify test accounts (#6221)
* Simplify filters code

* Simplify filters ASAP if filter is created

* Simplify route

* Remove simplification-specific logic from queries

* Remove recursion, update tests

* Pass team in more cases

* Update column optimizer specs

* Test simplify

* Update trends test

* Fix rebase fail
2021-10-07 23:14:35 +03:00
Neil Kakkar
899ad24722
Support multiple correlation properties (#6312)
* Support multiple correlation properties

* extensive comments, now that they get stripped at runtime

* rename funnel_correlation_values
2021-10-07 17:22:10 +01:00
Neil Kakkar
cfe9844a09
Add benchmarks for correlation (#6307)
* Add benchmarks for correlation
2021-10-07 14:12:56 +00:00
Neil Kakkar
8b2cc5d02e
Write few more tests for Correlation + ColumnOptimizer (#6309) 2021-10-07 13:29:16 +00:00
Neil Kakkar
823b3e7ec3
Correlation Analysis for Properties: Backend (#6305)
* Correlation Analysis for Properties

* clean typings

* address some comments

* use ClickhousePersonQuery
2021-10-07 12:24:25 +00:00
Yakko Majuri
7b50b0e35f
Events dead letter queue CH table (#6193)
* events dead letter queue CH table

* format

* update schemas

* also store raw payload

* better naming

* make table name more clear

* wip better testing

* remove unused imports

* remove kafka test

* prevent non null test from running on CH migrations

* add kafka testing

* minor tests cleanup

* test naive longer sleep

* make test end-to-end

* address review

* update ttl, format

* refactor delay func, address review
2021-10-07 08:30:13 +00:00
Harry Waye
f22532fb83
dev(docker): use arm builds of zookeeper and kafka, just for arm compose (#6302)
I've been getting lot's of errors with the qemu emulated x86 version.
I'm just changing the arm docker-compose as I don't want my issues with
local dev to affect others.
2021-10-07 10:04:15 +02:00
Harry Waye
50ee7b91f4
fix(correlation): add lower bounds for selected events (#6280)
* fix(correlation): ensure correlation partitioned by team

Previously if distinct_id's were the same between two teams, we'd end up
pulling in the event data between the teams.

* dev(tests): clear cache between partition calls

* fix(correlation): add lower bounds for selected events

Previously we would consider all events for correlation calculation. Now
we use the funnel `date_from` as the lower bounds.

* chore(correlation): exclude funnel steps

* chore(correlation): make sure cache is cleared before each test

* Update funnel success comment

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>

* fix: filter events by team_id

* chore(correlation): remove CTEs from correlation query

There seems to be an issue with the CTEs and production clickhouse, see
https://github.com/ClickHouse/ClickHouse/issues/29748

Instead of risking it, I'm just removing them.

* chore: update entities -> events for funnel step exclusion

* fix team_id = team_id issue

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-10-07 08:17:07 +01:00
Neil Kakkar
a59610e432
Use FunnelStep properly in Correlation Queries (#6289)
* two wrongs don't make a right

* give beginning timestamps as well
2021-10-06 15:34:19 +00:00
Neil Kakkar
7bfeb9d1b9
Add basic model for Correlation analysis on Funnels behind FF (#6258)
* Add basic model for Correlation analysis on Funnels behind FF

* make frontend ready for testing

* address comments

* prettier
2021-10-06 13:14:32 +01:00
Harry Waye
9887856c33
Implementation of diagnose event names (#6235)
* chore(diagnose): add a stub endpoint for event diagnosis

This adds an insight endpoint that takes a `target_entity` and returns
a list of events ordered by significance of a person reaching
`target_entity`

Followup PRs will add actual calculations but this should act as a
conversation piece around the structure of request and response, as well
as a stub from which UI development can start.

* play around to get mypy typings right

* Sort out test reponse structurea

* refactor: address CR comments

* feat(diagnose): add diagnose stubs for implementation

* feat(funnel): add event correlation calculation implementation

This adds to the `/api/projects/<team_id>/funnel/correlation` endpoint
an implementation that calculates the odds_ratios for each event that a
user that has been part of a funnel, successful or otherwise.

* chore(correlation): get query working

* refactor(correlation): move functions to Query methods
2021-10-06 11:08:16 +01:00
Li Yi Yu
27edb933e4
Revert "Always allow filtering on distinct id (#6264)" (#6271)
This reverts commit 03134f1d10.
2021-10-05 19:58:06 -04:00
Tim Glaser
03134f1d10
Always allow filtering on distinct id (#6264)
* Always allow filtering on distinct id

* fix

* fix

* remove accidentally commited test

* include table name

* add table specific because distinct_id doesn't exist on person table

Co-authored-by: eric <eeoneric@gmail.com>
2021-10-05 15:42:08 -04:00
Eric Duong
4e63d630ab
paths: Paths funnel post api better tests (#6266)
* make sure test handles as expected

* separate tests

* added api test for paths with funnel
2021-10-05 15:02:38 -04:00
Eric Duong
b5ed0b7221
paths: funnel-path date alignment and funnel path persons (#6236)
* make sure funnel and path dates are always aligned and add api handling for funnel filter persons

* use post instead of GET for paths

* parse label

* change type

* use post in test

* fix types

* test both get and post
2021-10-05 14:10:27 -04:00
Tim Glaser
e31d166d74
Don't count internal metrics for billing purposes (#6228) 2021-10-05 15:05:51 +03:00
Karl-Aksel Puulmann
fda8313be6
Use fixed benchmarking version (#6247)
This way adding new benchmarks/setup code does not invalidate the
existing code.
2021-10-05 13:24:10 +03:00
Guido Iaquinti
45fbb68d25
docker-compose: remove references to 'posthog/plugin-server' (#6152) 2021-10-05 09:20:43 +00:00
Karl-Aksel Puulmann
0512972426
Add benchmarks for cohort filtering in trends (#6244)
* Add benchmarks for cohort filtering in trends

* Add a way to manually trigger benchmarking
2021-10-05 12:16:55 +03:00
Karl-Aksel Puulmann
f0c9d68166
Make PRINT_SQL output readable (#6245)
Our queries now contain a lot of comment noise that's not relevant when
developing. This change makes PRINT_SQL env variable usable again by
stripping these comments.
2021-10-05 11:27:17 +03:00
Eric Duong
1a9eafe0ed
paths: remove funnel limit when querying path funnels (#6210)
* remove funnel limit when querying path funnels

* add limit test and fix args

* fix args

* typos
2021-10-04 09:56:20 -04:00
Harry Waye
eb08897cf4
dev(clickhouse): strip out comments before executing sql (#6181)
* dev(clickhouse): strip out comments before executing sql

This is so we can easily copy/paste from e.g. Metabase by querying the
system.query_log. In metabase is doesn't display new lines (although you
can download to file for this), but it's not very practical.

* test(clickhouse): use `capture_select_queries` in comment strip test

* test(clickhouse): only sub. params if non-insert query

This parallels `clickhouse_driver` behaviour.

* chore(clickhouse): move sql preparation to dedicated function

* refactor: rearrange func and type definitions
2021-10-04 08:13:31 +01:00
Tim Glaser
3402ba4ee7
Fix status reports (#6194)
* Fix status reports

* remove active in period

* types

* mypy
2021-10-01 18:56:29 +02:00
Karl-Aksel Puulmann
437b2982cd
Benchmarking suite for ClickHouse queries (#6187)
* Add asv code

* Get a benchmark running

* better output folder

* Move benchmark file

* Cleanup of config

* Run a query and benchmark

* Skip benchmarks for isort

* Set up materialized columns before test

* Better skipping logic

* Add first proper benchmark, add some documentation

* Person property filtering

* Add new workflow

* Show stderr in test run

* Continue debugging actions

* Try to save benchmark results to separate repo

* Output to main directory

* Scheduling

* Remove if temporarily

* Int for ms

* Comment on the PR

* Collapsible section

* Update README

* Clarification

* Remove h3

* Remove pyproject.toml, .gitignore changes that are unneeded
2021-10-01 15:20:58 +03:00
Michael Matloka
4ae063d0e6
Add project-nested version of all project-dependent endpoints (#6203)
* Add project-nested version of all project-dependent endpoints

* Fix hook `perform_create`

* Adjust `plugin-configs` to adhere to style of other endpoints
2021-10-01 13:38:33 +02:00
James Greenhill
d5fb987d53
Create Kafka consumer and write tests for consumer and producer (#6170)
* Test Kafka

* black format python

* fix imports

* add kafka and zk deps for testing

* Include ZK and Kafka for all tests

* fix signature for kafka helper

* Connect to localhost for kafka

* update kafka host for all test runs

* Wrong env var for kafka

* consolidate env vars for github actions

* set the advertised hostname from the broker to localhost

* add env var to docker-compose for kafka broker advert host

* resort to what we do locally with /etc/hosts

* Remove configs for kafka that won't be used
2021-10-01 09:43:50 +01:00
Eric Duong
83eca7f227
paths & funnels: Funnel to path connection (#6160)
* restore progress

* working connection no UI visual

* working for events

* edit endpoint to start point

* working with close button

* funnel to path work (no dropoff yet)

* run prettier

* make suggested adjustmenst
2021-09-30 11:20:38 -04:00
Michael Matloka
3a67367ac7
Project-based permissioning TopNavigation (#6027)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type

* Add "Per-project access" feature flag, premium feature, and organization switch

* Rename `OrganizationMembershipLevel` to `OrganizationAccessLevel`

* Create `ExplicitTeamMembership` model

* Show whether projects are restricted in the project switcher

* Update organizations API code

* Fix migrations

* Move organization tests that require EE to `ee`

* Revert `OrganizationMembershipLevel` rename

* Fix organization tests

* Update migration

* Fix schema and add Members to Project Settings

* Build out test memberships API with security tests

* Update `TeamMembers` and `teamMembersLogic`

* Move "Per-project access" description to tooltip

* Add moar tests

* Fix Project Members list logic

* Add additional membership checks

* Update migrations

* Fix typing

* Adjust explicit team memberships API similarly

* Fix typo

* Unify `ExplicitTeamMemberSerializer`

* Remove old changes to `membersLogic` usage

* Use `effective_membership_level` on `TeamBasicSerializer`

* Clean up organization update tests

* Explicitly disallow enabling per-project access for free

* Fix circular import

* Remove `id` from `UserSerializer`

* Fix typing

* Try to fix import

* Fix fatal typing

* Add more tests

* Update permissioning.ts

* Add clarifying comment to migration

* Fix import

* Revert `TopNavigation` changes

* Restore `TopNavigation` changes

This reverts commit 05fd9e4ed6.

* Try to add a story for `TopNavigation`

* minor clarifications

* Revert `TopNavigation` changes

* Restore `TopNavigation` changes

* Make new access control entirely project-based

* Update migrations

* Add `project_based_permissioning` to `TeamBasicSerializer`

* Update test_team.py

* Fix `isRestricted` in `ProjectRow`

* Disable project creation for non-admins

* Make project icon in top nav itself dynamic as well

* Fix story

* Delete 0169_project_based_permissioning.py

* Apply suggestions from code review

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Update frontend/src/layout/navigation/TopNavigation.tsx

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Address feedback

* Project-based permissioning full data access restrictions (#6068)

* Fix Access Control restriction tooltip

* Add `TeamMemberAccessPermission` and use it in viewsets

* Add `ErrorProjectUnavailable` scene

* Ignore mypy

* Update MainNavigation.tsx

* Update explicit_team_member.py

* Fix frontend detection of unavailable project

* Fix some tests and edge cases

* Fix basic permissions

* Add more tests

* Simplify `ExplicitTeamMemberViewSet` permissions

* Improve restrictions and add moar tests

* Update frontend

* Fix a couple of things

* Fix import

* Fix some edge cases

* Fix typing errors

* Use hedgehog instead of moth

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Address feedback

* Add proper permissioning to dashboard views

* Update ee/api/test/test_dashboard.py

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Run prettier

* Remove debug code

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-29 22:43:40 +00:00
Neil Kakkar
b8bc05661f
Proposal: Getting rid of Neighbors in Path Queries (#6125) 2021-09-29 10:44:47 +01:00
Neil Kakkar
579789b877
Allow excluding wildcards in paths (#6111)
* Allow excluding wildcards in paths

* address comment
2021-09-29 10:44:23 +01:00
Rick Marron
a0775d7fae
Replace sessions with session recordings (#6050)
* Move Sessions tab -> Session Recording (behind feature flag)

Note: the /scenes/sessionRecordings folder is a copy of /scenes/sessions. Planning to remove sessions from the new SessionRecordings folder over the next coupld of commits

* Add very basic session recording page

* Add session recordings to persons page and session recs can play

* add endpoints for clickhouse

* fix ordering in existing tests

* add basic test to pg and clickhouse

* small bug fix

* type fix

* add test for data leaking between teams

* fix navigation bugs

* Fix name of logic

* Add basic logic tests

* fix tests

* fix laoding state bug

* revert changes to existing session queries

* move to proper queries for session recordings

* type fixes

* rename feature flag

* type fix

* Fix capitalization

* remove showSessions and clean up ifs

* Style changes and refactor SessionPlayerDrawer

* bug fix

* move to using query params

* remove type from persons logic

* Move sessionRecordingTableLogic key to distinctId

* rename setSessionRecordingId to openSessionPlayer

* improve tests

* Cleanup from review

* move team and limit to parameters
2021-09-28 11:18:38 -07:00
Eric Duong
0dea7c6625
reduce edge limit (#6156) 2021-09-28 13:46:23 -04:00
Li Yi Yu
6284b645b0
New paths tab querybuilder UI (#5825)
* new path tab querybuilder

* prettier

* clean up

* wip

* format querybuidler

* prepare path type filter component

* dropdown

* formatted popup

* change button for endpoints

* styling the type buttons

* logic for all left side querybuilder components

* exclusion UI and logic

* improve exclusion handling, ensure API calls are made

* API fixes for event types

* fix popup on close issue with exclusions

* hide overflow on buttons

* all ui working

* more formatting adjustments

* type fixes

* leave response ambiguous

* feature flagging and adjust styles

* Add Step limit option

* add tooltip to wildcards

* rewrite tooltip for exclusions

* make Events toggle responsive

* fix types

* responsive at xl instead of lg for no overlaps

* Proof of concept of connecting Funnel to Paths

* protecc wip

* Connect Funnels to Paths

* remove funnel button for now

* remove unused

Co-authored-by: eric <eeoneric@gmail.com>
Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-09-28 12:53:03 -04:00
Neil Kakkar
70335c69ea
Remove dangling edges from Paths (#6142)
* Remove dangling edges from Paths

* validate results

* include edge weight backend

* smart default for edge limits
2021-09-28 16:49:35 +01:00
James Greenhill
22b574e50c
Don't provide key to kafka for now (broken partitioning) (#6127) 2021-09-27 19:22:54 +01:00
Neil Kakkar
2fc8a9f293
Add Paths Person API dropoff functionality (#6124) 2021-09-27 13:30:24 -04:00
James Greenhill
ca2ae2a8ad
Default to None if there is no key, encode only if there is data (#6122) 2021-09-27 15:46:37 +01:00
James Greenhill
c2f7ba0d08
Test if key for kafka is none and set to empty string (#6121) 2021-09-27 14:56:49 +01:00
Yakko Majuri
dbd31b91ba
fix kafka partition key (#6117) 2021-09-27 14:35:34 +01:00
James Greenhill
2ae020d6ff
Partition events_plugin_ingestion by IP (#6091)
* Partition  by IP

* use correct version of black...

* fix kafka test

* picky tests

* use value vs data for test kafka
2021-09-27 14:08:00 +01:00
Neil Kakkar
0720cf260a
Various Path API fixes (#6097) 2021-09-27 10:47:16 +01:00
Alex Gyujin Kim
6d6202317a
Add custom_name to entity model (#6090)
* add custom_name to entity model

* fix test and add custom name to funnel

* fix more tests

* remaining broken tests
2021-09-24 08:31:16 -07:00
Michael Matloka
b81ed874cc
Try to fix project deletion edge case (#5534)
* Try to fix project deletion edge case

* Use feedback

* Use `create_demo_team` in Team deletion test

* Don't use raw `DELETE` queries
2021-09-23 19:22:11 +02:00
Eric Duong
5205c03931
Retention event query cleanup (#6049)
* add event query

* replace target subquery

* cleaned up main retention function

* filter typing

* add mixin

* remove fluff

* use enum

* update fields pattern

* fix constants
2021-09-23 11:16:31 -04:00
Marius Andra
0583310a29
Export 10k lines in CSV, allow limit= query param (#5959)
* Export 10k lines in CSV, allow limit= query param

* this should be min

* fix test var

* add limit support to postgres, make tests to check all cases

* update tooltip to say 10k events

* fix 10k event text again
2021-09-23 08:52:53 +00:00
Michael Matloka
eb6db7c075
Project-based permissioning members addition + removal (#6028)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type

* Add "Per-project access" feature flag, premium feature, and organization switch

* Rename `OrganizationMembershipLevel` to `OrganizationAccessLevel`

* Create `ExplicitTeamMembership` model

* Show whether projects are restricted in the project switcher

* Update organizations API code

* Fix migrations

* Move organization tests that require EE to `ee`

* Revert `OrganizationMembershipLevel` rename

* Fix organization tests

* Update migration

* Fix schema and add Members to Project Settings

* Build out test memberships API with security tests

* Update `TeamMembers` and `teamMembersLogic`

* Move "Per-project access" description to tooltip

* Add moar tests

* Fix Project Members list logic

* Add additional membership checks

* Update migrations

* Fix typing

* Adjust explicit team memberships API similarly

* Fix typo

* Unify `ExplicitTeamMemberSerializer`

* Remove old changes to `membersLogic` usage

* Use `effective_membership_level` on `TeamBasicSerializer`

* Clean up organization update tests

* Explicitly disallow enabling per-project access for free

* Fix circular import

* Remove `id` from `UserSerializer`

* Fix typing

* Try to fix import

* Fix fatal typing

* Add more tests

* Update permissioning.ts

* Add clarifying comment to migration

* Fix import

* Revert `TopNavigation` changes

* Add project member addition button+modal

* minor clarifications

* Revert `TopNavigation` changes

* Make new access control entirely project-based

* Update migrations

* Add `project_based_permissioning` to `TeamBasicSerializer`

* Update test_team.py

* Fix Access Control restriction tooltip

* minor improvements

* fix frontend typing

* Fix frontend typing a bit more

* adjust copy & UI a bit

* Address feedback on field comment

* "Privacy settings" to "Access Control"

* Make `FusedTeamMemberType` comment clearer

* Remove useless `export`

* Delete 0169_project_based_permissioning.py

* Clean some code up a bit

* Project-based permissioning member removal (#6067)

* Fix  `teamMembersLogic` loaders

* Allow explicit project members to leave

* Add member removal/leaving button to Members with Project Access

* Restore error message

* Fix error message

* Correct things

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-22 17:32:35 +00:00
Harry Waye
3184db8aa0
fix(breakdown): resolve week rounding interval over shoot for trends (#6053)
* test(breakdown): add test for week interval rounding overshooting

This refers to https://github.com/PostHog/posthog/issues/2675

* fix(breakdown): resolve week rounding interval over shoot for trends

Previously there was a fix for another issue with weekly intervals not
spanning a large enough range, see
69ba0b1d90
for details.

The issue that this was trying to resolve was consider a date range
date_from, date_to and a week interval. The range can cross two weeks,
but prior to the above commit it would only show one tick/week on the
graph. In this case we just added on another week to show.

This doesn't help however in the case where the range is less than a
week, in which case we'd end up showing a week/tick on the graph with
a zero value.

Instead, we remove the additional 1 week and simply ensure that both
lower and upper bounds are included in the clickhouse zero fill.

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

* fix(lifecycle): update lifecycle to use updated week interval handling

This is due to the change in the way the week interval is handled in the
previous commi, where we removed a +1 we were adding to week intervals
and thus getting too many date axis ticks on trend graphs.

* ci(tests): only run non-ee tests for non ee action step

It seems that we are segregating tests between ee and non-ee via a
folder structure. This is a bit of a hack, but it works for now but
ideally we should converge on one set of tests for which we identify if
they are supported on clickhouse or not via pytest markers. This should
simplify working with the tests somewhat, e.g. making them easier to
locate, update, and e.g. debug in vscode/codespaces.

* test(trends): correct old week interval test. It was wrong before

Now with the change to how we create the interval, it's fixed.

* fix(trends): avoid including one week too many when deciding on bounds

Previously there was a test in here that was saying that if we request a
graph of events, with week interval ticks starting on a Sunday, we'd
actually end up also including the Sunday before due to some arithmetic
mistakes.

* fix(trends): resolve week interval rounding issues for trends query

* test(identify): update test func to accept `properties` argument
2021-09-22 18:28:25 +01:00
Neil Kakkar
cda9cfa001
Introduce Path Persons API endpoint (#6070)
* introduce path persons API endpoint

* docs in query class
2021-09-22 17:01:25 +00:00
Michael Matloka
bc3e223265
Project-based permissioning framework (#5976)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type

* Add "Per-project access" feature flag, premium feature, and organization switch

* Rename `OrganizationMembershipLevel` to `OrganizationAccessLevel`

* Create `ExplicitTeamMembership` model

* Show whether projects are restricted in the project switcher

* Update organizations API code

* Fix migrations

* Move organization tests that require EE to `ee`

* Revert `OrganizationMembershipLevel` rename

* Fix organization tests

* Update migration

* Fix schema and add Members to Project Settings

* Build out test memberships API with security tests

* Update `TeamMembers` and `teamMembersLogic`

* Move "Per-project access" description to tooltip

* Add moar tests

* Fix Project Members list logic

* Add additional membership checks

* Update migrations

* Fix typing

* Adjust explicit team memberships API similarly

* Fix typo

* Unify `ExplicitTeamMemberSerializer`

* Remove old changes to `membersLogic` usage

* Use `effective_membership_level` on `TeamBasicSerializer`

* Clean up organization update tests

* Explicitly disallow enabling per-project access for free

* Fix circular import

* Remove `id` from `UserSerializer`

* Fix typing

* Try to fix import

* Fix fatal typing

* Add more tests

* Update permissioning.ts

* Add clarifying comment to migration

* Fix import

* minor clarifications

* Revert `TopNavigation` changes

* Make new access control entirely project-based

* Update migrations

* Add `project_based_permissioning` to `TeamBasicSerializer`

* Update test_team.py

* Fix Access Control restriction tooltip

* adjust copy & UI a bit

* Address feedback on field comment

* "Privacy settings" to "Access Control"

* Ignore mypy

* Rename `Team` field `project_based_permissioning` to `access_control`

* Update migrations

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-22 18:29:59 +02:00
Neil Kakkar
152dfae591
Enable Paths Grouping on backend (#6052)
* enable paths grouping on backend

* write API test for path groupings

* remove % only use *
2021-09-22 16:41:49 +01:00
Eric Duong
81b73d38b0
make argument compatible (#6064) 2021-09-22 11:26:03 -04:00
Tim Glaser
eba29d85f6
Send license usage (#6060)
* Send license usage

* type errors

* Update posthog/celery.py

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Use correct URL

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-22 14:17:38 +02:00
Yakko Majuri
dc17c1d23c
report on self hosted duplicate ids (#6024)
* report on self hosted duplicate ids

* satisfy mypy

* satisfy black

* adjust test to run on ch only

* black

* fix stupid test typo

* black, again

* update report

* format

* fix black pre commit hook

* update query

* report on multiple ids per person

* fix foss test
2021-09-22 12:10:43 +00:00
Harry Waye
dc8148ede6
dev(clickhouse): raise clickhouse setup errors quickly (#6069)
I was having issues with running the clickhouse/ee tests and it was just
hanging. Clickhouse appeared to be up and I could perform queries with
`clickhouse-client`. For some reason it was hanging on querying, and on closer
inspection if looks like for each of the setup queries it was hanging for 6
seconds, failing to find zookeeper, and then continuing to run setup.

It's pretty useless to continue in this case, so it seems more sensible to raise
in this case.
2021-09-22 10:22:52 +00:00
Neil Kakkar
0d5ac10b88
Add Paths Persons to the backend (#6035)
* Add paths persons to the backend

* fix flakey test
2021-09-22 10:53:10 +01:00
Harry Waye
b4540a8c19
chore(tests): make clickhouse calls raise if PRIMARY_DB not set to clickhouse (#6054) 2021-09-22 11:12:43 +02:00
James Greenhill
492e8e25d1
Add events count to system status page (#6062)
* Add events count to system status page

* add events count for last month and month to date
2021-09-21 22:48:32 +00:00
Michael Matloka
3411ec5a5d
Skip empty selectors in ClickHouse action matching (#6038)
* Skip empty selectors in action matching

* Fix test and solution
2021-09-21 21:23:56 +02:00
Alex Gyujin Kim
662c2be31a
Remove steps parameter in time conversion result (#6046)
* remove steps parameter in time conversion result

* fix tests

Co-authored-by: Marius Andra <marius.andra@gmail.com>
2021-09-21 15:23:32 +02:00
Neil Kakkar
d6e410b3a9
Remove Autocapture functionality from Paths (#5895)
Co-authored-by: eric <eeoneric@gmail.com>
2021-09-20 15:10:50 +00:00
Alex Gyujin Kim
e85fde3921
Split out funnel apis and fix histogram paint order bug (#6002)
* split out funnel apis and fix histogram paint order bug

* fix broken tests

* simplify some more

* make this fail if no steps returned

Co-authored-by: Marius Andra <marius.andra@gmail.com>
2021-09-17 09:36:15 +00:00
Michael Matloka
e2a265af06
Don't try to set ClickHouse up in EE tests if not enabled (#5989)
* Don't try to set ClickHouse up in EE tests if not enabled

* Use `is_clickhouse_enabled`
2021-09-16 15:50:47 +02:00
James Greenhill
616c25ef00
Add support for CH for instance status reports (#5980)
* Add support for CH for instance status reports

* format

* `BETWEEN` a rock and a hard place
2021-09-15 18:39:09 -07:00
Michael Matloka
678722d4f0
Make EnterpriseFeatureException more informational, with a CTA (#5949)
* Make `EnterpriseFeatureException` more informational, with a CTA

* Fix test asserts

* Fix test asserts the other way around
2021-09-15 09:47:08 +00:00
Paolo D'Amico
cf9814c08f
SAML deps build (#5932) 2021-09-14 11:43:26 +02:00
Harry Waye
f43ad0334e
Fix IndexError in Retention endpoint: do not fail if there is more data than expected from clickhouse query (#5892)
* refactor(retention): add AppearanceRow dataclass to improve readability

This just makes it a little more clear what is being pulled out of the
database. Previously we were just getting a list of lists.

I haven't done anything else here but will follow up with a fix for
https://github.com/PostHog/posthog/issues/5443

* test(retention): reproduce retention marker index error

* fix(retention): make retention forgiving of too much data from query

This just makes the `appearance_to_markers` method not fail if the
underlying clickhouse query returns more data than expected. It should
just be less efficient than it could be and should still give the
correct results. Previously it would silently fail to include any data
in these cases.

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

Co-authored-by: Harry Waye <harry@scalexp.com>
2021-09-14 10:38:40 +01:00
Eric Duong
995524aa6f
Bugfix: cohort calculating race condition (#5929) 2021-09-14 08:33:43 +02:00
Marius Andra
9da6ee3b5f
ClickHouse M1 Docker (#5215)
* m1 clickhouse support

* add clickhouse arm64 compilation dockerfile

* use clang-12 and 2 parallel builds

* working clickhouse docker image

* this needs to be committed out for CH to work... a known issue. WIP

* move things around

* move things around again

* add arm64 build scripts

* comment out broken line in DEBUG mode, still make it break production builds

* update readme

* timeless text

* add issue in comment

* way way way too much white space

* zookeeper restarts sometimes needed
2021-09-13 13:01:24 +02:00
Paolo D'Amico
1012be975a
SAML auto provisioning (#5910) 2021-09-13 12:04:46 +02:00
Michael Matloka
81f7291261
Move is_clickhouse_enabled from posthog.ee to posthog.utils (#5902)
* Move `is_clickhouse_enabled` from `posthog.ee` to `posthog.utils`

* Remove circular import
2021-09-11 01:43:24 +02:00
Eric Duong
08efd78987
Swap out old paths querying class with new 2 (#5887)
* Revert "Revert "Swap out old paths querying class with new (#5821)" (#5886)"

This reverts commit 82ef50a1e7.

* remove old ref

* test 3.9 general

* test if there's overlapping

* change version back
2021-09-10 15:38:45 -04:00
Karl-Aksel Puulmann
9034813505
Kill an unused SQL query (#5889)
Dead code bye-bye
2021-09-10 18:15:39 +02:00
Eric Duong
6411a79d9a
Revert "Revert "Paths search between funnel steps (#5847)" (#5899)" (#5900)
This reverts commit 4b1c9167d0.
2021-09-10 11:36:26 -04:00
Eric Duong
4b1c9167d0
Revert "Paths search between funnel steps (#5847)" (#5899)
This reverts commit 685bd3be3e.
2021-09-10 10:50:42 -04:00
Eric Duong
685bd3be3e
Paths search between funnel steps (#5847)
* make timestamp dynamic

* change funnel path type to str

* change include_timestamp_step name

* type issues

* add argument

* add type

* explicit none check

* change field names

* change constant name

* between step test

* use different arguments for defining funnel steps and add tests

* after step test

* fix types

* test for valueerror

* add test for before dropoff

* custom logic for finding paths up to a dropoff

* fix type

* update test

* add comment

* change event names in test to be clearer

* run again

* test without caching

* return caching

* try not caching again

* try not caching again

* try not caching again

* restore caching

* remove funnel_window_days

* remove unused import
2021-09-10 10:46:21 -04:00
Karl-Aksel Puulmann
c5ababb963
Raise ValidationError if "math" without "math_property" passed to BE from FE (#5891)
* Raise ValidationError if "math" without "math_property" passed to BE from FE

BE side fix for https://github.com/PostHog/posthog/issues/5756

* Update ee/clickhouse/queries/trends/util.py

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Update typing

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-10 14:55:59 +03:00
Neil Kakkar
6e218705f5
Add test for funnel with autocapture elements chain (#5893)
* add test for funnel elements chain

* address comment
2021-09-10 12:49:25 +01:00
Karl-Aksel Puulmann
ec374a8f30
Test and fix "filtering trends with action with person property" failure (#5879)
* Test and fix "filtering trends with action with person property" failure

Closes #5876

* Improve wording
2021-09-10 11:22:45 +03:00
Eric Duong
82ef50a1e7
Revert "Swap out old paths querying class with new (#5821)" (#5886)
This reverts commit a8f12f8695.
2021-09-09 22:31:27 -04:00
Eric Duong
a8f12f8695
Swap out old paths querying class with new (#5821)
* swap out old paths querying class with new

* swap arguments

* swap name

* delete old CH paths file

* dont error out in calculate_by_filter

* write some backwards compatible tests for paths

* remove expanding autocapture element ability

* cleanup

* delete old code

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-09-09 21:55:17 -04:00
Paolo D'Amico
ef7ec14014
Conditional SAML dependencies (fix Heroku deploys) (#5870) 2021-09-09 14:09:15 +00:00
Karl-Aksel Puulmann
a911a69559
Improve clickhouse flamegraphs (#5874)
* Final fix for kwargs

* Make flamegraphs interactable, still allow opening in a new tab
2021-09-09 12:40:46 +00:00
Neil Kakkar
09e2eb0bfd
(No) ColumnOptimizer Updates for Paths (#5859)
* add optimizations for paths

* add test for excluding events as well

* clean
2021-09-09 12:50:46 +01:00
Karl-Aksel Puulmann
ce52ccca7c
Fix cloud-specific override logic (#5872)
😅 rebasing fail
2021-09-09 13:38:40 +03:00
Michael Matloka
1d4187923b
Refactor AvailableFeature from strings to an enum everywhere (#5856)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type
2021-09-09 12:19:55 +02:00
Karl-Aksel Puulmann
a8f46b056b
Refactor and speed up /api/action/people (trends person modal) (#5842)
* Move api/action/people SQL code under ee/clickhouse/queries

* Move api/action/people SQL code into a class

* Fix rebase

* Calculate Trends people via TrendsEventQuery

This should significantly speed up the query. In testing, this took one
query from 10s -> 1s.

We can reuse almost all of the plumbing in TrendsEventQuery.

* Update insert_entity_people_into_cohort

* Fix date handling in trends people, add in-depth tests for each interval

* Standardize code style a bit

* Make tests less TZ dependant

* Skip failing tests on-not-ee

* Document
2021-09-09 09:42:19 +03:00
Michael Matloka
f36c5f40b7
Rename RDBMS to AnalyticsDBMS (#5857) 2021-09-08 16:16:47 +02:00
Karl-Aksel Puulmann
3ac74a8472
Clickhouse flamegraphs (#5752)
* WIP: flamegraphs

* Get flame graphs generating

* Add files to bin

* Crude frontend for analyzing

* Hack: Use a stable clickhouse host instead of conn pool for flamegraphs

Otherwise no way to get back measurements due to LB.

* Error handling

* Only allow read queries

* Hide query analyze button for non-owners

* Make sure non-admins can't run queries

* Fix query issue
2021-09-08 16:24:44 +03:00
Eric Duong
a8731a3d00
Add test for defining both a start and end point for path (#5820)
* add test for defining both a start and end point

* add multiple target handling

* fix type

* move param handling

* null condition
2021-09-07 12:00:39 -04:00
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