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

4039 Commits

Author SHA1 Message Date
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
Yakko Majuri
ca57946ff3
add properties_last_updated_at (#6058) 2021-09-22 14:44:14 +00:00
PostHog bot
7aaf69e3d3
Update plugin server to 1.9.0 (#6071)
Co-authored-by: posthog-bot <posthog-bot@users.noreply.github.com>
2021-09-22 16:41:03 +02: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
Paul D'Ambra
a2308ebc2a
Allows users to choose whether the events page automatically loads new events (#6033)
* barebones implementation for #3899

Wires up an unlabelled switch with existing functionality. Doesn't provide any persistence of the setting or user feedback for when data is loading. Doesn't highlight new rows

* align content in table config to baseline

* make auto-loading text clickable without resolving page structure

* lift exporting and auto-loading out of table content and a pass through organising the page with grid layout

* note that the fixed filters won't change per logic instance

* never display the column configurator button. to be resolved by #1534

* simplify the labelled switch component

* highlight new rows when they're added to the table

* use styling from variables for labelled switch

* load new events into the table when the toggle is clicked so the human doesn't have to wait

* saves auto-load toggle to URL and loads it from there

* clearer name for temporary, fixed featured toggle

* use clsx for row classes in the EventsTable

* remove use of window in actionToUrl of events table logic

* add a test for unusual input to toParams while looking for the source of a bug

* don't allow input that stops events loading in the table

this is a workaround not a fix

* don't allow input that stops events loading in the table

this is a workaround not a fix

Co-authored-by: Paul D'Ambra <paul@posthog.com>
2021-09-22 10:39:18 +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
Paolo D'Amico
6511e4e465
Type and font updates (#6020) 2021-09-22 08:47:52 +03:00
dependabot[bot]
bc2460d040
Bump tmpl from 1.0.4 to 1.0.5 (#6065)
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-22 07:45:17 +02:00
Alex Gyujin Kim
d51f7e9599
fix hidden map, naming, and nits (#6061) 2021-09-22 07:16:25 +02:00
Marius Andra
208517983f
Reload 4 dashboard items at a time (#5875)
* reload 4 dashboard items at a time

* reload all items WIP

* delete dead code

* make visibilityMap default to visible

* fix insight logic props

* bugfix

* pass cachedResults do element

* type for insight logic props

* type and syntax cleanup

* set cached items if present

* fix more type inconsistencies

* fix undefined bug

* simpler refresh checking

* cleanup

* clean results exception

* remove escape hatch

* Revert "make visibilityMap default to visible"

This reverts commit 5e7e1befd5.

* fix TS error

* no separate time conversion bins
2021-09-22 05:08:00 +00: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
ad293d16e7
show tooltips (#6059) 2021-09-21 19:26:32 +02:00
Yakko Majuri
4a3b089c6d
dont identify users as null (#6057) 2021-09-21 19:19:24 +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
Marius Andra
9577e94ac0
Fix eventUsageLogic.ts error if properties is an object (#5940)
* fix error if properties is an object

* simplify
2021-09-21 12:33:00 +00:00
Alex Gyujin Kim
7a0c3dd147
Vertical funnel breakdowns (#5733)
* make funnels horizontal

* move exclusion filter to horizontal tab

* barebones implementation of vertical breakdowns

* refactor bar graph stuff a bit

* add visibility toggle to table

* tie in table logic visibility map to bar display

* remove dummy data

* add table legend

* add graphs to table

* breakdown indices bug

* fix toggling

* fix regression tests and add bar interaction

* remove consoles

* edge cases with long steps and many breakdowns

* fixes from review

* hide behind FF

* actually hide behind FF, fix time conversion bug, and convert visibility map to hidden map

Co-authored-by: Marius Andra <marius.andra@gmail.com>
2021-09-21 14:08:29 +02:00
Marius Andra
e13d8e9b6b
Action step empty field ==> null (#5942)
* save null for empty action steps

* save null for empty action steps in toolbar

* simplify

* fix type

* reset existing empty action step fields
2021-09-21 14:04:17 +02:00
Marius Andra
ef70592603
Usable logic tests (works now!) (#5990)
* mockup usable logic tests

* actually filter

* a little verbosity never hurt anyone

* await

* sync toDispatchActions and toMatchValues working

* get at least one test working

* should await this

* better action awaiting

* cleanup

* smarter logic test action matching

* cleanup

* delete snapshots

* fix titles

* remove .run(), add .then-magic

* cleanup

* more cleanup

* refactor into multiple files

* refactor into multiple files WIP

* finish refactor

* make nodejs compatible

* funnel logic test WIP

* delay and printActions

* fix label

* add more mocks

* only call action if it makes sense

* fix reload issue with funnels and actions

* explicitly connect to this logic

* listener and mount functions for kea-test-utils

* improve tests

* mock out scss files

* rename antd es/ to lib/ for compatibility in jest

* add breakdown test

* funnel test updates

* set pointer to now if running a block with expectLogic

* fix mock

* more mock

* ignore if breakpoint

* reset window history and posthog-js with logic tests

* one more breakpoint

* add test mode ecxeptions

* update kea

* improve funnel test

* merge, but break

* add safeguard

* safer props

* fix test bugs

* clarify window.crypto polyfill

* simplify api.mock

* simple throw if unmocked api

* use a global actionMap pointer, so we could query between logics

* use the global querying

* remove "Scene" hack

* fix type bug

* clarify some variables
2021-09-21 13:39:05 +02:00
Harry Waye
a022e03dab
docs(events): add documentation on index on posthog_event.distinct_id (#5973) 2021-09-20 23:31:34 +02:00
Tim Glaser
3f6d9799f8
Split person asynchronously (#5992) 2021-09-20 22:39:47 +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
Marius Andra
06f3f3a3f3
PyCharm run configurations (#6026)
Adds a bunch of environment-agnostic run configurations that'll make it easier for anyone to get started on PyCharm
2021-09-20 13:03:37 +01:00
Yakko Majuri
72880538ef
fix bug with undefined date on plugin jobs UI (#6029) 2021-09-20 11:45:42 +00:00
PostHog bot
c7d4606a29
Update plugin server to 1.8.3 (#6023)
Co-authored-by: posthog-bot <posthog-bot@users.noreply.github.com>
2021-09-20 09:59:20 +00:00
Yakko Majuri
501a75c168
Allow date as a job payload option (#5996)
* allow datepicker as a job payload option

* accept dates for export from the beginning
2021-09-20 09:32:08 +00:00
Harry Waye
2fb7cf80b5
perf(funnels): add filter on pdi.team_id to speed up query (#5997)
* docs(funnel): add comments around how the funnel query is build for pg

* chore(funnel): explicitly couple `_gen_lateral_bodies` to `_build_query`

`_gen_lateral_bodies` result seems to always be passed to `_build_query`
so it doesn't make too much sense to have them required to be called in
conjunction.

There are probably further changes that could be made. There is some
implicit coupling around the return value and the joining of the bodies
into a LATERAL JOIN, which should be made explicit.

* chore(funnels): reduce the query generation complexity

This is mainly just to make it a little more clear how the query fits
together.

I have done something naughty here in that I have changed from a using a
GROUP BY to using DISTINCT ON for the top level. I think you'd get
uniqueness of funnel path anyway, as each lateral join should only
produce only one result.

* perf(funnels): add filter on pdi.team_id to speed up query

Have tested on prod with team_id=2. Seems to work at making the query
complete in time. Quite quick there but not much data.

There's probably a lot more we could do here but I don't want to burn
too much time on this.

Future improvements could be:

 1. Remove the first subquery and just do a join
 2. Investigate if there's benefit in removing the group by and using
    distinct on. I don't know enough about this tbh.
 3. Remove all the string manipulations with re. Just write up the query
    by hand.
 4. Remove the implicit coupling between query_bodies gen and the `for step,
    qb` look. It's probably best to do this in one pass.

Closes #5519
2021-09-20 08:50:49 +01:00
PostHog bot
a26e9620b7
Update plugin server to 1.8.2 (#6012)
Co-authored-by: posthog-bot <posthog-bot@users.noreply.github.com>
2021-09-18 10:21:45 +02:00
Michael Matloka
a7a490dbdb
Refactor organization members component (#6015)
* Import change from per-project access branch

* Refactor organization members component

* Add a comment describing `getReasonForAccessLevelChangeProhibition`
2021-09-17 21:10:38 +00:00
Kunal
e09e2e9532
add alpha tag to mv test, make CTAs more obvious (#6004)
Co-authored-by: kunal <kunal@Kunals-iMac.hsd1.ca.comcast.net>
2021-09-17 12:09:38 -07:00
Marius Andra
54b33624a4
remove unused var (#6018) 2021-09-17 18:58:24 +00:00
posthog-contributions-bot[bot]
52a2cda224
🤖: Add csykes as a contributor 🎉 (#6016) 2021-09-17 17:17:08 +01:00
posthog-contributions-bot[bot]
65eca01c43
🤖: Add skabbes as a contributor 🎉 (#6014)
* docs: update README.md

* docs: update .all-contributorsrc

Co-authored-by: posthog-contributions-bot[bot] <80958034+posthog-contributions-bot[bot]@users.noreply.github.com>
2021-09-17 17:04:03 +02:00
posthog-contributions-bot[bot]
7484f043e3
🤖: Add banagale as a contributor 🎉 (#6013)
* docs: update README.md

* docs: update .all-contributorsrc

Co-authored-by: posthog-contributions-bot[bot] <80958034+posthog-contributions-bot[bot]@users.noreply.github.com>
2021-09-17 17:00:05 +02:00
Tim Glaser
121665fbd0
Create SECURITY.md (#6009)
* Create SECURITY.md

* Update SECURITY.md

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

Co-authored-by: Michael Matloka <dev@twixes.com>
2021-09-17 15:31:10 +02:00
Li Yi Yu
3f9a6bf357
Saved insights creation flow (#5702)
* dropdown menu

* creation buttons setup

* temp save

* editing name/description mode

* clean up

* fix bug

* new main nav button

* wording

* undo removal

* fix test

* fix logic flow with new tab insight creation

* fix functionalities

* clean up props and fix toast

* prettier

* fix lint error

* try to fix annotations menu item test

* do not create new insight upon tab switch

* view and edit mode, final clean up, bug fixes

* clean up insights without the feature flag

* update insight only when it exists

* clean up and fix bugs

* prettier

* do not run create insight code on dashboards
2021-09-17 14:36:18 +02:00
dependabot[bot]
cb7352c75b
Bump axios from 0.21.1 to 0.21.4 in /plugins (#5881)
Bumps [axios](https://github.com/axios/axios) from 0.21.1 to 0.21.4.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v0.21.1...v0.21.4)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-17 11:42:20 +02: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
Marius Andra
9aa06a8b95
reset new events when changing events page filter (#5957) 2021-09-17 11:33:52 +02:00
Marius Andra
87f5a77040
Delete session recording events with one db query (#6006)
* delete session recording events with one db query

* add tech debt comment, remove dead code
2021-09-17 10:59:23 +02:00
Paolo D'Amico
89b0a1335b
Optimize Dockerfile build (#5988) 2021-09-17 09:22:12 +02:00
Alex Gyujin Kim
9062001960
Unordered funnel quirks (#6000)
* switch out icons and add checks

* spelling is hard
2021-09-16 14:46:50 -07:00