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

176 Commits

Author SHA1 Message Date
Paul D'Ambra
49e3ceef5c
feat(object storage): add unused object storage (#9846)
* feat(object_storage): add unused object storage with health checks

* only prompt debug users if object storage not available at preflight

* safe plugin server health check for unused object storage

* explicit object storage settings

* explicit object storage settings

* explicit object storage settings

* downgrade pip tools

* without spaces?

* like this?

* without updating pip?

* remove object_storage from dev volumes

* named volume on hobby

* lazily init object storage

* simplify conditional check

* reproduced error locally

* reproduced error locally

* object_storage_endpoint not host and port

* log more when checking kafka and clickhouse

* don't filter docker output

* add kafka to hosts before starting stack?

* silly cloud tests (not my brain)
2022-05-20 09:56:50 +01:00
Michael Matloka
faf75ebb5e
refactor(ingestion): Make KAFKA_ENABLED true by default and set KAFKA_HOSTS default (#9844)
* refactor(ingestion): Make `KAFKA_ENABLED` true by default

* Sync `KAFKA_HOSTS` defaults too

* Update snapshots

* Update "kafka" to "kafka:9092"

* Revert "Update "kafka" to "kafka:9092""

This reverts commit d954ac6fa6.

* Update some tests

* Revert "Revert "Update "kafka" to "kafka:9092"""

This reverts commit 07edfa6c5e.

* Update test_0004_replicated_schema.ambr

* Remove `KAFKA_ENABLED` and `KAFKA_HOSTS` from places

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-19 19:18:15 +02: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
Michael Matloka
6da4d11957
refactor(plugin-server): Remove ts-jest, use jest.mocked (#9861) 2022-05-19 16:06:32 +02:00
Karl-Aksel Puulmann
bd0305bf73
feat(plugin-server): use swc for running jest tests (#9832)
* feat(plugin-server): use swc for running jest tests

Every time we run jest tests, typescript is being compiled. This adds
~13-20s to _starting_ each test suite on my machine.

This change brings it down to 1s at the cost of only _transpiling_ the
code and not doing any typechecking.

The second overhead this fixes is for piscina: every worker thread
compiled its own code every time, speeding this up takes that from 4.4s
to under a second. See https://github.com/PostHog/posthog/pull/9777 for
original context

* Re-add ts-jest
2022-05-18 14:45:54 +03:00
Michael Matloka
1af98a0fea
test(ingestion): Unify tests into single process-event.test.ts (#9819)
* Simplify imports in `setup_test_environment`

* refactor(ingestion): Unify tests into single `process-event.test.ts`

* Update test scripts for CI

* Fix imports

* Run prettier

* Fix missing import

* Fix the OTHER imports

* Nuke `includeNewPropertiesUpdatesTests`
2022-05-17 21:07:13 +02:00
Karl-Aksel Puulmann
86ef2ec3af
feat(plugin-server): Break on event on action on snapshot (#9781)
* (Temporarily) depend on a different version of plugin scaffold

* Change ingestEvent response schema, return PreIngestionEvent

* Refactor onEvent call pattern

* IP on preIngestionEvent

* Make a function generic

This way its return values can be used

* Deal with ProcessedPluginEvents not PluginEvents for onX plugin
functions

* Use beta versions of the package

* Update vm.test.ts

* Update dlq tests

* Continue calling onSnapshot

* Pass forward siteUrl

* yeet some code

* Refactor action matching & webhooks logic to work off of PreIngestionEvent

* Update site_url call pattern

* Remove console.log

* Remove a dead test

* fix hooks tests

* Fix ingest-event test

* update vm.test.ts

* rename a function

* Update plugin-scaffold
2022-05-17 11:04:15 +03:00
Michael Matloka
9a389847c2
refactor(plugin-server): Remove --idle mode (#9798)
* refactor(plugin-server): Remove `--idle` mode

* Support `PLUGIN_SERVER_IDLE` in `bin/start-worker`

* Don't `export` needlessly in npm script
2022-05-16 16:22:49 +00:00
Karl-Aksel Puulmann
d28560ff2b
Revert "chore: only report failing tests in plugin server tests (#9636)" (#9713)
This reverts commit 6fdea62b76.
2022-05-10 14:52:00 +03:00
Paul D'Ambra
6fdea62b76
chore: only report failing tests in plugin server tests (#9636)
* only report failing tests

* move silent reporter into package json so we can add a test:noisy task

* Revert "move silent reporter into package json so we can add a test:noisy task"

This reverts commit 234ae024a0.
2022-05-09 15:41:20 +01:00
Michael Matloka
500d4623ba
refactor: Yeet PRIMARY_DB (#9017)
* refactor: Yeet `PRIMARY_DB`

* Remove `db_backend`

* Eliminate "Analytics database in use"

* Satisfy mypy
2022-03-21 13:15:50 +01:00
Karl-Aksel Puulmann
40a1721d0b
fix: Simplify test setup for plugin-server (#9051)
We don't need multiple commands for setup, also verify TEST env is set.
2022-03-17 10:34:53 +02:00
Yakko Majuri
3ab69d23e3
chore(deps): upgrade node.js version to v16 (#8983)
* chore(deps): upgrade node.js version to v16

* update npm version'

* try to update alpine

* Revert "try to update alpine"

This reverts commit 58024968e2.

* don't update alpine, use node-current instead:

* go back to npm 7

* upgrade @google-cloud packages

* handle unhandled rejections :D

* add handling for unhandled promise rejections in the main thread as well
2022-03-15 09:48:56 +00:00
Yakko Majuri
18860fc49f
feat(plugin-server): add structured logging (#8888)
* feat(plugin-server): add structured logging

* updates

* handle methods

* fix

* use structlog

* fix deps
2022-03-10 12:58:06 +00:00
dependabot[bot]
f27bbf6ad0
chore(plugin-server): bump vm2 from 3.9.5 to 3.9.6 in /plugin-server (#8594)
Bumps [vm2](https://github.com/patriksimek/vm2) from 3.9.5 to 3.9.6.
- [Release notes](https://github.com/patriksimek/vm2/releases)
- [Changelog](https://github.com/patriksimek/vm2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/patriksimek/vm2/compare/3.9.5...3.9.6)

---
updated-dependencies:
- dependency-name: vm2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-10 09:58:10 +00:00
Karl-Aksel Puulmann
2e6aae702d
Allow disabling protobuf with CLICKHOUSE_DISABLE_EXTERNAL_SCHEMAS env (#8333)
* Allow disabling protobuf with CLICKHOUSE_DISABLE_EXTERNAL_SCHEMAS env var

This makes integrating with external clickhouse providers (like altinity
cloud) much easier as users don't need to use undocumented APIs to
upload the schemas.

* Keep underscores in protobuf. This allows using this payload for json ingestion

* Timestamp format
2022-02-02 00:30:11 +02:00
Eric Duong
a71e899605
Yeetcode (#7830)
* remove django query tests

* remove funnel and caching check

* remove ee available var

* remove is_clickhouse_enabled

* remove abstract tests

* change primary db

* missing func

* unnecessary test

* try new e2e ci

* func arg

* remove param

* ci

* remove plugins in docker

* background

* change ur;

* add kafka url

* add step

* update docker

* primary docker file

* mount volumes correctly

* one more

* remove postgres tests

* remove foss

* remove all  is_clickhouse_neabled

* remove irrelelvant test

* remove extra arg

* remove var

* arg

* add foss comment

* add foss comment

* plugin server config

* Update posthog/utils.py

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

* migrate commands

* comment

* add clickhouse to pg tests

* change script

* change ordering

* deepsource

* restore foss tests

* test remove KAFKA_ENABLED from CI

* always wait

* up proper resources

* use one conftest

* restore

* remove unnecessary tests

* remove more pg

* log event tests

* fix more tests

* more tests

* type

* fix more tests

* last test

* typing

* account for shared class setup

* temp test cloud

* restore cloud master checkout

* adjust contexts

* backwards

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
Co-authored-by: yakkomajuri <yakko.majuri@gmail.com>
2022-01-18 14:32:28 -05:00
Tiina Turban
a247475475
Plugin server tests to run in CI again (#7918) 2022-01-07 15:55:03 +01:00
Rick Marron
e124114a90
add ethers to plugin server (#7910) 2022-01-06 15:38:57 -08:00
Marius Andra
151f759faa
Event property counter (#7500)
* create event property model

* add null

* rename cache vars

* update event properties table on ingestion

* match date formats

* match date formats

* better string handling

* property type can be null too

* pass event timestamp

* update property type later

* perform all updates through a buffer object

* move to EventPropertyCounter

* fix migration

* improve flush last seen at job

* flush job periodically + env

* upsert all event properties in 1 query

* log to statsd

* enable property counter only if experimental mode enabled

* use now() instead of event timestamp

* fix seconds

* add user/pass for default postgres

* add tests

* use big integers

* make query work with 50k props

* processing events saves event properties

* fix script

* test date format detection

* default enabled

* only enable event property counter for specific teams

* eslint fixes

* fix logs double-sync noise in tests

* fix bigint test

* don't do tasks that make no sense

* remove dead code

* simpler test setup

* different contraint name

* refactor team manager

* greatly simplify the system

* fetch cached event properties

* fix team manager and timestamps

* add cached entry

* also don't cache event properties for teams that have it disabled

* remove indexes that are not going to be used

* remove unused imports

* blacked

* remember event properties with a LRU cache

* fix eslint

* clean up the last bits

* move ONE_HOUR to constants

* use sane_repr

* fix typo
2021-12-17 13:54:03 +01:00
Yakko Majuri
963c62aaf1
Use monorepo plugin server (#6784)
* use plugin-server in same repo

* remove plugins dir

* update docker files

* clean up docker files:

* visual separation

* run plugin server test stack

* build and push test image

* revert push image

* fix default yarn start

* another fix

* fix some more

* add plugin-server-prod script

* make executable

* update scripts:

* revert prod script

* fixes

* fix tests

* clean

* move build to docker

* build plugin-server in prod dockerfile

* use different entrypoint for e2e test

* fix bugs with ts-node-dev

* restore yarn.lock

* lost a few changes in the rebase

* fix dockerfile

Co-authored-by: James Greenhill <fuziontech@gmail.com>
2021-11-13 11:52:00 -08:00
Yakko Majuri
7a3e25742d
Fix pre-commit hook (#6902)
* pre commit hook

* final config options

* try new approach

* update prettierignore
2021-11-04 17:09:40 +00:00
Karl-Aksel Puulmann
28d1c48959
Update package.json (#6741)
I've been running a custom version of package.json since forever.

Here's my suggestion for cleaning it up
2021-11-03 11:51:06 +02: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