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
Karl-Aksel Puulmann
d7d2bcb7a3
Fix python manage.py migrate_clickhouse --plan (#8741)
Currently this would throw on a fresh install with an error similar to

```
│ posthog-events Migration would get applied: 0024_materialize_window_and_session_id                    │
│ posthog-events Traceback (most recent call last):                                                     │
│ posthog-events   File "manage.py", line 21, in <module>                                               │
│ posthog-events     main()                                                                             │
│ posthog-events   File "manage.py", line 17, in main                                                   │
│ posthog-events     execute_from_command_line(sys.argv)                                                │
│ posthog-events   File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", li │
│ posthog-events     utility.execute()                                                                  │
│ posthog-events   File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", li │
│ posthog-events     self.fetch_command(subcommand).run_from_argv(self.argv)                            │
│ posthog-events   File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 3 │
│ posthog-events     self.execute(*args, **cmd_options)                                                 │
│ posthog-events   File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 3 │
│ posthog-events     output = self.handle(*args, **options)                                             │
│ posthog-events   File "/home/posthog/code/ee/management/commands/migrate_clickhouse.py", line 41, in  │
│ posthog-events     self.migrate(CLICKHOUSE_HTTP_URL, options)                                         │
│ posthog-events   File "/home/posthog/code/ee/management/commands/migrate_clickhouse.py", line 57, in  │
│ posthog-events     sql = getattr(op, "_sql")                                                          │
│ posthog-events AttributeError: 'RunPython' object has no attribute '_sql'
```

This is due to the command not working with `RunPython` commands.
2022-02-25 16:51:22 +02:00
Eric Duong
a25caf50dd
Static cohort api return (#8735) 2022-02-24 19:08:23 +01:00
Michael Matloka
b679bc3d68
Fix dashboard permissions (#8734)
* Fix dashboard permissions

* Use `===`
2022-02-23 10:33:21 +00:00
Rick Marron
3f6c472155
Fix recordings on funnel trends (#8621)
* fix recordings on funnel trends

* update tests

* update snapshots
2022-02-23 01:42:55 -08:00
Karl-Aksel Puulmann
9769ef0b5d
Improve backend CI (update .test_timings, run against different CH version) (#8708)
* Make clickhouse server image version configurable

* Attempt to use a reusable workflow for backend tests

* Try a composite action

* Add missing shell: bash

* Temporarily remove a step

* Cache id parameter

* Include the action when needing to rerun

* Move checking migrations to separate file

This didn't work in composite actions tests and slows down every
parallelized test execution for no reason. This should have been
separate in the first place.

* Rename job

* Improve check-migrations

* Start stack in the new job

* Remove shell

* Solve flaky test

* Remove unused file

* Create a test timings job

* Use checkout@v2 - https://github.com/cds-snc/github-actions/issues/23

* Ignore coverage files

* Save backend test durations

* Install pytest-split

* Clean up ci-backend

* Move actions code around

* wording improvement

* Save backend test durations

* Add a comment

* Make it possible to run tests with a different clickhouse version

* Remove debugging code

* Fix typo

* Boolean inputs please work

Fixes overeager test running as per https://github.com/actions/runner/issues/1483

Co-authored-by: PostHog Bot <hey@posthog.com>
2022-02-22 17:06:04 +02:00
Guido Iaquinti
1d1d6d335c
flake8: enable E266,W291,W293,W391,W601 (#8699) 2022-02-21 15:47:27 +01:00
Tim Glaser
ee71311991
noop 0214 (#8704)
* noop 0214

* No opp tests and ee migration
2022-02-18 21:42:38 +00:00
Alex Gyujin Kim
a88766300e
Add tags back migrations (#8701)
* add tags back migrations

* make tags default None
2022-02-18 21:29:16 +00:00
Alex Gyujin Kim
d7a0c10e32
Part 2: Deprecate old tags and upgrade to new tags Backend (#8529) 2022-02-18 08:47:05 -08:00
Eric Duong
0b4a9f2cf0
Update Breakdown props to use filter groups (#8679)
Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2022-02-18 15:28:20 +00:00
Neil Kakkar
5c5d575939
Rename property group values (#8680)
* initial working for trends with simplify

* simplify logic only if property_groups exists

* purge empty clauses

* fix tests

* fix snapshots

* update subquery logic

* update snapshots

* update snapshots

* columnoptimizer

* combine tests

* proof of concept simplification

* diff snapshots

* fix tests

* helpers and property_groups everywhere

* update snapshots

* fix simplify

* type

* missing argument

* add old properties back to simplify logic

* resolve merge conflicts, address few comments

* wip cleanup

* rm simplify filters

* redo removal

* update snapshots

* last snapshot

* update snapshot

* rename property group values

* missed one

* cruft

Co-authored-by: Eric <eeoneric@gmail.com>
2022-02-17 13:25:33 -05:00
Neil Kakkar
101e1c8d1a
Simplification of property groups usage (#8641)
* initial working for trends with simplify

* simplify logic only if property_groups exists

* purge empty clauses

* fix tests

* fix snapshots

* update subquery logic

* update snapshots

* update snapshots

* columnoptimizer

* combine tests

* proof of concept simplification

* diff snapshots

* fix tests

* helpers and property_groups everywhere

* update snapshots

* fix simplify

* type

* missing argument

* add old properties back to simplify logic

* resolve merge conflicts, address few comments

* wip cleanup

* rm simplify filters

* redo removal

* update snapshots

* last snapshot

* update snapshot

Co-authored-by: Eric <eeoneric@gmail.com>
2022-02-17 12:46:08 -05:00
Guido Iaquinti
b17cb3de0a
len(queryset) -> queryset.count() (#8650) 2022-02-17 12:38:34 +01:00
Karl-Aksel Puulmann
f8daa4a05d
properties_to_Q: don't support event model anymore (#8667)
* Remove dead querying methods

* Remove a dead filtering method

* Remove capability to filter events from property_to_Q

Note I've also duplicated test_filter tests to ensure we still have
sufficient coverage (via persons now) on property_to_Q but also have the
existing tests for EE

* Remove test-only SQL

* Remove events-related cruft
2022-02-17 13:23:57 +02:00
Karl-Aksel Puulmann
2e038d4ae7
Remove more pg Events table usage (#8662)
* Remove Event dependency on action api tests

* Remove a dead function

* Remove BaseQuery

* Remove dead imports

* Remove Event creation from posthog/test/test_person_model.py

* Remove Event.earliest_timestamp function

* Remove some unused event model methods

* Remove query_db_by_action + associated migration code

* Remove dead filtering methods from Events model

* Remove a dead test class

* Remove some event model usage

* Remove events model usage from actions test

* Remove session recording related views

* Remove model usage in posthog/queries/session_recordings/session_recording.py

* Remove old pg-session recording code

* Remove dead import

* Re-add missing dependency

* Make lint/tests pass

* Make filter tests uuid-based
2022-02-17 12:47:11 +02:00
Guido Iaquinti
96b3cd6eb7
Boolean should be compared with is/is not (#8651) 2022-02-17 10:31:54 +01:00
Guido Iaquinti
126cd4c463
Remove mutable dataclasses (#8645) 2022-02-17 10:12:09 +01:00
Karl-Aksel Puulmann
9baba81d22
Delete postgres/events-related code: pg queries (#8638)
* Dont use event model in event api tests

* Remove trends-related postgresql code

* Kill stickiness.py

* Kill paths query

* Remove retention pg query
2022-02-17 09:14:47 +02:00
Michael Matloka
09c9f9d2f7
Dashboard permissions upsell two (#8614)
* Use LemonSelect for Template

* Add mini pay gate for dashboard permissions

* Use "advanced permissioning" instead of "collaboration features"

* Rename "Collaboration restrictions" to "Collaboration settings"
2022-02-16 20:36:36 +00:00
Paul D'Ambra
a314b61a02
Query person_distinct_id2 not person_distinct_id (#8358)
* add the fix and let CI say if that breaks any tests

* allow getting team IDS without direct substitution and mark all the places to check with TODOs

* pass team id in from everywhere and see what tests fail in CI

* named params everywhere

* address mypyc

* get tests passing

* fix tests after merge from master

* remove SQL query that's not referenced from anywhere

* check some marked queries are templated correctly now

* remove unused SQL

* check some marked queries are templated correctly now

* no optional team id

* more passing of team id into things

* don't trust autocomplete

* address review
2022-02-16 15:32:24 +00:00
Karl-Aksel Puulmann
9929161e35
Delete old events-model adjacent code (#8623)
* Remove event admin

* Move posthog/tasks/test/test_org_usage_report.py clickhouse version inline

* Remove postgres-specific code from org usage report

* Kill dead on_perform method

* Remove dead EventSerializer

* Remove a dead import

* Remove a dead command

* Clean up test, dont create a model

* Remove dead code

* Clean up test_element

* Clean up test event code

* Remove a dead function

* Clean up dead imports

* Remove dead code

* Code style cleanup

* Fix foss test

* Simplify fn

* Org usage fixup #3
2022-02-16 15:15:46 +02:00
Alex Gyujin Kim
ba640115e9
Editable taxonomy definitions (#8430) 2022-02-15 18:04:19 -08:00
Rick Marron
52a9054900
Materialize the window_id and session_id on the events table (#8532)
* materialize columns

* update snapshots

* remove test_with_materialized_column

* update recording snapshot

* update new funnel tests

* update snapshots

* fix test

* update snapshots pt 2
2022-02-15 16:41:30 -08:00
Eric Duong
dd620e01cc
Fill postgres cohortpeople table only if related to feature flag (#8610)
* fill postgres only if cohort is used in feature flag

* update relevant cohorts when feature flag is updated or created

* move calls

* call count test ff

* add ff test

* snapshots

* update types

* get person cohorts

* api all working

* fix tests

* typing and frontend

* capitalize constant
2022-02-15 16:59:36 -05:00
Rick Marron
b2beccdb17
Recordings in funnels (#8180)
* first pass at adding recordings to funnels

* fix funnel trend sort orders

* cleanup

* fix spacing for ambr

* fix should_refresh

* fix potential missing funnel_step

* add test to normal + strict funnels

* update snapshots

* update snapshot pt 2

* remove support for unordered funnels

* update snapshot

* fix include recording filter

* add recordings to funnel correlation

* add final_event concept

* fix filter

* fix snapshot

* tests for strict funnel correlation actors

* fix materialized property

* cleanup

* fix bug with any order funnel + correlation persons modal

* respond to feedback

* revert back

* snapshot update
2022-02-15 13:04:57 -08:00
Neil Kakkar
a3ae826059
Fix bug with exposure calculation in trends (#8600) 2022-02-15 12:46:25 +00:00
Harry Waye
3be0cda8ce
perf(cohorts): reduce select batch size, and sleep 1 between (#8598)
* perf(cohorts): reduce select batch size, and sleep 1 between

Previously we were hammering the database, see
https://github.com/PostHog/product-internal/issues/256 for details. Now
we:

 1. reduce the batch by 5 times
 2. have a little sleep(1) between batches

We also add a little bit of logging for instance in failure cases.

* include stack trace info in warning

* just reraise so we don't lose stack trace

* use monotonic for timings, not time

* update snapshots
2022-02-15 11:53:20 +00:00
Neil Kakkar
286d8844d7
Send Experiment variants used for calculations with API response (#8597) 2022-02-15 11:48:41 +00:00
Eric Duong
e1476dfaf4
Or property filtering API (#8012)
* add test

* update func

* add include and settings

* diff method

* some prelim changes to make backend work

* add tests and logic for handling groups

* setup basic mixin parsing

* add tests

* types and switchover

* adjustment

* update snapshots

* update more snapshots

* update more snapshots

* update more snapshots

* typing

* snapshots

* clean up TODOs and types

* separate to_dict

* another property dict fix

* use operator dependening on condition

* fix tests

* update tests

* remove dummy condition

* update tests

* change name to groups

* another label

* rename filter_group to property_group

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2022-02-14 13:39:48 -05:00
Eric Duong
3e7f0d37a4
fix(cohort): Add count field to cohort model (#8585)
* add count field to cohort model

* make count safe

* update version with count
2022-02-14 16:34:07 +00:00
Neil Kakkar
2d613d7d97
Fix trend breakdown duplicates (#8583)
* keep breakdown count consistent

* add constant back

* update test
2022-02-14 16:20:45 +00:00
Michael Matloka
db4111df8a
Finalize dashboard restrictions (#8527)
* Update test_insight.py

* Secure insight endpoint for dashboard restrictions

* Prohibit unauthorized deletion of restricted dashboard

* Update class name in snapshots

* Address feedback
2022-02-14 12:55:16 +00:00
Alex Gyujin Kim
459d304e95
Part 1: Make everything taggable Backend (starting with Actions) (#8528) 2022-02-13 22:19:53 -08:00
Harry Waye
bc43b8685e
feat(healthchecks): add clickhouse and redis health (#8497)
* feat(healthchecks): add clickhouse as a dependency

* feat(healthchecks): add celery broker healthcheck

* feat(healthchecks): add cache healthcheck, plus some misc updates

* add missing typing

* add missing typing

* add role cast

* Add logging for kafka connectivity check

* actually add healthcheck as middleware

* fix postgres failure check

* simplify postgres migration return value

* verboise -> verbose

Co-authored-by: Guido Iaquinti <4038041+guidoiaquinti@users.noreply.github.com>

* put interface validation at top of view

* remove unused imports

* show resp.content on status failures

* test(healthchecks): set log level to debug to pytest displays it

* restore logger level

* Bring up redis for backend ci tests

* up redis in non-cloud tests

Co-authored-by: Guido Iaquinti <4038041+guidoiaquinti@users.noreply.github.com>
2022-02-10 15:20:38 +00:00
Harry Waye
4f07fb7658
test(snapshots): update clickhouse snapshot comments (#8535)
* test(snapshots): update clickhouse snapshot comments

It looks like Clickhouse has been removed from clickhouse sql comments,
but the snapshots haven't been updated. Not sure how this got past CI.

* missed a couple
2022-02-10 12:07:09 +00:00
Michael Matloka
2207bbe84e Update snapshots 2022-02-09 21:14:53 +01:00
Tiina Turban
1abe9ef897
async mig check (#8503) 2022-02-09 20:45:59 +01:00
Tiina Turban
73e4f0db51
Add --check command to migrate_clickhouse (#8501) 2022-02-09 20:44:52 +01:00
Eric Duong
e4f65b1790
8356 versioning (#8449)
* version insights

* version and lock update

* make sure all tests work

* restore exception

* fix test

* fix test

* add specific id

* update plugin server test utils

* cleanup

* match filtering

* use timestamp comparison

* make tests work

* one more test field

* fix more tests

* more cleanup

* lock frontend when updating and restore refresh

* pass undefined

* add timestamp to background update

* use incrementer

* add field

* snapshot

* types

* more cleanup

* update tests

* remove crumbs

* use expressions

* make nullable

* batch delete

* fill null for static cohorts

* batch_delete

* typing

* remove queryset function
2022-02-09 12:19:00 -05:00
Marius Andra
ed25618236
Fetch person property values via Clickhouse (#8414)
* fetch person properties via clickhouse

* cleaner queries

* fix some types

* parse up to 100k persons with this prop, add back counts

* ignore something that's bound to error anyway

* no point making it too flat now

* revert flattening of lists

* add statsd

* ignore type

* add back conversion

* mypy

* better mypy

* refactor
2022-02-09 17:17:37 +01:00
Tim Glaser
1aea20c683
reintroduce assertNumQueries (#8487)
* reintroduce assertNumQueries

* Remove and speed up

* fix two more
2022-02-09 16:15:17 +00:00
Neil Kakkar
d5a48fbd06
Add support for Groups in Experiments (#8463)
* add support for Experiment groups

* update styling

* incl groups in property selection

* set participant type and respect FF group type on backend

* remove aggregation select
2022-02-09 15:32:54 +00:00
Michael Matloka
3a678e7261
Dashboard privilege API and collaborators UI (#8424)
* Add basic `/api/projects/:id/dashboard/:id/collaborators`

* Handle more collaboration cases and add base tests

* Add some collaborators UI to share modal

* Improve Python typing

* Improve TS typing

* Allow addition and deletion of collaborators from UI

* Add upsell prototype

* Improve upsell button

* Add `effective_restriction_level` to `DashboardSerializer`

* Improve `LemonSelect` value handling

* Improve `LemonSelect` behavior when selecting existing value

* Refactor the way privilege level name is determined

* Don't destroy `ShareModal` on close to avoid logic remounting

* Split out upsell into own PR

* Fix TS

* Fix typing

* Increase security with more tests

* Inline `parents_query_dict`

* Dashboard collaborator bubbles (#8450)

* Add collaborator bubbles to restricted dashboard headers

* Rename `index.tsx` to `ProfilePicture.tsx` for readability

* Improve tooltip handling

* Create ProfileBubbles.stories.tsx

* Make collaborator bubbles tooltip dashboard-level

* Always show collaborator bubbles

* Dashboard restrictions (#8462)

* Add frontend-side restrictions editing restrictions to dashboards

* Restrict `InsightCard`

* Align info message margin

* Disallow locking yourself out of the dashboard

* Handle dashboard restrictions in the insight page

* Allow disabling `InsightsTable` series checkbox

* Fix minor issues

* Align .page-title-row height

* Fix typing

* Fix arg name

* Address review feedback

* Fix n+1 queries issue
2022-02-08 16:22:09 +00:00
Paolo D'Amico
5ac9ecd985
Track invite signups (#8446)
Co-authored-by: Michael Matloka <dev@twixes.com>
2022-02-08 15:37:07 +01:00
Paolo D'Amico
e4e89a8da8
Configure recordings TTL setting from UI (#8139) 2022-02-08 15:08:23 +01:00
Tim Glaser
6d13d58cd6
Revert "Adds reserved properties for filtering property definitions (second attempt) (#8349)" (#8485)
This reverts commit 3491b161ad.
2022-02-08 13:49:11 +00:00
Paul D'Ambra
3491b161ad
Adds reserved properties for filtering property definitions (second attempt) (#8349)
* Revert "Revert "Adds reserved properties for filtering property definitions (#8291)" (#8340)"

This reverts commit cb6839fe21.

* limit reserved properties to events table, include this in unit tests

* add api level tests for datetime and reserved word filtering of trends

* remove unused constant

* make the cypress test even looser

* delete file that is no longer in master

* extract a query object

* implement reserved attribute querying for date filters

* update datetime cypress test

* separate and clarify tests and ensure date queries only use reserved attributes on event filters

* delete file that isn't in master
2022-02-08 14:25:39 +01:00
Yakko Majuri
fca0a46772
Add tags to dead letter queue table (#8345)
* add tags to dead letter queue table

* Update ee/clickhouse/migrations/0023_dead_letter_queue_tags.py

* fix typo

* fixes

* update snapshots

* fix tests

* fix test

* update snapshot

* send tags

* update

* Update ee/clickhouse/migrations/0023_dead_letter_queue_tags.py

* fix plugin server test?

* Update plugin-server/src/worker/ingestion/utils.ts

* Update plugin-server/src/types.ts

* Update plugin-server/src/worker/ingestion/utils.ts
2022-02-04 15:36:15 -05:00
Neil Kakkar
1fcf91fdfc
surface p value and loss from API, so frontend can display when needed. (#8434) 2022-02-04 12:12:26 +00:00
Neil Kakkar
4131d6a114
reduce precision for probabilities (#8427) 2022-02-03 21:04:07 +00:00