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

688 Commits

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