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

624 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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