3.2 KiB
3.2 KiB
title | sidebar | showTitle | hideAnchor |
---|---|---|---|
4. Developer Workflow | Handbook | true | true |
If you haven't already, it's worth your time to read Contributing to PostHog.
Most developers use either vscode or pycharm but you are free to use whatever IDE makes the most sense to you.
Backend w/ Vscode
- Create a git branch
- Start PostHog with
bin/start
- Open app in Chrome and login
- Open Chrome devtools to network tab
- Navigate to scene (aka screen or page) and click on the area of interest
- Find network request in devtools and find request
- Request maps to ./posthog/api/*.py, i.e. http://localhost:8000/api/insight/funnel/?insight=FUNNELS -> ./posthog/api/insight.py:197
- Make code changes including tests
- Run backend tests
bin/tests posthog
runs only posthog tests excluding ee tests./bin/tests ee/clickhouse/queries/test/test_trends.py -k test_active_user_math
for specific tests
- Commit changes to git branch
- Open PR for review
- Include Github issue number
#1234
which Github will automatically link for you
- Include Github issue number
Frontend w/ Vscode
- Same as backend 1-5
- Find frontend code, i.e.
frontend/src/scenes/insights/Insight.tsx
- Use
console.log
liberally - As of writing, there are no unit tests for the frontend although we do have integration tests for the frontend via Cypress
- Same as backend 9-10
Alternative: Pycharm
Some developers prefer to use Pycharm and for good reason. While there are many benefits, below you'll find a few keys benefits.
Debugging and no print() statements
this is probably the biggest win in my opinion. Since we are learning a new codebase there is no shame in having an assistant. Pycharm will show you the call stack and variable values. This is huge for understanding what is going on.Code navigation
when you are new to a codebase, moving easily through the code can be a real challenge, especially when there are multiple layers of abstraction. Pycharm allows you to Ctrl+Click nearly all methods to jump to their definitions. While editors like vscode have a similar feature, you'll find that Pycharm works in cases where vscode does not.Run configurations
make starting celery, django, and webpack services simple. It's mostly just clicking things.Excellent TypeScript support
with code completion and type checking directly in your editor.Click instead of type
which means that you spend much more time typing code than running commands. Nearly everything in Pycharm is clickable.
Pycharm offers a try it for free 30-day trial. It's recommended that you use it for at least that amount of time before you buy. I recommend watching The Future of Programming that will blow your mind and perhaps give you a new perspective on tools like these.