0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 09:14:46 +01:00
Commit Graph

105 Commits

Author SHA1 Message Date
dependabot-preview[bot]
bf164b216a
Bump whitenoise from 5.0.1 to 5.2.0 (#3538)
Bumps [whitenoise](https://github.com/evansd/whitenoise) from 5.0.1 to 5.2.0.
- [Release notes](https://github.com/evansd/whitenoise/releases)
- [Changelog](https://github.com/evansd/whitenoise/blob/master/docs/changelog.rst)
- [Commits](https://github.com/evansd/whitenoise/compare/v5.0.1...v5.2.0)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-01 20:11:07 +01:00
dependabot-preview[bot]
f2d7a962e5
Bump django-deprecate-fields from 0.1.0 to 0.1.1 (#3536)
Bumps [django-deprecate-fields](https://github.com/3YOURMIND/django-deprecate-fields) from 0.1.0 to 0.1.1.
- [Release notes](https://github.com/3YOURMIND/django-deprecate-fields/releases)
- [Commits](https://github.com/3YOURMIND/django-deprecate-fields/compare/0.1.0...0.1.1)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-01 20:02:30 +01:00
dependabot-preview[bot]
8ef31567db
Bump asgiref from 3.2.7 to 3.3.1 (#3535)
Bumps [asgiref](https://github.com/django/asgiref) from 3.2.7 to 3.3.1.
- [Release notes](https://github.com/django/asgiref/releases)
- [Changelog](https://github.com/django/asgiref/blob/master/CHANGELOG.txt)
- [Commits](https://github.com/django/asgiref/compare/3.2.7...3.3.1)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-01 20:02:25 +01:00
dependabot-preview[bot]
b13bd73e85
Bump psycopg2-binary from 2.8.4 to 2.8.6 (#3543)
Bumps [psycopg2-binary](https://github.com/psycopg/psycopg2) from 2.8.4 to 2.8.6.
- [Release notes](https://github.com/psycopg/psycopg2/releases)
- [Changelog](https://github.com/psycopg/psycopg2/blob/master/NEWS)
- [Commits](https://github.com/psycopg/psycopg2/commits)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-01 20:01:36 +01:00
dependabot-preview[bot]
5ae87afecd
Bump pytz from 2019.3 to 2021.1 (#3545)
Bumps [pytz](https://github.com/stub42/pytz) from 2019.3 to 2021.1.
- [Release notes](https://github.com/stub42/pytz/releases)
- [Commits](https://github.com/stub42/pytz/compare/release_2019.3...release_2021.1)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-01 20:01:13 +01:00
James Greenhill
cd7ccc779e
Run all connections through clickhouse connection pooler (#3495)
* Use clickhouse connection pooler to avoid connections from stepping on eachother

* build reqs
2021-02-26 12:54:35 -08:00
dependabot[bot]
070fa181d2
Bump cryptography from 3.2 to 3.3.2 (#3281)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.2 to 3.3.2.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.2...3.3.2)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-10 12:20:52 +01:00
James Greenhill
55db17eefb
Remove CH Pool as dependency (#3279) 2021-02-09 16:41:10 -08:00
Karl-Aksel Puulmann
58327b406d
Update clickhouse-driver (#3265)
We're having a lot of clickhouse noise in sentry, keeping good hygene by
keeping up.

Changelogs:
- https://github.com/mymarilyn/clickhouse-driver/blob/master/CHANGELOG.md
- https://github.com/ericmccarthy7/clickhouse-pool/releases/tag/v0.4.3
2021-02-09 19:40:50 +02:00
Michael Matloka
481e9ddc6f
Don't install unused pandas and numpy (#3034)
* Don't install unused pandas and numpy

* Use built-in NaN instead of Numpy's
2021-01-21 13:47:18 +01:00
dependabot[bot]
9f9516ab8e
Bump lxml from 4.6.1 to 4.6.2 (#2886)
Bumps [lxml](https://github.com/lxml/lxml) from 4.6.1 to 4.6.2.
- [Release notes](https://github.com/lxml/lxml/releases)
- [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
- [Commits](https://github.com/lxml/lxml/compare/lxml-4.6.1...lxml-4.6.2)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-07 20:12:45 -06:00
Tim Glaser
e8d64117d3
Remove legacy funnel code (#2700)
* Remove legacy funnel code

* recsw

* Fix test
2020-12-08 18:23:46 +01:00
Noah Rickles
d924181fce
Issue #2573, Add django-axes (#2582)
* Closes #2573 adds django-axes middleware with default configuration, disabled during tests

* Added django-axes to requirements

* Moved environment variable declaration in tests script to see if django-axes is disabled during CI tests

* Removed disabling of django-axes in the tests script, updated expected number of queries in tests
2020-12-02 11:01:46 +01:00
Marius Andra
ad86e43cce
bump posthoganalytics to 1.1.3 (#2475) 2020-11-23 17:54:02 +01:00
Michael Matloka
b7b9e8caf3
Remove some seemingly unused requirements and use pip-compile (#2192)
* Remove some seemingly unused requirements

* Remove a few more

* Bring back dependencies of other requirements

* pip-compile prod requirements

* Sync with master updates

* Fix grep

* Revert "Fix grep"

This reverts commit 2e6538cad4.

* Fix grep but using cut

* Clean up and regenerate requirements

* Simplify requirements-dev

* Fix fakeredis import in production

* Black
2020-11-10 10:17:48 +01:00
Michael Matloka
1e44617cdd
Update Django from 3.0.7 to 3.0.11 (and Django-related packages) (#2190)
* Update Django from 3.0.7 to 3.1.3 (and Django-related packages)

* Roll Django back to 3.0.11
2020-11-04 12:40:14 +01:00
Michael Matloka
3f8b95b9e7
Update sentry-sdk from 0.16.5 to 0.19.2 (#2188)
* Update sentry-sdk from 0.16.5 to 1.19.2

* Restore original clickhouse-driver
2020-11-03 14:29:48 +01:00
James Greenhill
83b5273113
Protobufize events to protect from malformed JSON (#2085)
* Protobuf all the things

* oops

* Protobufize events to protect from malformed JSON

* format the generated files (will need to remember this for future)

* format

* clean up kafka produce serializer

* fixes
2020-10-28 15:18:52 -07:00
dependabot[bot]
55dbb55747
Bump cryptography from 2.9 to 3.2 (#2058)
Bumps [cryptography](https://github.com/pyca/cryptography) from 2.9 to 3.2.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/2.9...3.2)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-28 15:53:16 +01:00
Michael Matloka
51c329248f
Make PostHog compatibile with Python 3.9 (#1987)
* Make PostHog compatibile with Python 3.9

* Update actions/setup-python and run Django tests in matrix

* Don't test pypy

* Better specify Py matrix
2020-10-26 11:11:02 +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
Paolo D'Amico
c5ea8220e7
bump drf-exceptions-hog (#1897) 2020-10-15 17:17: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
Michael Matloka
5714ced2f9
Bump drf-exceptions-hog to 0.0.3 (#1845) 2020-10-13 10:48:03 +02:00
Paolo D'Amico
457ae83b80
Report all non-DRF exceptions to sentry (#1773)
* report all non-DRF exceptions to sentry

* update drf-exceptions-hog
2020-09-30 10:32:38 -04:00
James Greenhill
fad85a5f4e
Convert sync execute to use clickhouse connection pool (#1762)" (#1770) (#1771)
* Revert "Revert "Convert sync execute to use clickhouse connection pool (#1762)" (#1770)"

This reverts commit cbb8fb01a9.

* remove runtime requirement from posthog, that is convered in posthog-production

* Bump the max number of connections in the pool
2020-09-30 15:07:10 +01:00
James Greenhill
08f6879343
Bump posthoganalytics requirement for feature flag bugfixes (#1772) 2020-09-30 15:05:13 +01:00
James Greenhill
cbb8fb01a9
Revert "Convert sync execute to use clickhouse connection pool (#1762)" (#1770)
This reverts commit fedd2428aa.
2020-09-30 14:19:03 +01:00
James Greenhill
fedd2428aa
Convert sync execute to use clickhouse connection pool (#1762)
* Convert sync execute to use clickhouse connection pool

* type fixes

* use pool for tests to feel safe
2020-09-29 19:26:58 +01:00
Tim Glaser
6cbe76f401
Bump posthog analytics version (#1751) 2020-09-29 15:51:55 +02:00
James Greenhill
0b371d43ec
Revert "Clickhouse Features (#1565)" (#1748)
This reverts commit 24713b923d.
2020-09-29 12:11:28 +01:00
Paolo D'Amico
b3532c598a
Weekly report email V1 (#1700) 2020-09-29 11:56:29 +01:00
Eric Duong
24713b923d
Clickhouse Features (#1565)
* initial

* migration command

* migrations working

* add modelless views for clickhouse

* initial testing structure

* use test factory

* scaffold for all tests

* add insight and person api

* add basic readme

* add client

* change how migrations are run

* add base tables

* ingesting events

* restore delay

* remove print

* updated testing flow

* changed sessions tests

* update tests

* reorganized sql

* parametrize strings

* element list query

* change to seralizer

* add values endpoint

* retrieve with filter

* pruned code to prepare for staged merge

* working ingestion again

* tests for ee

* undo unneeded tests right now

* fix linting

* more typing errors

* fix tests

* add clickhouse image to workflow

* move to right job

* remove django_clickhouse

* return database url

* run super

* remove keepdb

* reordered calls

* fix type

* fractional seconds

* fix type error

* add checks

* remove retention sql

* fix tests

* add property storage and tests

* merge master

* fix tests

* fix tests

* .

* remove keepdb

* format python files

* update CI env vars

* Override defaults and insecure tests

* Update how ClickHouse database gets evaluated

* remove bootstrapping clickhouse database routine

* Don't initialize the clickhouse connection unless we say it's primary

* .

* fixed id generation

* remove dump

* black settings

* empty client

* add param

* move docker-compose for ch to ee dir

* Add _public_ key to repo for verifying self signed cert on server

* update ee compose file for ee dir

* fix a few issues with tls in migrations

* update migrations to be flexible about storage profile and engine

* black settings

* add elements prop tables

* add elements prop tables

* working filter

* refactored

* better url handling

* add mapping table

* add processing to worker task

* working cohort with actions

* add cohort property filtering

* add cohort property filtering

* reformat and add cohort processing

* prop clauses

* add util

* add more util

* add clickhouse modifier

* Clickhouse Sessions (#1623)

* sessions sql

* skeleton

* add endpoint

* better tests

* sessions list

* merge clickhouse-actions

* added session endpoint

* sessions sql working again

* add clickhouse modifier

* session avg with props working

* add dist

* tests working (no list)

* list working

* add formatting

* more formatting

* fix tests

* dummy commit

* fix types

* remove unnecessary improt

* ignore type when importing from ee in task

* fix test running

* Clickhouse Trends Base (#1609)

* initial working

* date param almost working

* fix date range and labels

* fixed monthly math

* handle compare

* change table

* using new event ingestion

* direct query actions working

* remove interface

* fix date range

* properties initial working

* handle operator

* handle operator

* move timestamp parse

* move more to util

* inital breaking down working

* working cohort breakdown

* some tests running

* fix sessions

* cohort tests

* action and interval test

* reorder cohort filtering

* rename retention test

* fix inits

* change multitenancy tests

* fix types

* fix optional types

* replace ch_client.execute with sync_execute

* replace ch_client.execute with sync_execute, part 2

* Clickhouse Stickiness + Process Event (#1654)

* generate clickhouse uuid script

* set CLICKHOUSE_SECURE=False by default if running in TEST or DEBUG

* convert person_id to UUID, make adding `person_id` optional, add distinct_ids already in the `create_person` function

* Fix test_process_event_ee.py, remove all calls to Person.objects.*

* add back util

* fix broken imports

* improve process_event test clickhouse queries

* Basic stickiness query

* Clickhouse Stickiness tests

* stickiness test [WIP, actions fail]

* generate clickhouse uuid script

* change default test runner if PRIMARY_DB=clickhouse

* fix stickiness test for actions

* fix merge bug

* remove _create_person stub; cohort person_id is UUID now

* fix typing

* Clickhouse trends process math (#1660)

* most of process math works

* all process math

* fix ordering issue

* unusued imports

* update property comparison for process_event_ee

* indentation wrong missing calls

* demo users and events (#1661)

* finish breakdown filtering tests and reformat label function

* add increment to demo_data

* update demo data populating

* Add people endpoint for ch (#1670)

* add people endpoint for ch

* stickiness people

* fix value padding

* add process math to breakdown and

* add limit

* fix tests

* condensed code

* converted test to factory

* add people tests

* add month handling

* add typing fix

* change people test handling

* fix tests

* Clickhouse funnels 2 (#1668)

* add elements to create_event

* WIP closes #1663 Add funnels to clickhouse

* Make funnels work

* Clean up

* Move filtering around

* Add mypy tests and fix

* Performance improvements

* fix person tests again

* add people for funnel endpoint

* fix prop numbering

Co-authored-by: Marius Andra <marius.andra@gmail.com>
Co-authored-by: Eric <eeoneric@gmail.com>

* merge master

* add retention

* update types

* more typing errors

* fix types

* bug with kafka payload, elements insert, and demo data

* Clickhouse Paths (#1657)

* paths clickhouse test (fails)

* add elements to create_event

* make this fail for clickhouse

* hardcoded query that returns good results for $pageviews, no filters yet

* clean up queries

* bound by time, fix 30min new session boundary

* support screen and custom events

* add properties filter

* paths url

* filter by path start

* better path start test

* even better path start test

* start from the first "path start" in a group

* test for person_id in paths

* partition by person_id for POSTGRES paths

* partition by person_id for Clickhouse paths

* clean up order in paths test

* clean up order in paths test

* join elements

* force element order on element group creation

* remove "order" when creating elements in tests and demo

* get list of elements for paths

* add limit to paths query

* use materialized view

* rename "element_hash" to "elements_hash" (no change in db)

* cull rows that are definitely unused

* simplify query

* New highly optimized paths clickhouse query

* start_point for $autocapture paths

* extract event property values from clickhouse

* prevent crash

* select one element sql

* get elements for event

* remove lodash

* remove host from $pageview path elements if same domain as incoming path

* show metadata based on loaded paths filter, not in flight filter

* fix order (all soures and targets in order, not all sources first, then all targets after) - makes for a better looking graph

* add test that makes the Postgres paths query fail

* fix postgres paths --> no fuzzy matching, breaks "starts with" for urls and gives too many incorrect start points

* create automatic /demo urls that match the real urls (no ending /)

* fix elements queries

* path element joins

* create persons via postgres in paths test

* change serializers back to id

* fix tests with uuid

* fix demo

* more bugs

* fix type

* change now to timezone aware

* [clickhouse] retention filters (#1725)

* implemented target entity and prop filtering

* add insight view override

* fix endpoint and filters

* include tests

* fix tests

* add period filtering

* .

* fix pg param name

* add filtering params to both queries in retention sql

* fix param again

* change to todatetime

* change tz to timezone

* add back timezone in model/event

* [clickhouse] feature flag endpoint requests (#1731)

* add feature flags to endpoints

* add flags to endpoints that check on request

* remove magic strings and fill in missing flags

* fix types

* add missing flag

* change from iso

* fix more timestamps and comparator

* change _people to get_people in actions view

* remove action and cohort populating

Co-authored-by: James Greenhill <jams@uber.com>
Co-authored-by: Marius Andra <marius.andra@gmail.com>
Co-authored-by: Tim Glaser <tim.glaser@hiberly.com>
2020-09-29 06:36:50 -04:00
Paolo D'Amico
6320d05b08
Use drf-exceptions-hog package (#1732) 2020-09-29 09:07:51 +01:00
Michael Matloka
9d7dae201a
Make production docker-compose.yml generated (#1704)
* Make production docker-compose.yml generated

* Move "version" to top

* Update instructions

* Leave a fallback docker-compose.yml

* Fix grammar

* Update instructions

* Delete docker-compose.proxy.yml

* Improve error handling

* Update script

* Update wording
2020-09-28 20:50:38 +02:00
Marius Andra
dd7e38c5b5
Clickhouse Elements Dedup (based on master) (#1698)
* Use ReplacingMergeTree for elements, remove element_groups and use elements_hash as a virtual "pk"

* remove unused ELEMENT_GROUP_TABLE_SQL

* merge fixes

* use redis cache to avoid writing duplicate elements to clickhouse

* move fakeredis to requirements.txt

* add team_id to cache key

* remove elements_group kafka table references

* add elements_hash to clickhouse element serializer

* fix cache key

* rename few keys

* add test runner to ease pycharm dev

* fix a some mypy errors

* remove typo

Co-authored-by: Eric <eeoneric@gmail.com>
2020-09-24 06:47:28 -04:00
James Greenhill
adeb7694cc
Publish events to Kafka for consumption (#1644)
* Publish events to Kafka for consumption

* Commit avro idl's for event schemas

* convert client to use github.com/dpkp/kafka-python

* events loaded into clickhouse from Kafka

* remove cruft

* Publish events to Kafka for consumption

* convert client to use github.com/dpkp/kafka-python

* remove cruft

* include kafka migrations

* bugfixes for migrations

* use constants for consistency

* wrap up local migrations

* small fixes

* tune ups
2020-09-15 20:04:38 -07:00
James Greenhill
dedf5582c1
first chunk of clickhouse framework (#1613)
* first chunk of clickhouse framework

* prod, not dev docker-compose.yml

* add clickhouse sql files
2020-09-08 16:12:27 -07:00
James Greenhill
c2e03a3a46
Revert this to bring back the working copy of ee / clickhouse (#1588) 2020-09-04 21:12:07 -07:00
James Greenhill
8e26357770
Async writes to clickhouse (#1585)
* Initial commit async-ing clickhouse

* Async writes to clickhouse

* deconflict master

* sync events listing

* mypy checks
2020-09-04 17:46:02 -07:00
James Greenhill
5506135c3c
Bring back clickhouse changes along with queue size metrics (#1579)
* Revert "Revert "Clickhouse setup (#1463)""

This reverts commit 7f2cab4b93.

* add queue backlog to _stats endpoint

* celery queue length into heartbeat -> statsd

* reformat

* type check fixes

* bump expected number of queries to 8

Co-authored-by: Eric <eeoneric@gmail.com>
2020-09-04 13:44:53 -07:00
James Greenhill
7f2cab4b93 Revert "Clickhouse setup (#1463)"
This reverts commit a0327587cb.
Time to process events shot way up and logs are missing.
2020-09-03 19:27:02 -07:00
James Greenhill
c0a3c4b96b
explicitly use python-statsd as lib (#1570) 2020-09-03 15:04:00 -07:00
Eric Duong
d9baa2929e
remove statsd (#1568) 2020-09-03 16:49:53 -04:00
Eric Duong
a0327587cb
Clickhouse setup (#1463)
* initial

* migration command

* migrations working

* add modelless views for clickhouse

* initial testing structure

* use test factory

* scaffold for all tests

* add insight and person api

* add basic readme

* add client

* change how migrations are run

* add base tables

* ingesting events

* restore delay

* remove print

* updated testing flow

* changed sessions tests

* update tests

* reorganized sql

* parametrize strings

* element list query

* change to seralizer

* add values endpoint

* retrieve with filter

* pruned code to prepare for staged merge

* working ingestion again

* tests for ee

* undo unneeded tests right now

* fix linting

* more typing errors

* fix tests

* add clickhouse image to workflow

* move to right job

* remove django_clickhouse

* return database url

* run super

* remove keepdb

* reordered calls

* fix type

* fractional seconds

* fix type error

* add checks

* remove retention sql

* fix tests

* add property storage and tests

* merge master

* fix tests

* fix tests

* .

* remove keepdb

* format python files

* update CI env vars

* Override defaults and insecure tests

* Update how ClickHouse database gets evaluated

* remove bootstrapping clickhouse database routine

* Don't initialize the clickhouse connection unless we say it's primary

* .

* fixed id generation

* remove dump

* black settings

* empty client

* add param

* move docker-compose for ch to ee dir

* Add _public_ key to repo for verifying self signed cert on server

* update ee compose file for ee dir

* fix a few issues with tls in migrations

* update migrations to be flexible about storage profile and engine

* black settings

* add elements prop tables

Co-authored-by: James Greenhill <jams@uber.com>
2020-09-03 10:27:45 -07: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
Michael Matloka
a5c9733b4c
Upgrade Sentry (#1439) 2020-08-20 16:34:04 +02:00
James Greenhill
a8d545aaa3
StatsD attempt v2. Now with more optionality! (#1336)
* Add django-statsd for emitting performance metrics to statsd

* prefix metrics with debug unless overwritten

* Only include statsd middleware if the STATSD_HOST env var is set

* Clean up and have logic in one if block
2020-08-04 10:04:43 +02:00
Tim Glaser
f5933cb087
Revert "Add django-statsd for emitting performance metrics to statsd (#1317)" (#1325)
This reverts commit 76dc8dcf3e.
2020-08-03 12:18:09 +02:00
James Greenhill
76dc8dcf3e
Add django-statsd for emitting performance metrics to statsd (#1317)
* Add django-statsd for emitting performance metrics to statsd

* prefix metrics with debug unless overwritten
2020-07-31 16:17:01 -07:00