Commit Graph

39 Commits

Author SHA1 Message Date
Ben White
924ee1d43d feat(cdp): Use lazy loader for hog functions (#30235) 2025-03-21 12:16:49 +01:00
Ben White
ced2292f81 fix(node): Failing tests due to bigint migration (#30199) 2025-03-20 12:38:27 +01:00
Ben White
541a1bedcd fix(cdp): Action loading (#29805) 2025-03-12 10:11:24 +01:00
Ben White
9d46b776ff fix(node): Improve the way we compile and run tests (#27695) 2025-01-22 12:04:59 +00:00
Michael Matloka
d801027fb2 refactor(ingestion): Make group type project-based (read/write) (#25876) 2024-11-12 14:35:47 +01:00
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
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
Ben White
224a5d5d0c feat: Action steps refactor (part 2) (#22092) 2024-05-08 09:46:52 +02:00
Brett Hoerner
ddd0a05884 feat(plugin-server): lazy distinct_id/person row creation (#21670)
* split out InternalPerson and Person types

* disable old backfill code

* add lazy person env var setting

* lazily create person/distinct_id rows

* remove backfill.ts

* drop properties after person lookup

* remove leftover backfill bit
2024-04-23 10:39:40 -06: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
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
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
Tiina Turban
d78680c976 chore: Remove lazy person container (#15286) 2023-05-22 13:51:07 +02:00
Harry Waye
ed876aa40e fix: for empty group props (#14243)
* fix: for empty group props

We were failing if the props were empty.

* refactor: make property definitions db dependencies explicit

We were relying on implicit details setup via `resetTestDatabase` which
makes it hard to reason about what's going on. It also uses hard coded
ideas which limits our ability to isolate tests properly, which would
help both for writing tests with confidence that they are correct, and
for adding for example parallelism.

* add test
2023-02-15 15:39:20 +00:00
Harry Waye
ac6b863c73 refactor: remove timekeeper, use jest fake timers, create hub once (#14166)
This removes the timekeeper library and uses jest fake timers instead.
This also creates the hub once and reuses it for all tests, which is
faster than creating a new hub for each test.
2023-02-09 11:30:41 +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
cc2f424452 chore(plugins-server): use Kafka to buffer app jobs requests (#12345)
* chore(plugins-server): use Kafka to buffer app jobs requests

To remove the dependency on the Graphile Worker database on things that
may be requesting app job runs we push the jobs to a Kafka topic.

* chore: use KAFKA_JOBS instead of string literal `'jobs'`

* chore: rename startJobsBufferConsumer -> startJobsConsumer

* avoid checking eventId

* fix lint

* fix producer wrapper tests

* fix retries test

* handle offset sync

* wip

* wip

* remove exports

* do better

* use Producer not wrapper

* reset db

* mock once

* Add test for raising to the consumer

* Update plugin-server/tests/main/ingestion-queues/run-async-handlers-event-pipeline.test.ts

Co-authored-by: Yakko Majuri <38760734+yakkomajuri@users.noreply.github.com>

* and in the darkness bind them

* fix tests

* don't forget the name update!

* rename DependencyError to DependencyUnavailable

* separate dlq

* update comment

Co-authored-by: Yakko Majuri <38760734+yakkomajuri@users.noreply.github.com>
2022-10-28 11:05:15 +01:00
Harry Waye
62d9c20a90 chore(plugin-server): use DELETE instead of TRUNCATE (#12393)
* chore(plugin-server): use DELETE instead of TRUNCATE

Truncate seems a little slow. Other options to consider:

 1. PostgreSQL fsync settings in tests
 2. using tmpfs for "persistence"
 3. use transaction/rollback: not totally sure we'd be able to do this
    in our tests but may be worth a try.

* wip

* wip

* set fsync=off

* Delete all tables in current schema

* don't bother with fsync=off
2022-10-25 09:15:53 +00:00
Harry Waye
7f6f9d5e90 test(plugin-server): run same tests for single and multi process modes (#12220)
* tests(plugin-server): run same tests for single and multi process modes

Previously we were running different tests, now we run the same.

* exclude async on ingestion capability

* fix typing

* do not test for onSnapshot

* fix autocapture test
2022-10-12 16:21:16 -03:00
Harry Waye
21bc4b01ca refactor(e2e): make e2e tests 4x faster (#12214)
* refactor(e2e): make e2e tests 4x faster

I'm a little scared to make changes to the pluginsServer without having
some way to test that is close to production. I started changing some of
the internals in https://github.com/PostHog/posthog/pull/12191 but
started to see test failures for internals that I'm not confident in
handling without having some higher level tests testing the
pluginsServer functionality as a whole, so I started looking at the e2e
tests which are very slow and look like they don't have great coverage.

Rather than restarting the pluginsServer each time, we can use the
feature of partitioning by teamId to run multiple tests against the same
server.

To do this I've added a few helper functions for pulling out of
ClickHouse which enforce that you include a filter on teamId. It's a
little more verbose but also hopefully serves as good documentation for
how e.g. plugins work and are loaded.

I've also avoided reaching into the internals of the pluginsServer as
much as possible, only doing so to reload the plugins. Ideally we'd also
handle the reload via the PubSub which would allow us to, for example,
run the e2e tests against a separate pluginsServer process thereby
getting more confidence, but that's a stretch and maybe something we can
do without. This would however make it easy, for instance to:

 1. make big refactors without fear of breaking things
 2. swap out, e.g. the anonymous consumer to use instead something
    written in bash or maybe something not quite as absurd.

* enable buffer, remove random teamId
2022-10-12 16:14:46 +01:00
Marius Andra
2c2e9ce48e feat(apps): rename web.ts to site.ts (#12179)
* site.ts

* Update snapshots

* fix file in test archive

* Update snapshots

* more renames

* plugin source file updated at

* fix test

* last renames

* add null

* blank

* remove what we don't need

* get test to pass

* use new posthog-js

* new version

Co-authored-by: mariusandra <mariusandra@users.noreply.github.com>
2022-10-11 10:27:21 +00: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
Marius Andra
c42c2c1879 feat(apps): inject code to posthog-js (#12003)
* support adding custom files

* compile web.ts

* add injected code into /decide

* transpile better

* add id and payload stub to injected code

* skip backend if web only

* more web source

* add payload to default demo

* values list and inline for

* revert

* simpler query

* reload plugin if source changed

* pass on config that has "web":true

* add a bootloader for scripts larger than 1kb

* rename payload to config

* access posthog also in injected script

* cleanup

* pass meta object to inject

* split web_js code

* List

* add a web token for plugin configs

* test for web.ts

* use WEB_APP_INJECTION env to enable/disable injection

* fix types

* remove instance setting

* add inject_web_apps on team

* track installed web apps on team

* refresh from db

* enabling web apps makes an extra query

* null true

* clean imports

* null check

* fix migration

* fix noise in tests

* test web app injection

* update Team without going through a signal loop

* update plugin test

* update plugin test

* typo

* Update snapshots

* typing

* inject only via external scripts

* enable injection in the app

* update posthog-js

* blank source files when updating

* url dataclass

* comment

* add and remove files

* not users

* only show button to add files if there are files to add

* update in bulk

* TYPE_CHECKING

* abstract transpilation just a bit

* feedback and bug

* we're down under

* errors if failed

* raise on 404

* clean up more

* refactor

* add updated_at to list

* no need to check code equality

* remove australia ip override

* test

* remove support for random files

Co-authored-by: mariusandra <mariusandra@users.noreply.github.com>
2022-10-05 17:29:45 +02:00
Karl-Aksel Puulmann
c9f05fdaf1 chore(plugin-server): support tracing in plugin-server (#11029)
* Experimental tracing support for plugin server

* Add tag to postgresTransaction

* Track event pipeline steps as separate spans

* Track kafka queueMessage?

* Tracing for processEvent, onEvent, onSnapshot

* plugin.runTask

* Move sentry code

* Make tracing rate configurable
2022-07-28 15:05:00 +03: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
Neil Kakkar
9712fd9bb5 chore(feature-flags): Upsert hash key overrides on people merges (#10418) 2022-06-24 10:58:42 +01:00
Michael Matloka
3578a0c1c2 perf(apps): Only load PluginSourceFiles instead of Plugin.archive (#10374)
* perf(apps): Cache app code at install instead of fetching `archive` blob

* Fix typing

* Add migration

* Use `cast()` instead of `assert`

* Update plugin test helpers

* Restore `reload_plugins_on_workers()`

* Save plugin source file rows separately from plugin rows

* Fix migration

* Update latest_migrations.manifest

* Update plugins.test.ts

* Separate `plugin60WithSource` from `plugin60`

* Handle `PluginSourceFile` at `insertRow()` level

* Unify `plugin60WithSource` and `plugin60` again

* Update sql.test.ts

* Fix and simplify reading files in `loadPlugin()`

* Update plugins.test.ts

* Update more tests

* Clean code up

* Specify `json_parse=True` in lower-level function tests

* Add tests for `update_or_create_from_plugin_archive()`

* Update migration with updated function

* Update plugin `upgrade` endpoint

* Remove leftover `print()`

* Add error handling to `0243_unpack_plugin_source_files`

* Add `upgrade` assertions

* Revert plugin server changes

* Fix typing

* perf(apps): Only load `PluginSourceFile`s instead of `Plugin.archive`

This reverts commit 180ed228b8cc59875ac426783a2f46e57eb1e69c.

* Update logging level and message

* Refactor `find_index_ts_in_archive()` and `extract_plugin_code()` out

* Don't select `latest_tag` and `latest_tag_checked_at`

* Use kwargs in logging

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>

* Fix missing comma

* Only throw if `plugin_json_parsed` is `None`

* Fix `reverse_func`

* Accept empty files

* Make sure files which are deleted between version are gone

* Update 0243_unpack_plugin_source_files.py

* Update 0243_unpack_plugin_source_files.py

* Explain query counts

* Use `@snapshot_postgres_queries` instead of `assertNumQueries()`

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2022-06-22 16:33:23 +02:00
Karl-Aksel Puulmann
59797efce8 refactor(plugin-server): yeet element-group related postgres code (#10161) 2022-06-07 12:23:20 +03:00
Tiina Turban
735ceb33a5 refactor(plugin-server): yeet postgres plugin logs (#9881)
* refactor(plugin-server): yeet postgres plugin logs

* forgotten usage

* Remove more Postgres `PluginLogEntry` code

* Modernize tests

* Wait for `KafkaEngine` in `console.test.ts`

* Fix formatting

* Add `resetKafka`

* Update console.test.ts

* Update style

* Use `delayUntilEventIngested` and improve its ergonomics

* Fix tests

* Refactor `test:postgres:2` away

* Fix and optimize `console.test.ts`

* Rearrange things a little bit

* Revert "Fix and optimize `console.test.ts`"

This reverts commit 273dbc1244df190fdf9bb6e1ab3cc35f0586af96.

* Rework `console` test to avoid Kafka

* Update `vm.test.ts` to spy on `queueSingleJsonMessage`

* Improve `.queueSingleJsonMessage()` typing

* Try to fix `moveDistinctIds & deletePerson`

Co-authored-by: Michael Matloka <dev@twixes.com>
2022-05-30 13:09:13 +03:00
Karl-Aksel Puulmann
c23108adad feat(plugin-server): Manage webhook SITE_URL logic via instance settings (#9895)
* SiteUrlManager

* Update site_url

* Update imports

* Use SiteUrlManager with webhooks

* Remove most siteUrl usecases from preIngestionEvent

* Run onEvent even if action lookup fails

* Add tests

* Re-add some null guards

* Add missing test file

* Missing await
2022-05-23 15:53:30 +03:00
Ben White
2f7573125c feat(person): Added setting for customising the displayed property for the Person identifier (#9607)
* Added setting for customising the properties used for the "display name" for any given Person

* Reworded the setting

* Formatting fixes

* Removed transiition on Tag component that was interfering with sorting animation

* Changed field type to string array

* Reverted hook based approach based on PR feedback for using global state from Kea

* Reverted personsLogic addition

* Reverted test case

* Formatting

* Removed dead code

* Fixed null check for Teams model

* Fixed array format for sql command

* fix migration

* Reverted default on the backend and moved it to the frontend for now

* Formatting

* Updated test snapshots

* Skipped migration tests

* Corrected migrations

* Fixed import order

* test

* test

* test

* untest

Co-authored-by: Ben White <ben@posthog.com>
Co-authored-by: Marius Andra <marius.andra@gmail.com>
2022-05-03 16:12:46 +01:00
Paolo D'Amico
9496394952 Remove & clean onboarding-2822 (#8707) 2022-02-23 08:22:01 +01:00
Yakko Majuri
07f5f565ab fix api key bot (#8566)
* fix api key bot

* add explicit assurance of hitting cache

* remove log

* revert debug

* prettier

* rename test
2022-02-14 11:55:35 +00:00
Alex Gyujin Kim
c12179b5ba Give actions descriptions (#8272)
* add description to action

* update tests

* no limit to description and use pageheader

* add ee_action

* add description as global relationship:

* fix tests

* revert to using descriptions

* revert to using descriptions

* allow description to be null

* fix tests

* persist mode

* fix e2e

* Address review points, clean up some margins

* Clean up the way editing state is determined

* Restore default description value and improve typing

* Fix typing better

* Update sql.ts

Co-authored-by: Michael Matloka <dev@twixes.com>
2022-02-02 15:50:28 +01:00
James Greenhill
434e379f9a Add 'plugin-server/' from commit '01a99a4e26b0b11f068a7073d6b94e53a7214d33'
git-subtree-dir: plugin-server
git-subtree-mainline: 776b056b6d
git-subtree-split: 01a99a4e26
2021-10-28 14:59:19 -07:00
James Greenhill
145937a435 Revert "Monorepo with updated history" 2021-10-28 14:55:17 -07:00
James Greenhill
65512ae16f Pack up plugin-server for moving 2021-10-12 15:45:42 -07:00