0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00
Commit Graph

18 Commits

Author SHA1 Message Date
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
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
612d62610e
perf(plugin-server): speed up getPluginConfigRows (#10952)
This is currently one of our slowest queries. The query itself is fine
but the amount of data returned is causing issues.

`error` column constitutes >80% of data stored in the column - by
removing it in the query we should see significant speedups.

pganalyze page: https://app.pganalyze.com/databases/-675880137/queries/5301003665?t=7d
2022-07-25 16:27:18 +03:00
Karl-Aksel Puulmann
e00b458dd8
fix(plugin-server): don't query source column for posthog_plugin (#10949)
This column is quite large and unused. Large columns slow down queries
due to extra data being sent back and forth.
2022-07-25 16:00:22 +03:00
Yakko Majuri
a8687f896e
fix: don't pull unnecessary plugin data in the plugin server (#10909)
* fix: don't pull unnecessary plugin data in the plugin server

* fix tests

* fix test 2

Co-authored-by: Tiina Turban <tiina303@gmail.com>
2022-07-21 16:47:55 +00: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 180ed228b8.

* 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
Michael Matloka
6da951d2d1
fix(apps): Avoid zombie plugin VMs (#10299)
* fix(apps): Avoid zombie plugin VMs

* Add `plugin_disabled_by_system` metric
2022-06-15 14:55:45 +02:00
Karl-Aksel Puulmann
59797efce8
refactor(plugin-server): yeet element-group related postgres code (#10161) 2022-06-07 12:23:20 +03: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
Marius Andra
c204a32835
feat(apps): transpile frontend.tsx (#9828)
* create plugin source model

* edit source via plugin_source model

* deprecate "source"

* test plugin source updates

* add support for index.ts and index.js

* refactor plugin loading, support plugin sources from db

* fix source code in tests

* remove transpilation code

* reload plugin after saving

* store defaults in the db instead of persisting in form

* remove fields that don't exist

* feat(apps): transpile frontend.tsx

* update timestamp even if no local fields changed

* yarn.lock

* remove unused fields

* commit suggestion

* rename to PluginSourceFile

* rename to PluginSourceFile

* remove dead code

* fix code feedback

* add comments

* make it safer to call

* convert to upsert

* convert to upsert

* comment on the null

* revert plugin server changes

* get source from new model behind the scenes

* simplify

* revert accidental changes

* revert accidental changes

* remove defaults

* sync the old source field

* use the source model in the plugin server

* cache the source from pluginsourcefile

* test that getPluginSource gets data from the database

* safer null check that doesn't override `{}` in the db with `null`

* use enum

* fix error from migration 0233 ([] is falsy in python!)

* fix merge

* error as null

* use the explicit "source__index_ts" field

* cache transpiled code

* remove unused type

* cleaner query

* remove extra line

* fix test
2022-05-19 18:49:03 +02:00
Yakko Majuri
77a3790abf
chore(plugin-server-tests): refactor tests to use a top-level describe (#8955) 2022-03-10 11:18:24 +00:00
Yakko Majuri
89b5bd36ec
Allow disabling a plugin's logs (#8519)
* allow disabling plugin logs

* fix

* suggested log level approach

* fixes
2022-02-16 11:35:26 +00:00
Yakko Majuri
d25fc565f6
Stateless plugins (#8112)
* WIP stateless plugins

* add test

* fix tests

Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-01-18 19:42:09 +00:00
Tiina Turban
a247475475
Plugin server tests to run in CI again (#7918) 2022-01-07 15:55:03 +01:00
Yakko Majuri
f919392e44
Historical export support for elements_hash (#7261)
* handle elements hash

* fixes, add tests

* better caching

* clean up db

* remove comment
2021-11-29 11:04:29 -03: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