53 Commits

Author SHA1 Message Date
Lukinoh
9531326682 fix(plugin-server): handle correctly empty attributes during chainToElements (#39020) 2025-11-12 19:24:02 -08:00
Ben White
396e3631d8 feat(node): Added opentelemetry to node services (#37154) 2025-08-26 14:30:03 +01:00
Ben White
b9d7cdb28c fix(node): Flakey test and update jest (#36107) 2025-08-05 14:07:24 +02:00
Ben White
2710e1a034 feat: Sanitize bad characters in token (#31773) 2025-04-30 14:44:14 +00:00
Ben White
fc2c2b403f fix: Secure fetch in node (#31229) 2025-04-16 10:49:13 +02:00
Ben White
1b308916e8 feat(cdp): Refactored logger (#29933) 2025-03-17 12:55:25 +01:00
Rafael Audibert
eda494ef12 fix: Silence several TS errors from plugin-server tests (#29200) 2025-02-25 18:46:02 +00:00
Ben White
f784a460ad feat: New ingestion consumer (#27668)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2025-01-23 10:33:49 +01:00
Ben White
e5c82e7927 feat: Producer refactor (#27672) 2025-01-21 11:12:51 +01:00
Meikel Ratz
8e074bd011 chore(cdp): upgrade jest version (#27320) 2025-01-07 18:59:16 +01:00
Michael Matloka
bfceab6b45 feat(plugin-server): project_id in clickhouse_events_json (#25873) 2024-11-04 23:39:30 +01:00
Ben White
02bf6bb7d8 fix: Rework plugin server redis configs (#25342) 2024-10-03 16:10:20 +08:00
Ben White
16870d63fc feat: Plugin server services refactor - take 2 (#24737) 2024-09-03 11:00:50 +02:00
Ben White
3f56346512 chore: Reverts "Plugin server services refactor (#24638)" (#24733) 2024-09-02 08:43:52 +00:00
Ben White
4684a2bc0d chore: Plugin server services refactor (#24638) 2024-09-02 09:56:13 +02:00
Michael Matloka
7d4554a88d fix(ingestion): Use $os_name as fallback for $os (#24184) 2024-08-06 12:18:12 +02:00
Brett Hoerner
8edc743a7d fix(plugin-server): fix ordering of utm properties so , from the eve… (#21355)
fix(plugin-server): fix ordering of utm properties so ,  from the event win
2024-04-05 07:28:39 -06:00
ted kaemming
644cc6f1f1 fix: createEventsToDropByToken should handle tokens with multiple separators (#20392) 2024-02-17 13:52:46 -08:00
ted kaemming
1e8776eac7 feat(plugin-server): Add capability to use deferred overrides writer and worker (#19112) 2023-12-08 12:33:56 -08:00
Tiina Turban
8f81c31d21 chore: Nuke promiseManager (#19094) 2023-12-05 16:47:41 +01:00
Juraj Majerik
fb62925063 chore(plugin server): add OS version to person properties (#18924) 2023-11-28 13:57:08 +01:00
ted kaemming
9299aa09e5 fix(plugin-server): Remove Postgres-based plugin error logging in favor of existing ClickHouse-based approaches (#18764) 2023-11-27 10:41:36 -08:00
Xavier Vello
9179e65f88 feat(ingestion): use kafka message ts when rate-limiting to overflow (#18119) 2023-10-26 10:49:29 +02:00
Michael Matloka
b7fe004d6b chore(plugin-server): Validate fetch hostnames (#17183)
* chore(plugin-server): Validate fetch hostnames

* Only apply Python host check on Cloud

* Update tests to use valid hook URLs

* Only apply plugin server host check in prod

* Update URLs in a couple more tests

* Only check hostnames on Cloud and remove port check

* Fix fetch mocking

* Roll out hostname guard per project

* Fix fetch call assertions

* Make `fetchHostnameGuardTeams` optional
2023-09-18 14:38:02 +02:00
Ben White
05079fa1a7 feat: Save app properties and others to Person from events (#17393) 2023-09-14 12:57:54 +02:00
Xavier Vello
1b6628055d feat(plugin-server): allow to use several PG connection pools (#17001)
Co-authored-by: Tiina Turban <tiina303@gmail.com>
2023-08-24 11:09:10 +02:00
Marius Andra
59eca63f30 fix: Revert "feat(hogvm): hogvm bytecode action matching in the plugin server" (#17036)
Revert "feat(hogvm): hogvm bytecode action matching in the plugin server (#16937)"

This reverts commit e0d2582e32.
2023-08-15 16:22:19 +01:00
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