0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-25 11:17:50 +01:00
Commit Graph

26 Commits

Author SHA1 Message Date
Marius Andra
e0d2582e32
feat(hogvm): hogvm bytecode action matching in the plugin server (#16937) 2023-08-15 15:37:19 +02:00
Ben White
cd2f7f398a
feat: Optimised blob storage team loading (#16486) 2023-07-12 10:21:06 +02:00
Tomás Farías Santana
72dd012cf2
fix: Update tests to use new number of retries (#16346) 2023-07-03 11:54:59 +02:00
Xavier Vello
3414f8ebbc
chore(ingestion): re-introduce rdkafka consumer alongside kafkajs (#16048) 2023-06-20 14:29:26 +02:00
Xavier Vello
bece269c32
perf(ingestion): revert rdkafka consumer for both ingestion queues (#15711)
* Revert "perf(ingestion): use rdkafka consumer for both ingestion queues (#15695)"

This reverts commit fea9e4d77c.

* format

* fix split test

* no really, fix the test

---------

Co-authored-by: Harry Waye <harry@posthog.com>
2023-05-30 17:02:11 +01:00
Xavier Vello
fea9e4d77c
perf(ingestion): use rdkafka consumer for both ingestion queues (#15695) 2023-05-25 10:42:55 +02:00
Harry Waye
616389713b
revert: use rdkafka consumer for analytics ingestion and onEvent (#15469)
Revert "chore: use rdkafka consumer for analytics ingestion and onEvent (#15432)"

This reverts commit 85bb582cee.
2023-05-10 12:22:38 +00:00
Harry Waye
85bb582cee
chore: use rdkafka consumer for analytics ingestion and onEvent (#15432)
This _should_ give us better performance and reliability, but it's
hard to tell without a lot of testing. Will monitor closely on rollout.

Note that this will require a delete on the old consumer members as they
are using round eager robin partition strategy, whereas this is using
the cooperative sticky partition strategy. librdkafka doesn't support
mixing the two, unlike the Java Kafka Client.

---------

Co-authored-by: Tiina Turban <tiina303@gmail.com>
2023-05-10 11:15:02 +00:00
Harry Waye
cff0dab1ee
fix(plugin-server): send headers as well with KafkaProducerWrapper (#15382)
I forgot to pass this through. I think we nuked the buffer tests so was
only apparent in production :grimace:
2023-05-04 15:28:53 +00:00
Tomás Farías Santana
5d7900dfd5
feat: Add sent-at property during normalizeEvent (#15151) 2023-04-21 11:31:59 +02:00
Raquel Smith
bc9b449ae5
fix: set msclkid on person like gclid (#14386)
* set msclkid on person like gclid

* fix typos (thx copilot)
2023-02-24 19:35:35 +00:00
Tomás Farías Santana
1e94d8e138
feat(ingestion-slowlane): Re-route events in plugin-server on capacity exceeded (#14211)
* feat(ingestion-slowlane): Add token-bucket utility

* feat(ingestion-slowlane): Re-route overflow events

* fix: Import missing stringToBoolean

* fix(ingestion-slowlane): Flip around kafka topics according to mode

* refactor(ingestion-slowlane): Use dash instead of underscore in filename

* fix(ingestion-slowlane): Do not increase tokens beyond bucket capacity

* feat(ingestion-slowlane): Add ingestion-overflow mode/capability/consumer

* feat(ingestion-slowlane): Add ingestion warning for capacity overflow

* test(ingestion-slowlane): Add test for ingestion of overflow events

* fix(ingestion-slowlane): Rate limit warnings to 1 per hour

* test(ingestion-slowlane): Add a couple more tests for overflow re-route

* fix(slowlane-ingestion): Look at batch topic to determine message topic

* refactor(slowlane-ingestion): Use refactored consumer model

* fix(slowlane-ingestion): Undo topic requirement in eachMessageIngestion

* refactor(slowlane-ingestion): Only produce events if ingestionOverflow is also enabled

* refactor(slowlane-ingestion): Use an env variable to determine if ingestionOverflow is enabled

* chore(slowlane-ingestion): Add a comment explaining env variable
2023-02-16 14:30:13 +01:00
Yakko Majuri
90f1b16285
feat(ingestion): remove postgres dependency from capture endpoint (#12802)
* add support for token field in kafka message

* formPipelineEvent

* rename pipeline files according to new order

* wip team_id and anonymize ips

* conditional handlers and tests

* some plugin server fixes

* fix capture bug

* fix

* more fixes

* fix capture tests

* pipeline update

* fix + investigate database resets

* fix import order

* testing and typing updates

* add test for capture endpoint

* testing

* python typing

* plugin server test

* functional test

* fix test

* another fix

* make sure no team ids clash in tests

* fix

* add more metrics and logs

* cache nulls

* updates

* add more metrics
2022-11-23 09:55:26 -03:00
Yakko Majuri
4f372c05f9
feat(plugin-server): simplify groups caching (#12403)
* refactor(plugin-server): simplify groups caching

* add multi groups test

* remove comments

* fix type, add debug

* fix

* stringify

* add groups created_at to types

* more test fixes

* use the right clickhouse timestampo format

* update created at to ch format in tests

* finally

* more fixes
2022-10-25 15:35:47 -03:00
Karl-Aksel Puulmann
4d1c0e45fb
feat(app-metrics): Gather and show information on errors (#12250)
* Add dependencies

* WIP: Gather error context

* Downgrade package

* Update tracking logic

* Query errors along with app metrics/export metrics

* last_seen

* Fetch and show errors table underneath metrics

* Sorting order

* Endpoint for fetching sample error details for an error

* Render error details drawer

* Render tabs in ErrorDetailsDrawer

* Tests for AppMetricsErrorsQuery

* Tests for AppMetricsErrorDetailsQuery

* Tests for historical_export_metrics

* Update existing app metrics API tests

* /error_details endpoint tests

* Update retries tests

* Update v2 historical exports tests

* Tests for app-metrics.ts

* run prettier

* Avoid reloading data on table sorting

* Fix fat-finger
2022-10-18 09:58:08 +03:00
Karl-Aksel Puulmann
1c96763bf0
feat(app-metrics): Set up schema and data gathering of app metrics (#12143)
* Add new app_metrics feature available on scale and enterprise

* chore(ingestion): cache available_features for a longer period in OrganizationManager

This will come in handy for app metrics and is generally a performance win

* Add service to track app metrics

* refactor(historical-exports): Move retry limit handling code to same place as other error handling

* Track app metrics in processEvent/onEvent/exportEvents and historical exports

* Add mising app-metrics file

* Add missing __init__.py module

* Use correct topic + columns for app metrics

* Add a placeholder schema

* Set timestamp correctly

* Fix a typeerror in organization-manager.ts

* Schema fixup

* Add test showing read-own-writes logic

* Remove unneeded TODO

* Add missing constant

* Simplify flushing logic

* Stabilize VM tests

* Use correct sharding key

* Revert hooks changes
2022-10-12 11:30:58 +03:00
Karl-Aksel Puulmann
30f59dfef2
feat(historical-exports): Include historical exports finishing in activity log (#12068)
* Add a is_system flag to activity logs

* Allow writing activity logs from within plugin-server

* Make changes object non-required

* Render system user information

* Log when export finishes or fails in plugin activity log

* Update activityLogLogic.plugin.test.tsx
2022-10-07 13:25:16 +03:00
Karl-Aksel Puulmann
02bae96be5
fix(historic-exports): $autocapture classnames parsing (#11626)
Re-ingesting historically exported autocaptured events currently fails: https://sentry.io/organizations/posthog2/issues/3552913543/?query=is%3Aunresolved+level%3Aerror

This is because of attr__class being sometimes there under attributes, other times not, so $elements.attr_class could be either a string or an array when leaving posthog in an export.

Rather than fix this at the export, making the parsing logic in ingestion more flexible
2022-09-02 16:28:15 +03:00
Yakko Majuri
cb689c9129
feat: add retries for enqueuing graphile jobs (#11561)
* feat: add retries for enqueuing graphile jobs

* fix tests

* fix tests

* address review

* fix build

* add back mock clear?

* bring back old approach
2022-09-01 14:54:32 -03:00
Tiina Turban
c6b1da5932
fix: hide initial referrer as event property (#11536) 2022-08-30 18:07:02 +02:00
Michael Matloka
7bd3cac2f5
refactor(plugin-server): Unify event types (#10612)
* Simplify Event, ClickHouseEvent, PreIngestionEvent, IngestionEvent

* Unify `ClickhouseEventKafka` with `RawEvent`

* Fix imports

* Eliminate PostgresSessionRecordingEvent

* Parse `Event.elements_chain` too

* Update process-event.test.ts

* Update tests

* Make `IngestionEvent['timestamp']` consistent

* Update tests

* Restore `PreIngestionEvent` vs. `PostIngestionEvent` split

* Update worker.test.ts

* Improve typing a bit

* Update tests to work with mandatory `DateTime`

* Remove ClonableIngestionEvent

* Rename RawEvent -> RawClickHouseEvent

* Rename Event -> ClickHouseEvent

* Update prepareEventStep tests

* Update convertToIngestionEvent behavior back to master

* Update tests to compile

* Use branded types for ISO/Clickhouse timestamp string disambiguation

* Test for parseRawClickHouseEvent()

* Update each-batch tests

* Tests for clickHouseTimestampToDateTime()

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2022-08-15 10:54:09 +03:00
Karl-Aksel Puulmann
6457f0296b
fix(ingestion): Change overrides order when parsing Kafka messages (#10998)
* Move formPluginEvent

* Work around risky behavior

Previously, users could override some important event fields by passing
values in their payload. This bug was introduced way back in https://github.com/PostHog/plugin-server/pull/34

This bug indirectly caused the following sentry errors:
- https://sentry.io/organizations/posthog2/issues/3289550563/?project=6423401&query=is%3Aunresolved+level%3Aerror
- https://sentry.io/organizations/posthog2/issues/3455742732/?project=6423401&query=is%3Aunresolved+level%3Aerror
- https://sentry.io/organizations/posthog2/issues/3382895905/?project=6423401&query=is%3Aunresolved+level%3Aerror

One area I'm unsure on is specifically `ip` field and its expected
behavior, but looking at old code from 2020 it seems we always took the
ip from request rather than looking at event body.
2022-07-27 13:26:50 +03:00
Michael Matloka
313226838c
revert: revert: Revert person properties updates refactor (#10349)
* Revert "revert: Revert person properties updates refactor (#10348)"

This reverts commit 6b3c4691b3.

* sanitizeEvent -> normalizeEvent

* Ensure we handle property updates from within plugins, test

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2022-06-20 09:49:11 +03:00
Neil Kakkar
6b3c4691b3
revert: Revert person properties updates refactor (#10348) 2022-06-17 17:48:20 +02:00
Karl-Aksel Puulmann
d6ec3aedc6
refactor(plugin-server): person state updating (#10321)
* Remove some excessive call signatures

* refactor: move property sanitization outside of .capture

* Move event sanitization into event sanitization logic

* Move person creation/updating logic outside of capture/createSnapshot

* refactor: remove personManager from arguments

* refactor: remove various properties from arguments

* Update `handleIdentifyOrAlias` signature

* refactor: inline timeoutGuard into personStateManager

* refactor: prefix pipeline steps with indexes

* Extract timestamp parsing logic from process-event.ts

* refactor: move timestamp tests over from process-event.ts

* refactor: update process-event.test.ts

* refactor: person-state-manager -> person-state

* Move sanitizeEvent to a more suitable module

* Fix some process-event tests
2022-06-17 09:17:08 +03:00
Karl-Aksel Puulmann
6a6faf600e
fix(plugin-server): chain-to-elements regular expression behavior (#10170)
* refactor tests to be more extensible

* Move elements-related code to separate file

* Copy over tests for element chain

* Handle `undefined` match group

As this test from python indicates, the right-most match group may be
empty. In javascript the behavior for this is different from python and
the match group may be `undefined`

* Update import

* Fix http capabilities
2022-06-07 15:13:25 +03:00