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

748 Commits

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