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

39 Commits

Author SHA1 Message Date
Michael Matloka
12ff477551
refactor(group-analytics): Add project field to group type (#25600)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-01 00:12:28 +01:00
Tiina Turban
54875e188a
fix: Webhooks groups properties (#23822) 2024-07-22 14:21:46 -06:00
Tiina Turban
60ba76d9c4
feat: Part 1 of ability to spin up different pipelines (#23601) 2024-07-17 14:11:49 +02:00
ted kaemming
1ed9426eb7
refactor: Remove legacy overrides handling from plugin-server (#23616) 2024-07-11 08:24:54 -07:00
Tiina Turban
9734894bc2
feat: Remove groups properties and created from each event (#22962) 2024-07-10 13:07:58 +02:00
Bianca Yang
6acfaf55f5
feat: Final piece of deprecating available features, DB references (#22402)
* remove db ref

* update the migration

* remove referencess from test fixture jsons

* some more removals

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update query snapshots

* Update query snapshots

* Update query snapshots

* Update UI snapshots for `chromium` (1)

* Update query snapshots

* fix migration

* add reverse sql

* fix the migration

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update query snapshots

* i think i finally fixed the migration issue

* Update UI snapshots for `chromium` (2)

* Update query snapshots

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (2)

* update migration post merge

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-30 16:41:22 +00:00
Bianca Yang
9dd22a3757
feat: Deprecate available_features pt 2 (#22373)
* everything except plugin server and sync_available_features

* sync_available_features_done, some plugin_server done?

* and a tiny bit more

* linting

* try to fix some tests

* more test fixes/

* clean up typos

* weed wacking bugs

* more test shenanigans

* fix plugin server

* actually fix plugin server test?

* still fixing tests

* another attempt

* some pr feedback

* small fix

* fix database query accessor

* fix functional tests

* fix tests

* Update query snapshots

* Update query snapshots

* Update query snapshots

* update some comments and fxn names

* fix plugin server test

* Update query snapshots

* Update query snapshots

* Update query snapshots

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-28 17:29:24 -07:00
Bianca Yang
008698a785
feat: remove most frontend references to available_features (#22337)
* remove most frontend references to available_features

* some more

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (2)

* adding back some items, fix tests

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (2)

* fix test

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (1)

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-20 14:24:32 -07:00
Ben White
224a5d5d0c
feat: Action steps refactor (part 2) (#22092) 2024-05-08 09:46:52 +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
Michael Matloka
f02d045bf9
chore(environments): Add migration to backfill projects (#20887)
* chore(environments): Add migration to backfill projects

* Fix `noop`

* Add `project_id` to plugin server test setup

* Fix `project_id`

* Also add `posthog_project` to plugin server tests

* Update `createTeam`

* Fix func tests
2024-03-14 13:45:28 +01:00
Xavier Vello
6117206ea2
feat(ingestion): pass PLUGIN_SERVER_MODE as pg app name (#20613) 2024-02-29 10:34:28 +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
ted kaemming
f342f35f33
test(plugin-server): Reduce flakiness of plugin teardown functional tests (#18896) 2023-11-27 07:51:39 -08:00
Xavier Vello
68fd523c35
fix(ci): fix flaky 'plugins can use attachements' test (#18341) 2023-11-02 15:40:33 +01:00
Paul D'Ambra
31c1cdf301
chore: yeet CH recordings ingestion (#17572)
Removing ClickHouse based recordings

One big yeet for a man, a great yeet for humanity
2023-10-11 14:23:41 +01: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
Harry Waye
9f0cf9f40f
chore: make attachement test less flakey
We do this by making sure the plugin config and the attachement are
committed together.
2023-07-11 14:08:29 +00:00
Harry Waye
d8773d99d9
test: add tests for plugin secrets (#15754)
* test(plugin-server): add test for attachments

We didn't have one before, now we do!

* test: add tests for plugin secrets

Adds basic test for using configurations in plugins. This is a first
step towards getting lazy loading of plugins in safely:
https://github.com/PostHog/posthog/pull/15704
2023-05-26 18:00:45 +00:00
Harry Waye
685d1e2fc8
test(plugin-server): add test for attachments (#15752)
We didn't have one before, now we do!
2023-05-26 17:17:14 +00:00
Xavier Vello
6b0abd05af
feat(jobs): don't execute queued jobs for disabled configs (#15738)
* feat(jobs): don't execute queued jobs for disabled configs

* add functional test for disabled plugins

---------

Co-authored-by: Harry Waye <harry@posthog.com>
2023-05-26 14:29:52 +00:00
Tiina Turban
a5544cf7e4
feat: Async handlers use person info from event (#15307) 2023-05-04 13:25:56 +02:00
Harry Waye
7ba6fa7148
chore(plugin-server): remove piscina workers (#15327)
* chore(plugin-server): remove piscina workers

Using Piscina workers introduces complexity that would rather be
avoided. It does offer the ability to scale work across multiple CPUs,
but we can achieve this via starting multiple processes instead. It may
also provide some protection from deadlocking the worker process, which
I believe Piscina will handle by killing worker processes and
respawning, but we have K8s liveness checks that will also handle this.

This should simplify 1. prom metrics exporting, and 2. using
node-rdkafka.

* remove piscina from package.json

* use createWorker

* wip

* wip

* wip

* wip

* fix export test

* wip

* wip

* fix server stop tests

* wip

* mock process.exit everywhere

* fix health server tests

* Remove collectMetrics

* wip
2023-05-03 14:42:16 +00:00
Harry Waye
9b4d455a29
docs(set/set_once): add $set/$set_once to docs (#15306)
This also adds a test to ensure we are capturing usage of $set/$set_once
at the top level of the event, as posthog-js uses this method.

This was initiated by the issue mentioned
[here](https://github.com/PostHog/posthog-js/issues/615).
2023-05-01 12:09:38 +00:00
Xavier Vello
013ac5cd93
chore(tests): use PoEv2 join instead of dict for functional_tests (#15188) 2023-04-28 16:27:35 +02:00
Harry Waye
3f4c0498df
chore(plugin-server): remove recording forwarding (#15230)
We were forwarding events for backwards compatibility with the old
session recording system. Now that we've removed that, we can remove
this code.
2023-04-25 17:03:43 +01:00
Tomás Farías Santana
315f47f57d
feat: person-overrides writes with Mapping to Persons (#14513)
* feat(person-override): Add a helper model to indirectly reference person overrides

This allows us to use an exclusion constraint on the person overrides table instead of directly using a FK on posthog_person.

* test(person-overrides): Update tests to match new constraint

* fix(migration): Add drop extension query to reverse migration

* fix(migration): Use correct table name

* refactor(person-overrides): Make team a regular bigint field without FK

* refactor(person-overrides): Rename Helper model to Mapping

* feat(person-override): Add a helper model to indirectly reference person overrides

This allows us to use an exclusion constraint on the person overrides table instead of directly using a FK on posthog_person.

* wip: add test for concurrent updates to posthog_personoverride table

* refactor

* Update snapshots

* fix(isort): Correctly sort imports

* fix(ee-cohort-test): Delete person after creating it

* fix: person constraint in person overrides table (#14319)

* nits

* fix migration tests

* chore(migration): Bump migration number to 0302

* Update snapshots

* feat: person-overrides writes

* test(person-overrides): Add concurrent tests to person-overrides model

* feat(person-merge): Update merge to use new helper table

* fix(tests): Pass poEEmbraceJoin to updatePersonState in test

* fix(person-state): Format person-overrides message for ClickHouse

* test(api): Add function to reload dictionary for person overrides

* fix: poe final test failure

* refactor(person-state): Make failed attempts a class variable to

This allows us to mock it during testing as some tests require
immediate failures.

* fix(postgres-utils): Apply some magic changes lost to time

* fix(person-state): Join with helper table to return UUIDs

* fix(person-state): Use single quotes for UUID queries

* test(person-overrides): Skip test that doesn't work without a merge command

* test(person-state): Add a very complicated query to get UUIDs in a test

* test(person-state): Try waiting longer, this is flaky

* fix(migrations): Remove unused migration

* fix(person): Undo unneeded person model changes

* chore: Clean-up artifacts from rebase on model branch

* refactor(person-state): Rename mergeAttempts and don't read from ENV

* chore: Better clarify oldest_event usage in comment

Co-authored-by: Tiina Turban <tiina303@gmail.com>

* refactor(person-state): Update version in queries

* fix(person-state): Use new mapping model instead of helper

* fix(migrations): Re-add constraint deleted on field drop

* revert: Re-enable test that was skipped

Test was originally skipped due to missing a $merge command, but now
$merge_dangerously is available, so the test should pass.

* test: Attempt to refresh dictionary in test

* Update query snapshots

* Update query snapshots

* test: Expect dictionaries to be refreshed before resuming test

* fix(test): Use alias property for $merge_dangerously in test

* fix(test): Expect any string like in all other tests

* test: Fix order of events to determine merged persons

* chore: Update comment regarding overrides mapping query

* chore: Remove out of date comment

* test: Set number of retries to 0 when updating persons

* test: Delete comment

* test: Assert clickhouse state after identify

* chore: Move comment

* chore: Delete TODO regarding oldest_event updates

* test: Assert events are still processed if merge fails

* test: Assert properties are processed if merge fails

* test: Don't expect to throw when failing merges

* fix: Indent RETURNING query clause

Co-authored-by: Harry Waye <harry@posthog.com>

* chore: Remove out of date comment

Co-authored-by: Tiina Turban <tiina303@gmail.com>

* test: Resume merges after test suite

* test: Run processPersonStep tests for both poEEmbraceJoin modes

---------

Co-authored-by: Harry Waye <harry@posthog.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tiina Turban <tiina303@gmail.com>
2023-03-13 11:52:08 +01:00
Harry Waye
01da91d1e2
test: remove explicit dependencies from functional tests (#14471)
* test: remove explicit dependencies from functional tests

* Install pnpm in devcontainer
2023-03-01 12:03:54 +00:00
Harry Waye
a4a3a0c902
test(plugin-server): use librdkafka for functional tests (#14468)
* test(plugin-server): use librdkafka for functional tests

While trying to port the session recordings to use node-librdkafka I
found it useful to first implement it in the functional tests.

* use obj destructuring to make calls more self explanatory
2023-03-01 11:03:13 +00:00
Alex Gyujin Kim
4ec1990270
chore: add ttl to performance events table (#13921) 2023-01-30 09:37:31 -05:00
Harry Waye
da482a3cba
refactor(recordings): remove session code from event pipeline (#13919)
* refactor(recordings): remove session code from event pipeline

We have moved session recrodings to a separate topic and consumer. There
may be session recordings in the old topic, but we divert these to the
new logic for processing them.

* refactor to just send to the new topic!

* fix import

* remove empty line

* fix no team_id test

* implement recordings opt in

* remove old $snapshot unit tests

* remove performance tests

* Update plugin-server/functional_tests/session-recordings.test.ts

Co-authored-by: Tiina Turban <tiina303@gmail.com>

* Update plugin-server/functional_tests/session-recordings.test.ts

Co-authored-by: Tiina Turban <tiina303@gmail.com>

* add back $snapshot format test

* Add comment re functional test assumptions

Co-authored-by: Tiina Turban <tiina303@gmail.com>
2023-01-27 12:36:45 +00:00
Harry Waye
49f1dcb9a2
fix(session-recordings): fix missing distinct_id for session recordings (#13757)
* fix(session-recordings): fix missing distinct_id for session recordings

Previously I'd assumed that the distinct_id would be in the event.
That's not true, rather it is at the top level of the Kafka message
value JSON.

This commit fixes that, and also updates all functional tests to not
include the `distinct_id` within the event body.

* Revert "chore(session-recordings): revert to sending events to old topic (#13756)"

This reverts commit 41874de277.

* add test for session without team_id, only token

* pull out event names as variable

* Change info -> debug otherwise its very noisy
2023-01-17 13:42:31 +00:00
Harry Waye
51e134e98c
chore(session-recordings): separate topics for events as recordings (#13654)
* chore(session-recordings): separate topics for events as recordings

WIP

* fix tests

* Use simpler consumer for session recordings

* wip

* still batch things by batchSize

* add tests, improve comments

* rename topic var

* push performance_events to session recordings topic also

* Add completely separate consumer for session-recordings

* wip

* use session_id for partition key

* fix test

* handle team_id/token null

* wip

* fix tests

* wip

* use kafka_topic var in logs

* use logger

* fix test

* Fix $performance_event topic usage

* fix tests

* fix check for null/undefined

* Update posthog/api/capture.py

Co-authored-by: Tomás Farías Santana <tomas@tomasfarias.dev>

* Add test for kafka error handling

* Remove falsy teamId check

* fix statsd error

* kick ci

* Use existing getTeamByToken

* remove partition key from recordings

* Make sure producer is connected !

* fix session id kafka key test

* add back throws!

* set producer on each test

* skip flaky test

* add flush error logs

* wait for persons to be ingested

* fix skip

Co-authored-by: Tomás Farías Santana <tomas@tomasfarias.dev>
2023-01-17 12:04:03 +00:00
Ben White
cb7e7d5e5e
feat: Added performance API (#13452) 2023-01-06 09:51:51 +01:00
Harry Waye
be1ddaaa85
fix(historical-exports): do not send sent_at in exports (#13275)
* fix(historical-exports): preserve sent_at in exports

It seems that when exporting historical events (and likely all events),
the sent_at field is not preserved, rather we were using the
`created_at` date which by the looks is what we set to `now()` as it
goes through the event processing pipeline. This means timestamps on
exported events will be slightly different, depending how much lag there
was between sending the event and processing the event. It also means,
e.g. that if you were to export events twice, then we'd likely end up
with very off timestamps on the final export.

This commit fixes this by using the `timestamp` field that we get from
the ClickHouse events table.

We also add a test to ensure that the capture endpoint allows for
setting all the appropriate data needed for exports to function as
expected.

This is in relation to
https://posthogusers.slack.com/archives/CTLTM70RM/p1670577437942799

* remove sent_at from historical export

* remove comment re sent_at

* update comment

* update comment

* wip

* Update plugin-server/src/worker/ingestion/timestamps.ts

Co-authored-by: Xavier Vello <xavier@posthog.com>

* Update plugin-server/functional_tests/exports-v2.test.ts

Co-authored-by: Xavier Vello <xavier@posthog.com>

Co-authored-by: Xavier Vello <xavier@posthog.com>
2023-01-04 10:22:38 +00:00
Harry Waye
63ba5e2fb7
chore: remove usage of delayUntilEventsIngested (#13509)
Its usage is odd and it's not clear what it's doing.
2022-12-29 21:54:44 +00:00
Harry Waye
1e82569bbb
chore(plugin-server): Add metrics for time of last processed message (#13350)
* chore(plugin-server): Add metrics for time of last processed message

Previously we have been alerting on Kafka consumer group offset lag.
However, really we care about the delay between messages being written
to Kafka and being processed by the plugin server.

By adding the last processed timestamp, as a gauge, we can then alert on
if that time and now is greater than a threshold.

This alert would not require the plugin-server to be up to trigger, just
that there be some time registered so it handles complete failure also.

For the case that there are no messages past the committed offsets, we
will end up triggering the alert if we do not also take into
consideration the production rate into the topic.

* wip

* wip

* fix imports order

* fix group id

* Add and use waitForExpect instead

* remove yarn.lock

* move comment

* wip
2022-12-15 18:28:43 +00: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
Harry Waye
b010073ec4
test(plugin-server): add functional tests for property definitions (#12659)
* refactor(plugin-server): separate api from functional_tests

This just moves the api helpers to a separate file, such that we can
import from other files.

* test(plugin-server): add functional tests for property definitions

I was going to take a stab at
https://github.com/PostHog/posthog/issues/12529 but I wasn't sure how
the definition bits worked, so thought I'd add some tests first.

This doesn't just add tests but also:

 1. starts demonstrating how we can split up the tests into
    different files, thereby also allowing jest test isolation.
 2. removes --runInBand, such that isolated tests can run in parallel
2022-11-08 06:56:19 +00:00