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

42 Commits

Author SHA1 Message Date
Ben White
776298d2a8
feat: Action steps refactor (part1) (#22091) 2024-05-07 12:08:13 +02:00
Brett Hoerner
30bafdd382
chore(plugin-server): kafka ack cleanup and metric (#21111)
* cleanup: remove unused team arg from registerLastStep

* cleanup: rename promises to ackPromises to make it more clear thats what they are

* cleanup(plugin-server): make waitForAck explicit/required

* add Kafka produce/ack metrics

* Clarify Kafka produce metric/labels
2024-03-25 13:01:15 +00:00
ted kaemming
05a06d27e4
refactor(plugin-server): Clean up Person Postgres & Kafka code a little bit (#20479) 2024-02-21 11:25:35 -08:00
Brett Hoerner
1f6ce77e66
chore(plugin-server): remove statsd (#19027) 2023-12-05 11:47:12 -07:00
Brett Hoerner
f470984976
chore(plugin-server): add prometheus metrics to match statsd ones, remove unused metrics (#19000) 2023-12-01 08:01:45 -07:00
Brett Hoerner
428542a78a
refactor(plugin-server): combine 2 person merge queries into a single… (#18127)
refactor(plugin-server): combine 2 person merge queries into a single round trip to PG
2023-10-26 10:02:52 -06:00
Tiina Turban
1cdcedb11a
fix: Move redis cache outside of pg transaction (#17509) 2023-09-19 15:26: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
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
Xavier Vello
4b5e41d2cc
chore(plugin-server): add tags to redisGet/Set (#17057) 2023-08-17 16:07:17 +02:00
Marius Andra
8316edc87d
feat(hogvm): save bytecode for actions (#16932) 2023-08-10 11:13:03 +02:00
Harry Waye
9dcb8aa030
chore: fix plugin server tests for acitonMatcher (#16548)
* chore: fix plugin server tests for acitonMatcher

I broke these but there was an issue with CI so they were merges broken
but now maybe they are fixed?

* more fixes

* wip

* wip

* wip
2023-07-13 10:56:43 +01:00
Harry Waye
12d0a29957
chore(plugin-server): simplify action matcher deps (#16429)
* chore(plugin-server): simplify action matcher deps

Specifically this only depends on postgres, so passing in the `DB`
object is unnecessary. This should make refactors easier to e.g. only
load the required dependencies when they are needed.

* pass only postgres to ActionMatcher
2023-07-07 15:02:46 +01:00
Tiina Turban
876ce6a43c
fix: Nuke siteUrlManager reducing PG load (#16290) 2023-07-05 12:19:32 +02:00
Michael Matloka
1aee725409
feat(webhooks): Support person display name preferences and nested properties (#15882)
* Use same logic for `[person]` webhook token as person display in the app

* Allow accessing nested properties in webhook message

* Update hooks.test.ts

* Fix team fetching test

* Update query snapshots

* Update query snapshots

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-05 16:25:39 +00:00
Michael Matloka
39ad3cd68c
feat(actions): Support "Link target contains/matches regex" (#15535)
* Add `ActionStep.href_matching` + `ActionStep.text_matching`

* Use `href_matching` and `text_matching` in matching

* Show new matching options in the UI

* Update query snapshots

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (2)

* Add support in the API

* Fix `LemonLabel` overflow

* Add support in the toolbar

* Update plugin server tests

* Add Django support

* Update query snapshots

* Add Django test

* Don't italicize text input placeholder

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (1)

* Update query snapshots

* Fix typing

* Update query snapshots

* Fix typing more

* Update query snapshots

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (1)

* Update query snapshots

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-25 16:35:02 -07:00
Tiina Turban
bf535847a5
chore: nuke person redis cache (#15458) 2023-05-24 13:46:12 +02:00
Tiina Turban
a5544cf7e4
feat: Async handlers use person info from event (#15307) 2023-05-04 13:25:56 +02:00
Tiina Turban
f065757ae7
revert "chore: person props last-op/ts clean-up" (#14741)
Revert "chore: person props last-op/ts clean-up (#14316)"

This reverts commit 4bf7ddd8e9.
2023-03-14 16:36:44 +00:00
Tiina Turban
4bf7ddd8e9
chore: person props last-op/ts clean-up (#14316) 2023-03-14 16:35:53 +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
Karl-Aksel Puulmann
f07f8763e4
fix(person-on-events): Fix groups caching in ingestion (#12547)
* fix(person-on-events): Fix groups caching in ingestion

We were seeing some groups-related events never get ingested in
playground. Digging in, it turned out that these events were serialized
with invalid timestamps due to cache containing dates in different
formats.

The bug was introduced in https://github.com/PostHog/posthog/pull/12403
and makes for a good case study for this common class of errors

There were multiple practices that could have indicated the error sooner:
1. Tests for the feature mocked out the DB and used a different data
format than what is used properly
2. Some methods related to caching were not properly updated to test the
caching logic
3. timestamps-as-strings: we deal with both ISO and clickhouse-format
timestamps, and the code didn't differentiate between them properly
4. `getGroupsColumns` signature was very loose, allowing for everything
to pass by

This change fixes the issue as well as updates relevant code to be more
in-line with best practices.

* Solve minor typing related issue
2022-11-01 14:27:34 +02: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
Yakko Majuri
8ed495b327
fix: groups data fetching bugs (#12371)
* fix: groups data fetching bugs

* add tests
2022-10-21 12:33:36 -03:00
Tiina Turban
377f2ae47f
chore: Rollout groups properties writes to events (#12233)
* chore: Rollout groups properties writes to events

* forgotten save

* fix test
2022-10-17 09:50:20 -03:00
Karl-Aksel Puulmann
14b420da0a
fix(plugin-server): Fix cohort matching in actions (#11388)
* fix(plugin-server): Remove wild clickhouseQuery in ingestion pipeline

Point queries against clickhouse are slow and we should avoid them.
They're also not instrumented.

The postgres table already used in the method previously contains the
right data. Use that instead.

Reference: https://github.com/PostHog/posthog/blob/master/posthog/models/cohort/cohort.py#L274-L316

* Fixup and test doesPersonBelongToCohort

* Handle NULLs
2022-08-22 11:07:56 +03:00
Karl-Aksel Puulmann
f8c203fe5a
fix(plugin-server): refactor groups caching (#11141)
* Remove unneeded method

* Refactor how groups are handled

* Remove .only
2022-08-05 09:26:45 +03:00
Karl-Aksel Puulmann
4f648268f2
feat(ingestion): Make person loading lazy (#11091)
* fix issues with fetchPerson() and add tests

- fetchPerson() returned extra columns that were not needed

* Add LazyPersonContainer class

* Load person data lazily through the event pipeline

* Make webhooks and action matching lazy

* Update runAsyncHandlersStep

* Return own person properties in process-event.ts

* Remove snapshots that caused pain

* Handle serialization of LazyPersonContainer

* Merge: Handle LHS only existing

.get() would be cached in that case not to do a query, which we can
avoid

* Serialize result args as well

* Make personContainer functional

* Resolve feedback
2022-08-04 09:57:43 +03:00
Yakko Majuri
4bce5dfa8a
feat: (bring back) buffer 3.0 again (#10896)
* Revert "Revert "feat: (bring back) buffer 3.0  (#10874)" (#10883)"

This reverts commit e203bc7cfa.

* reduce graphile load
2022-07-20 12:16:13 +00:00
Yakko Majuri
e203bc7cfa
Revert "feat: (bring back) buffer 3.0 (#10874)" (#10883)
This reverts commit 3e772b8614.
2022-07-19 17:50:06 +00:00
Yakko Majuri
3e772b8614
feat: (bring back) buffer 3.0 (#10874)
* Revert "Revert "feat: buffer 3.0 (graphile) (#10735)" (#10802)"

This reverts commit ca8c4d0271.

* add metrics and error tracking
2022-07-19 16:34:07 +00:00
Yakko Majuri
ca8c4d0271
Revert "feat: buffer 3.0 (graphile) (#10735)" (#10802)
This reverts commit 9a2a9046cb.
2022-07-14 18:24:58 +00:00
Yakko Majuri
9a2a9046cb
feat: buffer 3.0 (graphile) (#10735)
* feat: buffer 3.0 (graphile)

* fixes

* test

* address review

* add test for buffer processAt
2022-07-13 11:32:00 +00:00
Yakko Majuri
985148ee7e
feat: buffer 2.0 (#10653)
* feat: buffer 2.0 proposal

* add tests

* prevent infinite retrying

* perf

* updates

* tweaks

* Update latest_migrations.manifest

* Update plugin-server/src/main/ingestion-queues/buffer.ts

* update

* updates

* fix migrations issue

* reliability uopdates

* fix tests

* test fix

* e2e test

* test

* test

* ??

* cleanup
2022-07-08 10:48:25 +00:00
Yakko Majuri
a598c7b664
feat(persons-on-events): cache + send persons and groups created_at with events (#10457)
* feat(persons-on-events): cache + send persons and groups created_at with events

* more testing

* Update plugin-server/src/utils/db/db.ts

* better naming

* fixes

* testing

* update test
2022-06-27 11:39:58 +00:00
Neil Kakkar
9712fd9bb5
chore(feature-flags): Upsert hash key overrides on people merges (#10418) 2022-06-24 10:58:42 +01:00
Karl-Aksel Puulmann
773f922eef
feat(apps): Remove onAction plugin function (#10414)
* Remove onAction

* Avoid fetching actions that dont deal with REST - 99% reduction

* Plural hooks

* Avoid hook fetching where not needed

* Remove dead code

* Update lazy VM test

* Rename a function

* Update README

* Explicit reload actions in tests

* Only reload actions which are relevant for plugin server

* Remove excessive logging

* Reload actions when hooks are updated

* update action matching tests

* Remove commented code

* Solve naming issues
2022-06-24 12:29:10 +03:00
Karl-Aksel Puulmann
f4668ed855
refactor(plugin-server): move buffer as first step of event pipeline & more (#10360)
* WIP: Move person creation earlier

* WIP: move person updating, handle person property changing

* WIP: leverage person information

* Update `updatePersonDeprecated` signature

* Avoid (and test avoiding) unneeded lookups whether 'creating' person is needed

Note there were two tricky interactions within handleIdentify, which
again got solved by indirect message passing.

* Solve TODO

* Normalize event before updatePersonIfTouchedByPlugins

* Avoid another lookup for person in updatePersonProperties

* Avoid lookup for newPerson in handleIdentifyOrAlias

* Add kludge comments

* Fix runBufferEventPipeline

* Rename upsertPersonsStep => processPersonsStep

* Update emitToBufferStep tests

* Update some event pipeline step tests

* Update prepareEventStep tests

* Test processPersonStep

* Add tests for updatePersonIfTouchedByPlugins step

* Update runner tests

* verify person vesrion in event-pipeline-integration test

* Update process-event test suite

* Argument ordering for person state tests

* Update runner test snapshots

* Cast to UTC

* Fixup person-state tests

* Dont refetch persons needlessly on $identify

* Add missing version assertion

* Cast everything to UTC

* Remove version assertion

* Undo radical change to event pipeline - will re-add it later!

* Resolve comments
2022-06-23 10:27:01 +03:00
Karl-Aksel Puulmann
dea8c6973a
perf(plugin-server): reduce number of person lookups in the event pipeline (#10324)
* Return person in PreIngestionEvent if possible

* Avoid unneccessarily fetching person in emitToBufferStep

* Avoid unneccessarily fetching person in createEvent

* Use unified type instead of separate type for cached data

* Pass person info forward explicitly in each event-pipeline step

* minor typing improvement

* Remove person from type

* Remove unneeded `undefined`

* Add person check for prepareEventStep test

* Fix hook test

* Update getPersonData tests

* Cast created_at to UTC

* Cast created_at to utc on fetch

* Remove personUuid var - unneeded

* Add unit tests for process-event.ts#createEvent
2022-06-21 09:18:22 +03:00
Karl-Aksel Puulmann
ebfc8251a7
fix(plugin-server): Properly set version in deletePerson (#10207)
* Use correct style for querying postgres

* Add test showing problems with deletePerson logic

* Fix deleting persons from clickhouse

* Fix concurrent tests

* Version + 100

* Fixup FINAL

* Remove console.log
2022-06-13 12:58:44 +03:00
Tiina Turban
95c9045cc1
fix: Postgres and CH Person version across other columns to match (#10135) 2022-06-06 17:57:03 +02:00
Michael Matloka
64317238e6
refactor: Eliminate the KAFKA_ENABLED setting (#10059)
* refactor: Eliminate the `KAFKA_ENABLED` setting

* Remove dead code

* Consolidate plugin server test scripts and CI

* Fix CI command

* Remove Celery queues

* Rearrange test directories

* Update import paths
2022-05-30 18:39:33 +00:00