Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin v8 #1946

Merged
merged 251 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
5db7fc8
Merge branches 'plugins' and 'master' of github.com:PostHog/posthog i…
fuziontech Oct 7, 2020
9cd8318
plugin progress
fuziontech Oct 7, 2020
41076d7
blah
fuziontech Oct 7, 2020
66fed09
add posthog config for plugins
fuziontech Oct 7, 2020
862a7d8
test gitignore
fuziontech Oct 7, 2020
bbfc091
new functionality for plugins
fuziontech Oct 7, 2020
632956e
support local plugin paths
mariusandra Oct 7, 2020
1506306
also ignore symlinks
mariusandra Oct 7, 2020
eceac05
add positional argument
mariusandra Oct 7, 2020
a7a10d3
fixes
mariusandra Oct 7, 2020
59736dd
small fixes
mariusandra Oct 7, 2020
28fa6f5
config polish
fuziontech Oct 8, 2020
1bc6a7a
config passed to posthog plugin
fuziontech Oct 8, 2020
6381322
ooooooops
fuziontech Oct 8, 2020
a4c211e
symlink fix
fuziontech Oct 8, 2020
a10a607
cleanse dir before loading
fuziontech Oct 8, 2020
fc40fe3
add cache to plugins
fuziontech Oct 8, 2020
2e29a72
pickle the goods
fuziontech Oct 8, 2020
b5f6552
unlink symlink
mariusandra Oct 8, 2020
ace5375
pass full config
fuziontech Oct 8, 2020
caf1e86
Merge branch 'plugins' of github.com:PostHog/posthog into plugins
fuziontech Oct 8, 2020
4d33754
unlink even if link points to nothing
mariusandra Oct 8, 2020
d7d24d4
Merge branch 'plugins' of github.com:PostHog/posthog into plugins
mariusandra Oct 8, 2020
a1f7050
fix fix
mariusandra Oct 8, 2020
41e880d
return none if value is empty
fuziontech Oct 8, 2020
3fe8fa6
Merge branch 'plugins' of github.com:PostHog/posthog into plugins
fuziontech Oct 8, 2020
9eb7142
plugin model
mariusandra Oct 8, 2020
6760803
plugins scene
mariusandra Oct 8, 2020
caac3d1
add config schema to plugins
mariusandra Oct 8, 2020
74aa457
install plugins
mariusandra Oct 8, 2020
ec250cd
save descriptions
mariusandra Oct 9, 2020
61d8245
show descriptions
mariusandra Oct 9, 2020
025860f
edit plugin
mariusandra Oct 9, 2020
87f88d1
save plugin config
mariusandra Oct 9, 2020
347cfc8
plugin modal
mariusandra Oct 9, 2020
b0ad187
uninstall plugins
mariusandra Oct 9, 2020
ebedf5b
UX cleanup
mariusandra Oct 9, 2020
7e10e0b
add "required" to plugin config
mariusandra Oct 9, 2020
0a30500
open plugin modal after install
mariusandra Oct 9, 2020
f5f96d5
split to subcomponents
mariusandra Oct 9, 2020
2d7c226
install custom plugins
mariusandra Oct 9, 2020
25dc309
rework backend for model plugins
fuziontech Oct 9, 2020
f069cd7
Plugins on models
fuziontech Oct 9, 2020
b8f5f11
Merge branch 'plugin-setup' of github.com:PostHog/posthog into plugin…
fuziontech Oct 9, 2020
e3bc924
simple reload pubsub
mariusandra Oct 9, 2020
7e36de4
Merge branch 'plugin-setup' of github.com:PostHog/posthog into plugin…
mariusandra Oct 9, 2020
5c6300d
fix apps not installed
mariusandra Oct 10, 2020
5c5caf4
fix master/main issue
mariusandra Oct 10, 2020
a4caa01
fix reload command
mariusandra Oct 10, 2020
1227d8b
use the github api to get the default branch
mariusandra Oct 10, 2020
a018abf
init plugins only if not running migrate/makemigrations
mariusandra Oct 10, 2020
c53f0b6
store plugins zip archives in postgres
mariusandra Oct 10, 2020
8463924
tag plugins to specific versions
mariusandra Oct 10, 2020
ffd9246
save plugins in pluginConfig
mariusandra Oct 10, 2020
a9e216c
update pluginConfigs instead of adding new rows, remove from redux on…
mariusandra Oct 10, 2020
a86e269
remove debug
mariusandra Oct 10, 2020
cc9c25d
run plugins from db by team
mariusandra Oct 10, 2020
21c0c14
reload when deleting
mariusandra Oct 10, 2020
622d324
remove debug
mariusandra Oct 10, 2020
d4dd514
smarter handling of dynamic plugins, support local plugins again
mariusandra Oct 13, 2020
5fea1fa
improve typings, add some nicer warnings
mariusandra Oct 13, 2020
15a0704
Merge branch 'master' into plugin-setup
mariusandra Oct 14, 2020
b80fb68
yarn lock file after merge
mariusandra Oct 14, 2020
51c1f96
squash migrations and add "locked" field to plugins
mariusandra Oct 14, 2020
9256cfb
error if folder not found in zip
mariusandra Oct 14, 2020
6c83b1c
unregister plugins
mariusandra Oct 14, 2020
cd38b1c
skip plugin init in test mode
mariusandra Oct 14, 2020
fbc987e
basic plugin test
mariusandra Oct 14, 2020
d5f2f26
avoid mutating the same prop hash
mariusandra Oct 14, 2020
925db29
add pip tools to requirements.txt
mariusandra Oct 14, 2020
249b0fe
fix mypy, fix manage.py script error
mariusandra Oct 14, 2020
de61cd3
avoid plugins with mypy
mariusandra Oct 14, 2020
a9a1485
mypy fix
mariusandra Oct 14, 2020
ceaff45
abstract redis into plugin and add team_id to reload
mariusandra Oct 14, 2020
22b6566
Merge branch 'master' into plugin-setup
mariusandra Oct 14, 2020
52b89f8
refactor and start work on syncing with posthog.json
mariusandra Oct 14, 2020
1fad2b0
start testing plugin loading from json
mariusandra Oct 14, 2020
3a74b65
test plugin deletion
mariusandra Oct 15, 2020
9651e9e
test for syncing plugins from config
mariusandra Oct 15, 2020
1a4690b
complete and then test local json plugin sync
mariusandra Oct 15, 2020
8f9cc74
test converting back and forward between an local and http path
mariusandra Oct 15, 2020
866fea5
remove global plugin config from plugins array in posthog.json
mariusandra Oct 15, 2020
2e77823
rename configSchema --> config_schema
mariusandra Oct 15, 2020
5f95bf4
Merge branch 'master' into plugin-setup
mariusandra Oct 15, 2020
d76e134
fix migration after merge
mariusandra Oct 15, 2020
47901fa
rename from_cli to from_json
mariusandra Oct 15, 2020
21c752c
mypy
mariusandra Oct 15, 2020
598b7b6
import pip after plugin loaded
mariusandra Oct 15, 2020
5e96698
show error details
mariusandra Oct 15, 2020
318d740
raise exceptions visible to the frontend
mariusandra Oct 15, 2020
fb25a47
sync plugins on load
mariusandra Oct 15, 2020
4075c2b
access control to updating plugins from the web
mariusandra Oct 15, 2020
a3da59c
access control
mariusandra Oct 15, 2020
355fc84
remove posthog.json from git
mariusandra Oct 15, 2020
c210068
test config schema from json
mariusandra Oct 15, 2020
5dbcf64
if you can install via the web, you can also configure
mariusandra Oct 15, 2020
95116ed
remove separate view access
mariusandra Oct 15, 2020
d2cda53
Merge branch 'master' into plugin-setup
mariusandra Oct 15, 2020
4ee561b
title as "Plugins" instead of "Installed Plugins" if we can't install…
mariusandra Oct 15, 2020
74f1b29
add self.team to plugin base class
mariusandra Oct 16, 2020
4002fd4
add instance_init method
mariusandra Oct 16, 2020
5329efd
refactor into files
mariusandra Oct 16, 2020
9880904
Merge branch 'master' into plugin-setup
mariusandra Oct 16, 2020
bd3ea3c
sync global plugin config from json
mariusandra Oct 16, 2020
5277078
make global plugins work, add test
mariusandra Oct 16, 2020
90c175b
global plugins in interface, make them take precedence over local plu…
mariusandra Oct 16, 2020
68bc12e
add comments to plugin base class
mariusandra Oct 16, 2020
0fea379
reload/reset plugins before each test
mariusandra Oct 16, 2020
612d515
add error field to plugins
mariusandra Oct 16, 2020
9c6baac
add many plugin zips
mariusandra Oct 16, 2020
c57613a
add many plugin zips, fix imports
mariusandra Oct 16, 2020
034a03c
store errors on plugin object and test them
mariusandra Oct 17, 2020
4e503b0
fix types
mariusandra Oct 17, 2020
2c821ed
add null to error
mariusandra Oct 17, 2020
bebd013
can be with any team ID in the test
mariusandra Oct 17, 2020
d2639d3
save problems running plugins in the plugin_config model
mariusandra Oct 17, 2020
90f62ae
Merge branch 'master' into plugin-setup
mariusandra Oct 17, 2020
b0762e6
try to create redis connection pool only once
mariusandra Oct 17, 2020
89940a6
throw if no redis
mariusandra Oct 17, 2020
63ea29e
mypy
mariusandra Oct 17, 2020
4136976
get instance inside heartbeat and not top level
mariusandra Oct 17, 2020
e5149e7
try caching pubsub
mariusandra Oct 17, 2020
6c01dfb
try pip install with -q
mariusandra Oct 19, 2020
16ef544
install pip externally
mariusandra Oct 19, 2020
717313f
remove uuid and typing, now in stdlib
mariusandra Oct 19, 2020
2890e51
more verbosity
mariusandra Oct 19, 2020
41d216c
add pip back
mariusandra Oct 19, 2020
441f2a2
catch exceptions
mariusandra Oct 19, 2020
aee8f48
quiet and no input for pip
mariusandra Oct 19, 2020
3f31fe0
check plugin reload every 10sec on new task
mariusandra Oct 19, 2020
51a4241
fix type errors
mariusandra Oct 19, 2020
d3486b4
fix requirements error message
mariusandra Oct 19, 2020
5729fd4
use repository.json
mariusandra Oct 19, 2020
a0d1b95
only load and reload plugins on workers
mariusandra Oct 19, 2020
47a5036
Merge branch 'master' into plugin-setup
mariusandra Oct 20, 2020
9d64bf0
rename task
mariusandra Oct 20, 2020
484b93c
support local js plugins via py-mini-racer
mariusandra Oct 20, 2020
410c1cd
load js plugins from zip files
mariusandra Oct 20, 2020
e179ea0
extract jsplugin class and convert to syntax that uses global functio…
mariusandra Oct 23, 2020
4c9deef
process events via grpc
mariusandra Oct 23, 2020
a0d7272
process events with the "posthog-plugins" queue to enable plugins
mariusandra Oct 27, 2020
711c40b
remove old native python & mini racer plugin code
mariusandra Oct 27, 2020
da78763
default to false
mariusandra Oct 27, 2020
eb3aa02
change env vars
mariusandra Oct 27, 2020
826cb29
fix test
mariusandra Oct 27, 2020
cf4b289
remove grpc tools
mariusandra Oct 27, 2020
c388038
skip plugins in migrate.py scripts
mariusandra Oct 27, 2020
ad5592b
Merge branch 'master' into plugin-v8
mariusandra Oct 27, 2020
07117b5
fix migration
mariusandra Oct 27, 2020
4f8fb5f
change output of settings debug banner to STDERR
mariusandra Oct 27, 2020
bda31d6
start posthog plugin server with worker
mariusandra Oct 27, 2020
0124d7f
try to fix python 3.7 test
mariusandra Oct 28, 2020
d774b51
add fallback for the optional argument
mariusandra Oct 28, 2020
26b45f5
annoying CI test debug
mariusandra Oct 28, 2020
b833324
try to finally fix python 3.7 test
mariusandra Oct 28, 2020
4c69fd3
here we go again
mariusandra Oct 28, 2020
12d9357
move plugins under instance
mariusandra Oct 28, 2020
d43ac1e
move plugins npm start into its own folder
mariusandra Oct 28, 2020
fb55977
more console.log debugginf
mariusandra Oct 28, 2020
5362a2b
and again
mariusandra Oct 28, 2020
894967d
move plugins to separate script
mariusandra Oct 28, 2020
2fa040f
more prints
mariusandra Oct 28, 2020
c98688b
fix test error
mariusandra Oct 28, 2020
994744c
docker config
mariusandra Oct 28, 2020
ff62ce1
small fixes
mariusandra Oct 28, 2020
7cddec1
dckerfile fix
mariusandra Oct 28, 2020
15dfbd1
reload plugins via pubsub, upgrade version
mariusandra Oct 28, 2020
e34d31b
plugins that support team setup code
mariusandra Oct 28, 2020
dee65ba
sync if made changes from config
mariusandra Oct 28, 2020
e474bf5
move plugins in menu
mariusandra Oct 28, 2020
909a11a
Merge branch 'master' into plugin-v8
mariusandra Oct 28, 2020
222ccbb
require node 14 in heroku for better plugin support (namely ?. support)
mariusandra Oct 28, 2020
a76344e
bump node version in dockerfiles
mariusandra Oct 28, 2020
9d7b683
update node versions for github actions
mariusandra Oct 28, 2020
b3ea1bc
update the concurrency for heroku workers
mariusandra Oct 28, 2020
a732ba4
update the concurrency for heroku workers (add link)
mariusandra Oct 28, 2020
f255de2
Merge branch 'master' into plugin-v8
mariusandra Oct 28, 2020
76ec442
Merge branch 'master' into plugin-v8
mariusandra Oct 28, 2020
43fda69
Fix migrations after merge
mariusandra Oct 28, 2020
2b412cd
Merge branch 'master' into plugin-v8
mariusandra Oct 29, 2020
e3cfefc
Merge branch 'plugin-v8' of github.com:PostHog/posthog into plugin-v8
mariusandra Oct 29, 2020
fd36d3d
add ignore_result to process_event tasks
mariusandra Oct 29, 2020
525eb9a
fix: docker-preview run in parallel bug
mariusandra Oct 29, 2020
74db745
Merge branch 'master' into plugin-v8
mariusandra Oct 30, 2020
00dca81
change order of commands
mariusandra Oct 30, 2020
9b6e8e3
remove separate plugins server conf script
mariusandra Oct 30, 2020
6d5af86
clarify intent
mariusandra Oct 30, 2020
b10eeae
revert castaway change
mariusandra Oct 30, 2020
8e6b88f
add context to plugins/sync.py
mariusandra Oct 30, 2020
023ab76
change everything to ValidationError
mariusandra Oct 30, 2020
a99049a
delegate destroy to super
mariusandra Oct 30, 2020
daed81f
no request to repository url if can't install
mariusandra Oct 30, 2020
a473cf7
make the if cleaner
mariusandra Oct 30, 2020
0c92b10
add clarifying line
mariusandra Oct 30, 2020
87c689c
add clarifying line
mariusandra Oct 30, 2020
046def1
fix url field type
mariusandra Oct 30, 2020
e7e47c6
rename get_redis_instance to get_client, move to posthog.redis
mariusandra Oct 30, 2020
d274040
remove duplicate validation
mariusandra Oct 30, 2020
30b73bb
flip if around
mariusandra Oct 30, 2020
26fc7f9
simplify api logic
mariusandra Oct 30, 2020
676f83f
simplify plugin_config api, fix global_plugin error
mariusandra Oct 30, 2020
0a0ef63
remove unnecessary field rename
mariusandra Oct 30, 2020
25db54c
mypy
mariusandra Oct 30, 2020
eed83ff
Plugins UI (#2090)
paolodamico Nov 1, 2020
2a2b444
add plugins opt in toggle to project/plugins
mariusandra Nov 1, 2020
6ccfc1b
Merge branch 'master' into plugin-v8
mariusandra Nov 1, 2020
55cb955
choose pipeline based on team setting
mariusandra Nov 1, 2020
88ce5bc
add "beta"
mariusandra Nov 1, 2020
1631767
plugin opt-in opt-out pages
mariusandra Nov 1, 2020
5570556
adjust install button
mariusandra Nov 1, 2020
2f3d4f9
remove tasks that are never called, remove PLUGINS_ENABLED global key
mariusandra Nov 1, 2020
5c6d580
fix responsive card display
mariusandra Nov 1, 2020
29dd150
fix typo and drawer width
mariusandra Nov 1, 2020
4240983
skeleton fixes
mariusandra Nov 1, 2020
d4ddb8a
typo
mariusandra Nov 1, 2020
a6f48b9
use "posthog-plugin-server" npm package
mariusandra Nov 1, 2020
028ef6a
"posthog-plugin-server" doc
mariusandra Nov 1, 2020
86abcde
require the plugin server to be online before enabling plugins
mariusandra Nov 1, 2020
93ccca6
remove a few needeless "?." cases
mariusandra Nov 1, 2020
2a84cd9
add hint for config_schema
mariusandra Nov 1, 2020
47a0265
add hint for errors
mariusandra Nov 1, 2020
e84c61a
show plugin errors
mariusandra Nov 1, 2020
3bb81d9
stop clicks if clicking on error
mariusandra Nov 1, 2020
2f20225
show plugin errors
mariusandra Nov 1, 2020
6a44ceb
loading indicators
mariusandra Nov 2, 2020
1186081
reload plugins when opting in/out
mariusandra Nov 2, 2020
2108699
nicer beta tag
mariusandra Nov 2, 2020
df8a894
add frontend type
mariusandra Nov 2, 2020
3f782fb
fix mypy error
mariusandra Nov 2, 2020
24e582a
fix test
mariusandra Nov 2, 2020
c7380f0
disable plugins if MULTI_TENANCY
mariusandra Nov 2, 2020
1c8d1c6
upgrade plugin-server version
mariusandra Nov 2, 2020
15a1ab9
save event with plugin error
mariusandra Nov 2, 2020
799d7c9
upgrade plugin server
mariusandra Nov 2, 2020
3ce9c7a
squashed & optimized migrations
paolodamico Nov 2, 2020
bf90b5a
remove unused import
paolodamico Nov 2, 2020
59623d5
updates opt-in copy & hides tech details for cloud version
paolodamico Nov 2, 2020
6c80b44
fix cypress tests
paolodamico Nov 2, 2020
407168b
compare with None
mariusandra Nov 2, 2020
284bddc
change plugins url and add redirect
mariusandra Nov 2, 2020
a345be7
remove ellipsis
mariusandra Nov 2, 2020
8d1de95
use code snippet in plugin errors
mariusandra Nov 2, 2020
4a6c00e
change github regex
mariusandra Nov 2, 2020
4888e6e
fix loading flickering on installing plugins
mariusandra Nov 2, 2020
4a8d7ea
add comment to plugin archive
mariusandra Nov 2, 2020
cc2f4ec
fix python style
mariusandra Nov 2, 2020
1cd4bcb
remove pip-tools (relic from the python plugin era)
mariusandra Nov 2, 2020
f2b3efc
hard pin plugin server version
mariusandra Nov 2, 2020
9add77c
remove copying of posthog.json from dev dockerfile (breaks if file do…
mariusandra Nov 2, 2020
0fcb4e6
update lockfile
mariusandra Nov 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
!requirements.txt
!requirements/dev.txt
!posthog
!plugins
!staticfiles
!manage.py
!gunicorn.config.py
!babel.config.js
!posthog.json
!package.json
!yarn.lock
!webpack.config.js
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Node 12
- name: Set up Node 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Install package.json dependencies with Yarn
run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
python -m pip install psycopg2-binary --no-cache-dir --compile
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14
- name: Get yarn cache directory path
id: yarn-dep-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ yarn-error.log
yalc.lock
cypress/screenshots/*
docker-compose.prod.yml
posthog.json
.python-version
1 change: 1 addition & 0 deletions bin/docker-preview
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export REDIS_URL=redis://localhost
/etc/init.d/redis-server start > /dev/null

DEBUG=1 celery -A posthog worker --loglevel=info &
DEBUG=1 ./bin/plugin-server &
DEBUG=1 gunicorn posthog.wsgi --config gunicorn.config.py --bind 0.0.0.0:8000 --log-file - -e DEBUG=1 -e DATABASE_URL=postgres://posthog:posthog@localhost:5432/posthog
1 change: 1 addition & 0 deletions bin/docker-worker
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ then
echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
else
rm celerybeat.pid || echo "celerybeat.pid not found, proceeding"
./bin/docker-worker-plugins &
./bin/docker-worker-beat &
./bin/docker-worker-celery
fi
4 changes: 4 additions & 0 deletions bin/docker-worker-plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

./bin/plugin-server
4 changes: 4 additions & 0 deletions bin/plugin-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
KEYS="DATABASE_URL REDIS_URL PLUGINS_CELERY_QUEUE CELERY_DEFAULT_QUEUE BASE_DIR PLUGINS_RELOAD_PUBSUB_CHANNEL"
CONF=`python manage.py print_settings --format json --indent 0 $KEYS 2> /dev/null | tr -d '\n' | sed 's/\n$//'`
cd plugins && yarn --frozen-lockfile --silent && yarn --silent start --config "$CONF"
8 changes: 7 additions & 1 deletion bin/start-worker
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash
set -e

# this kills all processes when the last one terminates
trap 'kill $(jobs -p)' EXIT

# start celery worker with heartbeat (-B)
celery -A posthog worker -B --scheduler redbeat.RedBeatScheduler
celery -A posthog worker -B --scheduler redbeat.RedBeatScheduler &

# start celery plugin worker
./bin/plugin-server
4 changes: 2 additions & 2 deletions cypress/integration/projectSettings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Setup', () => {
it('Setup loaded', () => {
cy.get('[data-attr=menu-item-project-settings]').click()
cy.get('[data-attr=menu-item-project]').click()
cy.get('[data-attr=layout-content]').should('exist')
})

Expand All @@ -16,7 +16,7 @@ describe('Setup', () => {
})
})
cy.reload(true)
cy.get('[data-attr=menu-item-project-settings]').click()
cy.get('[data-attr=menu-item-project]').click()
cy.get('[data-attr=app-url-suggestion]').click()
cy.get('[data-attr=app-url-item]').should('contain', '/demo')
})
Expand Down
7 changes: 6 additions & 1 deletion dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /code

RUN apt-get update \
&& apt-get install -y --no-install-recommends curl git \
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& npm install -g yarn@1 \
&& yarn config set network-timeout 300000 \
Expand All @@ -30,6 +30,10 @@ COPY tsconfig.json /code/
COPY .kearc /code/
COPY frontend/ /code/frontend

RUN mkdir /code/plugins
COPY plugins/package.json /code/plugins/
COPY plugins/yarn.lock /code/plugins/

RUN mkdir /code/frontend/dist

COPY . /code/
Expand All @@ -39,5 +43,6 @@ RUN DEBUG=1 DATABASE_URL='postgres:///' REDIS_URL='redis:///' python manage.py c
EXPOSE 8000
EXPOSE 8234
RUN yarn install
RUN cd plugins && yarn install
ENV DEBUG 1
CMD ["./bin/docker-dev"]
4 changes: 2 additions & 2 deletions ee/clickhouse/process_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _capture_ee(

if check_ee_enabled():

@shared_task(ignore_result=True)
@shared_task(name="process_event_ee", ignore_result=True)
def process_event_ee(
distinct_id: str, ip: str, site_url: str, data: dict, team_id: int, now: str, sent_at: Optional[str],
) -> None:
Expand Down Expand Up @@ -117,7 +117,7 @@ def process_event_ee(

else:

@shared_task(ignore_result=True)
@shared_task(name="process_event_ee", ignore_result=True)
def process_event_ee(*args, **kwargs) -> None:
# Noop if ee is not enabled
return
Expand Down
3 changes: 3 additions & 0 deletions frontend/public/plugin-default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/initKea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function initKea(): void {
<div>
<h1>Error loading "{reducerKey}".</h1>
<p className="info">Action "{actionKey}" responded with</p>
<p className="error-message">"{error.message}"</p>
<p className="error-message">"{error.message || error.detail}"</p>
</div>
)
window['Sentry'] ? window['Sentry'].captureException(error) : console.error(error)
Expand Down
34 changes: 29 additions & 5 deletions frontend/src/layout/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ProjectOutlined,
LockOutlined,
WalletOutlined,
ApiOutlined,
DatabaseOutlined,
} from '@ant-design/icons'
import { useActions, useValues } from 'kea'
Expand Down Expand Up @@ -63,6 +64,8 @@ const submenuOverride = {
liveActions: 'events',
sessions: 'events',
cohorts: 'people',
projectSettings: 'project',
plugins: 'project',
organizationSettings: 'organization',
organizationMembers: 'organization',
organizationInvites: 'organization',
Expand Down Expand Up @@ -238,11 +241,32 @@ function _Sidebar({ user, sidebarCollapsed, setSidebarCollapsed }) {
<Link to={'/annotations'} onClick={collapseSidebar} />
</Menu.Item>

<Menu.Item key="projectSettings" style={itemStyle} data-attr="menu-item-project-settings">
<ProjectOutlined />
<span className="sidebar-label">Project</span>
<Link to={'/project/settings'} onClick={collapseSidebar} />
</Menu.Item>
<Menu.SubMenu
key="project"
title={
<span style={itemStyle} data-attr="menu-item-project">
<DeploymentUnitOutlined />
<span className="sidebar-label">Project</span>
</span>
}
onTitleClick={() => {
collapseSidebar()
if (location.pathname !== '/project/settings') push('/project/settings')
}}
>
<Menu.Item key="projectSettings" style={itemStyle} data-attr="menu-item-project-settings">
<ProjectOutlined />
<span className="sidebar-label">Settings</span>
<Link to={'/project/settings'} onClick={collapseSidebar} />
</Menu.Item>
{user.plugin_access.configure && (
<Menu.Item key="plugins" style={itemStyle} data-attr="menu-item-plugins">
<ApiOutlined />
<span className="sidebar-label">Plugins</span>
<Link to="/project/plugins" onClick={collapseSidebar} />
</Menu.Item>
)}
</Menu.SubMenu>

<Menu.SubMenu
key="organization"
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/lib/components/Drawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { useEffect } from 'react'
import { Drawer as AntDrawer } from 'antd'

export function Drawer(props: Record<string, any>): JSX.Element {
/* Extends Ant's Drawer component to add a class to the HTML body knowing when a drawer is open,
used to alter global stylying (e.g. move Papercups widget) */
const { visible } = props

useEffect(() => {
if (visible) {
document.body.classList.add('drawer-open')
} else {
document.body.classList.remove('drawer-open')
}
}, [visible])

return <AntDrawer {...props} />
}
16 changes: 16 additions & 0 deletions frontend/src/lib/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,19 @@ export function sampleSingle<T>(items: T[]): T[] {
if (!items.length) throw Error('Items array is empty!')
return [items[Math.floor(Math.random() * items.length)]]
}

export function parseGithubRepoURL(url: string): Record<string, string> {
const match = url.match(/^https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/?$/)
if (!match) {
throw new Error('Must be in the format: https://github.com/user/repo')
}
const [, user, repo] = match
return { user, repo }
}

export function someParentMatchesSelector(element: HTMLElement, selector: string): boolean {
if (element.matches(selector)) {
return true
}
return element.parentElement ? someParentMatchesSelector(element.parentElement, selector) : false
}
4 changes: 3 additions & 1 deletion frontend/src/scenes/ingestion/frameworks/CodeSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,18 @@ export interface CodeSnippetProps {
language?: Language
wrap?: boolean
actions?: Action[]
style?: React.CSSProperties
}

export function CodeSnippet({
children,
language = Language.Text,
wrap = false,
style = {},
actions,
}: CodeSnippetProps): JSX.Element {
return (
<div className="code-container">
<div className="code-container" style={style}>
<div className="action-icon-container">
{actions &&
actions.map(({ Icon, callback, popconfirmProps }, index) =>
Expand Down
43 changes: 43 additions & 0 deletions frontend/src/scenes/plugins/CustomPlugin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react'
import { Button, Card, Col, Input, Row } from 'antd'
import { useActions, useValues } from 'kea'
import { pluginsLogic } from 'scenes/plugins/pluginsLogic'

export function CustomPlugin(): JSX.Element {
const { customPluginUrl, pluginError, loading } = useValues(pluginsLogic)
const { setCustomPluginUrl, installPlugin } = useActions(pluginsLogic)

return (
<div style={{ marginTop: 32 }}>
<Card>
<h3 className="l3">Install Custom Plugin</h3>
<p>
To install a third-party or custom plugin, please paste the plugin's repository below.{' '}
<b className="text-warning">Warning: Only install plugins from trusted sources.</b>
</p>

<Row style={{ width: '100%' }} gutter={16}>
<Col style={{ flex: 1 }}>
<Input
value={customPluginUrl}
disabled={loading}
onChange={(e) => setCustomPluginUrl(e.target.value)}
placeholder="https://github.com/user/repo"
/>
</Col>
<Col>
<Button
disabled={loading}
loading={loading}
type="default"
onClick={() => installPlugin(customPluginUrl, true)}
>
Fetch and install
</Button>
</Col>
</Row>
{pluginError ? <p style={{ color: 'var(--red)', marginTop: 10 }}>{pluginError}</p> : null}
</Card>
</div>
)
}
51 changes: 51 additions & 0 deletions frontend/src/scenes/plugins/InstalledPlugins.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react'
import { Button, Col, Row } from 'antd'
import { useActions, useValues } from 'kea'
import { pluginsLogic } from 'scenes/plugins/pluginsLogic'
import { PlusOutlined } from '@ant-design/icons'
import { PluginCard, PluginLoading } from './PluginCard'
import { userLogic } from 'scenes/userLogic'

export function InstalledPlugins(): JSX.Element {
const { installedPlugins, loading } = useValues(pluginsLogic)
const { setPluginTab } = useActions(pluginsLogic)
const { user } = useValues(userLogic)

return (
<div>
<Row>
<h2 className="subtitle" style={{ flex: 1 }}>
Installed {!loading || installedPlugins.length > 0 ? `(${installedPlugins.length})` : ''}
</h2>
{user?.plugin_access.install && (
<div className="float-right mb" style={{ marginBottom: 16 }}>
<Button type="primary" icon={<PlusOutlined />} onClick={() => setPluginTab('available')}>
Install new plugin
</Button>
</div>
)}
</Row>
<Row gutter={16}>
{(!loading || installedPlugins.length > 0) && (
<>
{installedPlugins.map((plugin) => {
return (
<PluginCard
key={plugin.id}
pluginId={plugin.id}
name={plugin.name}
url={plugin.url}
description={plugin.description}
pluginConfig={plugin.pluginConfig}
error={plugin.error}
/>
)
})}
{installedPlugins.length == 0 && <Col span={24}>You don't have any plugins installed yet.</Col>}
</>
)}
{loading && installedPlugins.length === 0 && <PluginLoading />}
</Row>
</div>
)
}
Loading