0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 08:40:03 +01:00
Commit Graph

27 Commits

Author SHA1 Message Date
Sandy Spicer
eac199d24a
chore: upgrade python to 3.11 (#23206) 2024-06-27 14:16:27 -07:00
Sandy Spicer
6c23c9bd89
revert: "chore: upgrade python to 3.11 🐍" (#23198)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-24 11:50:48 -07:00
Sandy Spicer
23a789d9fe
chore: upgrade python to 3.11 🐍 (#22932)
🐍
2024-06-21 16:45:42 +00:00
Julian Bez
1c6215981f
fix(types): Fix type errors by adding defaults for optional dataclass fields (#19691)
Fix type errors by adding defaults for optional dataclass fields
2024-01-10 12:28:50 +00:00
Julian Bez
7cabe21ae3
chore: Upgrade pydantic, mypy, and others (#19660)
* Upgrade pydantic and all related
* Upgrade mypy
* Add mypy-baseline

To update baseline when you fix something (only then!) use:

    [mypy cmd] | mypy-baseline sync
2024-01-10 08:32:55 +00:00
Marius Andra
6af31d41bc
feat(hogql): antlr grammar (#13971) 2023-02-07 17:02:29 +01:00
Paolo D'Amico
066721e3c1
Stability & dev experience improvements (#2152) 2020-11-02 14:55:20 +00:00
Michael Matloka
37680e39e0
Add login with Google and account creation with social auth (#1990)
* Add social auth base for Google

* Improve style

* Fix social signup from invite

* Adjust password changing for social logged-in users

* Add social account creation second view

* Fix account creation

* Update login UI

* Add Cypress test for using invites

* Fix typing

* Revert "Add Cypress test for using invites"

This reverts commit d0c60641da.

* Update utils.py

* Address feedback

* Add missing imports

* Improve org invite creation
2020-10-29 03:43:32 +01:00
Michael Matloka
533c7df105
Organization<>Team<>User structure (closes #1540) (#1562)
* Backend changes to implement #1461

* Added the missing migration files

* Fixes Typecheck errors

* Refactor request.user.team_set.get() to use request.user.team

* Updated user patch method to change current_team on team id instead of name

* Merged migration file

* Changes team property to return first item in queryset

* Fixes failing tests

* Changed User api to return the ids of the teams they are currently part of

* Frontend for changing teams

* Update and simplify migrations

* Improve team and user buttons

* Make team changing backend more logical

* Improve current_team mechanics

* Update test_team.py

* Fix Team.objects.create_with_data

* Update migration

* Update tests

* Make setup_review more convenient

* Add Organization and OrganizationMembership

* Replace is_admin with level

* Extend API

* Update team.py

* Improve modeling

* Improve handling of new mechanics

* Add proper migration

* Remove _ensure_organization_and_team

* Update 0084_org_team_user.py

* Improve user, org and team creation

* Make MembershipLevel more flexible for the future

* Add member deletion

* Fix naive datetime warnings

* Update setup_review.py

* Update API route

* Make PersonalAPIKey changes

* Update models and migrations, fix typing

* Fix typing

* Use MAC-less UUID v1 instead of v4 for better performance

* Add abstract UUIDModel

* Update utils.py

* Update utils.py

* Fix multi/unicast bit

* Update APIs, frontend and tests

* Update pull_request_template.md

* Fix comment

* Fix migration error

* Compress migrations

* Updates with minimal renaming

* More updates

* Make further updates

* Update test_team_user.py

* Fix issues

* Add migration

* Satisfy mypy

* Remove Signup redirect on logged in

* Use uuid1_macless in Person

* Fix typing

* Update tests

* Update /api/team/signup to /api/organization/signup

* Fix mypy issues and update tests

The remaining failures are actually missing functionality (TDD applied), so filling these in.

* Update 0086_org_live

* Make small improvements

* Implement permissions

* Remove now unneccesary membership check

* Update setup_dev.py

* Make small frontend improvements

* Add drf-nested-routers as requirement

* Remove unused import

* Implemented nested routes

* Remove cruft

* Add relevant org/proj/user name to headings

* Fix imports

* Update migration

* Replace unreliable drf-nested-routers with drf-extensions

* Improve unset team handling

* Make org and team creation proper

* Update migration

* Fix migration

* Update TopContent

* Update command palette for new sidebar structure

* Remove deprecated demo data deletion

* Assume that each org has a project and fix typing

* Require paid plan for multiple orgs and projects

* Make HogFlix demo a separate team

* Update migration

* Slightly improve style

* Adjust page layout bottom padding

* Make user dropdown nicer

* Fix base app tests

* Satisfy mypy

* Fix test_leave_organization

* Improve wording

* Possibly fix import

* Remove misplaced None check

* Enhance org and teams APIs and add tests

* Fix /api/projects for particular Team

* Improve invites and demo data

* Address feedback

* Put everything related to billing on Organization

* Fix minor issues

* Simplify invitation creation

* Update team model

* Make orgs and projects premium only on self-hosted

* Improve testing

* Update migration

* Remove extra License import

* Fix minor issues

* Fix Django tests

* Fix Cypress

* Fix yarn build

* Fix TeamSignupViewset

* Fix posthog-production incompatibility

* Remove extraneous insight endpoint registration

* Adjust tests for posthog-production

* Simplify invitations and fix email validation

* Address all feedback

* Satisfy mypy

* Update migration

* Fix constraint removal in migration

* Update tests

* Fix test creation edge case

* Run posthog-production CI tests against this branch and teams-live

* Ensure that js_posthog_api_key is always passed

* Fix preflight check pre-login

* Update cypress tests

* Update instanceStatus.js

* Bring ee tets up to par

* Bring actions-ux-201012 back

* Cypress retry in cypress.json

* Revert "Run posthog-production CI tests against this branch and teams-live"

This reverts commit d79cb844d8.

Co-authored-by: anna <ms.annaphilips@gmail.com>
Co-authored-by: Anna Philips <aphilips@matmacorp.com>
2020-10-22 10:58:32 +02:00
Michael Matloka
f71e011a86
Command palette (#1819)
* add hotkey base

* add platform check

* Rename CommandBox to CommandPalette

* Add styled-components

* Restructure CommandPalette and add Esc handling

* Update utils.js

* add search box

* Add logic types

* Implement base logic

* Fix scroll prevention

* Update logic and add goto command base with Fuse fuzzy serach

* ux hotkey

* Implement command (de)registration

* minor fix

* base UI

* error message & hints

* command groups UI

* Add commands search

* Make commands work

* Prepare palette for fuzzy search and add basic labeling

* ui adjustments

* ui

* Improve colors

* switch to global command

* Optimize resolution

* global go to commands

* abstract item selection logic to command palette

* Update casing and types

* Add conditional useCommands

* Improve results

* keyboard nav

* keyboard nav fix

* removed double fuse (synonyms broken)

* Update style

* Fix highlighting

* Remove extra style

* conditional go to commands

* add mouse hover handling and rename functions

* remove mac check

* add more commands

* added insights stub pages

* Add command components

* refactor logic

* Update styling

* Remove extraneous `input`

* load custom dashboards to command palette

* Add input styling

* Add write icon

* Refactor results

* minor adjustments

* add person search

* remove papercups fully

* fix input indexing

* fix result executing empty

* Add command grouping and improve navigation

* add urls

* make logic explicit

* fix error with hadnler

* Remove redundant border-top

* add trend functions

* personal api key stub

* Add command palette toggle button

* Fix things

* fix personal api keys

* copy api key to clipboard

* Add toggle text

* Improve palette UX and perform refactoring

* Improve UX and add palette usage reporting

* tests refactor

* filter person list

* refactor api person tests

* add squeak

* deprecate by_distinct_id & by_email person endpoints

* Optimize squeak

* fix typegen error

* use new filters in frontend

* Optimize squeak

* key identifier refactor

* fix mypy

* removed unused code

* Make custom command UI more coherent

* Add calculator to palette

* Use equal sign

* Make palette button nicer

* Add lodash back officially and show palette suggestions

lodash is still used in a few places, but it was not in package.json. The reason this was working was that lodash is a dependency of some other depedencies, but this was fragile. It's still not ideal to use this, but at least this is now not a hack the way it was.

* Remove isHint

* Optimize graph time range command

* Move command results grouping to Kea logic

* Fix result focus autoshift

* Improve palette result focusing

* Adjust for window.posthog being optional

* add test for third-party person filters

* Remove styled-components in favor of .scss files

* Remove redundant container class

* Use insect (sic!) squeak instead of pig squeak

* Show only unique palette results

* Fix palette overlay

* Add powerful command building protocol CommandFlow

* Fix minor issues

* Always show scope when flow active

* Use custom label icon

* Add feedback sharing command

* block command input from being captured in screen recording

at least until we can figure out how to capture this info in a privacy-preserving way

* Hide palette button on narrow screens

* Improve responsiveness

* Fix palette feedback sending

* Fix Esc handling

* Add Message Sent info

* Fix Message Sent info

* Fix dashboard creation and null name handling

* Rename Cy tests to JS convention

* Add basic Cypress test

* Address feedback

Co-authored-by: Eric <eeoneric@gmail.com>
Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2020-10-13 15:44:56 +02:00
Tim Glaser
92e8bbd283
[Clickhouse] Event list (#1787)
* convert sessions table logic to TS

* convert rest of sessions to TS

* sessions table logic refactor, store date in the url

* add back/forward buttons

* load sessions based on the URL, not after mount --> avoids duplicate query if opening an url with a filter

* prevent multiple queries

* throw error if failed instead of returning an empty list

* date from filters

* rename offset to nextOffset

* initial limit/offset block

* indent sql

* support limit + offset

* load LIMIT+1 sessions in postgres, pop last and show load more sign. (was: show sign if exactly LIMIT fetched)

* based offset is always 0

* default limit to 50

* events in clickhouse sessions

* add elements to query results

* add person properties to sessions query response

* show seconds with two digits

* fix pagination, timestamp calculation and ordering on pages 2 and beyond

* mypy

* fix test

* add default time to fix test, fix some any(*) filter issues

* remove reverse

* WIP event list

* Events progress

* Finish off event listing, skip live actions for now

* Fix mypy

* Fix mypy again

* Try fixing mypy

* Fix assertnumqueries

* Fix tests

* Fix tests

* fix test

* Fix tests

* Fix tests

* Fix tests again

Co-authored-by: Marius Andra <marius.andra@gmail.com>
Co-authored-by: Eric <eeoneric@gmail.com>
2020-10-01 15:47:35 +02:00
Paolo D'Amico
b3532c598a
Weekly report email V1 (#1700) 2020-09-29 11:56:29 +01:00
Tim Glaser
c59ab4c3a7
Add django extensions (#1541) 2020-09-01 16:07:43 +02:00
Michael Matloka
c040601f49
Personal API keys and Zapier integration (#1281)
* Add missing migration

* Add generate_random_token() model util

* Move PublicTokenAuthentication to utils

* Make use of generate_random_token

* Add User.personal_access_token field

* Add PersonalAccessTokenAuthentication

* Fix PublicTokenAuthentication

* Fix migration and auth import

* Add personal_access_token to user API

* Update Setup.js

* Support trailing slash in API

* Improve PAT auth quality

* Add django-rest-hooks requirement

* Update settings.py for rest_hooks

* Fix django-rest-hooks requirement

* Bring back API routes with no double trailing slash

* Rename posthog.api.team to team_user

* Add API TODO

* Ad PAT auth with X-PAT HTTP header

* Replace User.personal_access_token with PersonalAPIKey model

* Fix PersonalAPIKey max_lengths

* Describe posthog.models.utils.generate_random_token better

* Add personal_api_key to API

* Add authenticate_header to PersonalAPIKeyAuthentication

* Add hook API endpoint

* Use django.utils.timezone in place of datetime.datetime

* Add Personal API Keys to Setup

* Sort personal_api_keys in ORM

* Add Action.on_perform()

* Remove requirements.txt comment

* Add a

* Add REST hook tasks

* Optimize PersonalAPIKeyAuthentication query

* Add a trailing slash version of /e endpoint

* Add team field to PersonalAPIKey model

* Add personal API key support to capture endpoint, get_cached_from_token

* Reject personal API keys from inactive users

* Add extra_properties_json field to /capture

* Improve PAK auth header regex

* Use custom hook model

* Deliver hooks

* Handle action.on_perform

* Consolidate userLogic in userLogic.tsx

* Update PersonalAPIKeys.js

* Make PersonalAPIKey foreign keys read-only

* Update requirements/dev.txt

* Make PersonalAPIKeys TSX

* Fix conflict

* Fix migration

* Fix minor mishaps

* Update and fix tests

* Use CharField of random 32 bits as hook.id

* Fix conflicting migrations

* Fix ValidationError in HookSerializer.validate_event

* Use query param in /api/event/actions ID filtering

* Rename endpoint `hook` to `hooks`

* Satisfy mypy

* Add tests

* Use DRF serialization in action_defined and annotation_created triggers

* Update migration leafs

* Make mypy ignore rest_hooks

* Update Django signal receiver names

* Update TS dependencies

* Revert "Update TS dependencies"

This reverts commit 7fc26fefcd.

* Add field user to Hook model

* Update migration leafs

* Fix circular import

* Fix some code

* Install git before running pip install in Dockerfiles

* Improve personal API keys UI

* Satisfy mypy

* Reword key label placeholder

* Add personal API key support to /api/user/*

Unfortunately these endpoints are still limited by CSRF protections at the moment, so not accessible outside PostHog itself.

* Improve PersonalAPIKeyAuthentication and add CsrfOrKeyViewMiddleware

* Run collectstatic before test

* Don't install dev dependencies in CI

* Update dependency installation order in CI

* Fix bug and describe PersonalAPIKeyAuthentication

* Fix CI issues

* Fix typing issues

* Fix more typing issues

* Use /api/personal_api_keys to list keys

* Move REST hooks (and therefore Zapier) to ee/

* Refactor personal API logic with kea-loaders

* Add "More about API authentication in PostHog docs."

* Update PersonalAPIKeys.tsx

* Use TestMixin

* Fix "Authentication" that should've been "Authorization"

* Add option to skip self.client.force_login in API tests

* Include team_id and user_id in personal API key serialization

* Update test_hooks.py

* Add personal API key tests

* Remove leftover

* Make ee.settings override posthog.settings

* Don't directly import from models

* Remove unused imports

* Fix mypy issues

* Fix HOOK_DELIVERER

* Use decorator for /api/user PAK auth

* Don't fire REST hook if user doesn't have "zapier" feature

* Import Optional

* Reword to "premium Zapier"

* Make mypy happy

* Fix test_delete_personal_api_key

* Fix misclick

* Fix and test /capture with personal API key

* Make mypy happy

* Remove extra_properties_json

* Resolve migrations

* Remove apt-utils

* Optimize and test PAK user.is_active filtering

* Replace DEBUG true with 1

* Remove unused instance_id

* Improve typing

* Fix deletion toast

* Refactor CopyToClipboard and use it in PAKs

* Use toast.success

* Update migrations

* Fix migration

* Fix migrations

* Complete merge

Co-authored-by: Tim Glaser <tim@glsr.nl>
2020-08-26 10:34:57 +02:00
Tim Glaser
4b1e896888
888 filter on elements (#986)
* Closes #888 filter on elements

* Add joinfield as requirement

* Fix tests

* Use correct element

* Fix paths query

* Delete old migration test

* Clean up

* Add frontend filters for elements, closes #419

* Add element api

* Fix paths and add test

* Keep elements field, otherwise breaks parititons

* Don't use join field

* Remove other join field references

* Fix test

* Add endpoint to get stats on elements

* Add sensible limit

* Put migration back

* Pass team_id as property
2020-06-12 10:03:32 +02:00
Tim Glaser
646d854cc9
Revert "888 filter on elements (#981)" (#985)
This reverts commit a41ef7f7c2.
2020-06-11 16:59:05 +02:00
Tim Glaser
a41ef7f7c2
888 filter on elements (#981)
* Closes #888 filter on elements

* Add joinfield as requirement

* Fix tests

* Use correct element

* Fix paths query

* Delete old migration test

* Clean up

* Add frontend filters for elements, closes #419

* Add element api

* Fix paths and add test

* Keep elements field, otherwise breaks parititons

* Don't use join field

* Remove other join field references

* Fix test

* Add endpoint to get stats on elements

* Add sensible limit

* Put migration back
2020-06-11 16:32:10 +02:00
Tim Glaser
37fa876732
Revert "Closes #888 filter on elements (#917)" (#968)
This reverts commit ac46f09429.
2020-06-09 17:58:18 +01:00
Tim Glaser
ac46f09429
Closes #888 filter on elements (#917)
* Closes #888 filter on elements

* Add joinfield as requirement

* Fix tests

* Use correct element

* Fix paths query

* Delete old migration test

* Clean up

* Add frontend filters for elements, closes #419

* Add element api

* Fix paths and add test

* Keep elements field, otherwise breaks parititons

* Don't use join field

* Remove other join field references

* Fix test
2020-06-08 14:58:51 +01:00
James Greenhill
0f1d74dee6
Add Django-debug-toolbar for profiling requests performance (#768)
* Add Django-debug-toolbar for profiling requests performance

* Only require and import debug-toolbar in dev

* don't bother checking types for debug_toolbar

* mypy configs and try/except for import of debug_toolbar

* include debug toolbar url config
2020-05-18 18:15:31 +01:00
Tim Glaser
7da9287656
595 offload storing events to workers (#615)
* Adds to #595 move capture workload to tasks

* Move tests to tasks

* Move tests from api to tasks

* Finish moving tests around

* Closes #611 alias should find based on alias rather than distinct_id

* Make sure batch still works

* Add tests for slack
2020-04-17 15:38:17 +01:00
Sanket Dasgupta
3738f33e30
Remove drf-yasg in favor of new docs website (#596)
The new documentation at https://docs.posthog.com supersedes
this.

Fixes https://github.com/PostHog/posthog/issues/574
2020-04-15 16:24:10 +01:00
Tim Glaser
4782d54d1f
Configure mypy (#562)
* server/mypy: Enable no_implicit_optional

no_implicit_optional Changes the treatment of arguments with a default value of None by not implicitly making their type Optional.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#none-and-optional-handling

* server/mypy: Enable warn_unused_ignores

warn_unused_ignores: Warns about unneeded # type: ignore comments.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#configuring-warnings

It's best to exclude packages with no typing in mypy.ini rather than in
the code. This waym if tin the future these packages add types it's can
easily be disabled (by removing the exclusion in mypy.ini).

* api/user: Fix user password was not really validated

* api/test/base: Remove unreachable code

Team is created in setup, so no reason for it not to be there (unless
setUp is overriden by child, which as far as I can see is currently not
happening),

* server/mypy: Enable check_untyped_defs

check_untyped_defs: Type-checks the interior of functions without type annotations.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#untyped-definitions-and-calls

* server/mypy: Enable strict_equality

strict_equality: Prohibit equality checks, identity checks, and container checks between non-overlapping types.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#miscellaneous-strictness-flags

* server/mypy: Enable warn_unreachable

Added a fixme for a possible oversight in function that parses JSON.

warn_unreachable: Shows a warning when encountering any code
inferred to be unreachable or redundant after performing type
analysis.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#configuring-warnings

* api/posthog: fix possible bug when batch is not a list

Current code assumes batch is a valid list. If batch is not a list, the
capture handling will cause a 500 error.

* fix stricter mypy

* Use response.json instead of .data

Co-authored-by: Haki Benita <hakibenita@gmail.com>
2020-04-14 11:05:45 +01:00
Marius Andra
3ec4db5ce7 ignore celery for mypy 2020-04-07 14:02:09 +02:00
Tim Glaser
cf8995b574 Add GitLab API URL 2020-04-06 11:08:59 +01:00
Tim Glaser
5336c93658 Add posthog analytics module
- Make sure each user has a distinct id that we can pass
2020-02-10 13:18:01 -08:00
Tim Glaser
7b0b04f0ad Move api stuff around 2020-01-24 11:00:25 -08:00