PostHog VS Code Extension Playground
This is a playground to test PostHog integration within a VS Code extension's webview.
How to run
- Open this directory (
packages/browser/playground/vscode-extension) in a separate VS Code window. - Open a terminal and run
pnpm install. - Press
F5to open a new Extension Development Host window. - In the new window, open the Command Palette (
Cmd+Shift+PorCtrl+Shift+P) and search for "Start PostHog Playground". - Run the command to open the webview.
- You can interact with the input and button to send events to PostHog.
Configuration
Running with a local posthog-js build
By default, the playground is configured to use a local build of posthog-js. In src/extension.js, the runningLocally constant is set to true. This will load array.full.js from the packages/browser/dist directory.
To use the production snippet from the PostHog CDN, you will need to set runningLocally to false.
Environment Variables
The PostHog project key and API host are loaded from a .env file in the root of the posthog-js repository.
- If you don't already have one, create a
.envfile at the root of theposthog-jsproject. - Add your PostHog Project Key to the
.envfile:IfPOSTHOG_PROJECT_API_KEY=<your-project-key> POSTHOG_API_HOST=<your-api-host>POSTHOG_API_HOSTis not set, it will default tohttp://localhost:8010.