Please see PostHog Docs. Specifically, browser JS library details.
Unit tests: run yarn test
.
Cypress: run yarn serve
to have a test server running and separately yarn cypress
to launch Cypress test engine.
Testing on IE11 requires a bit more setup.
- Run
posthog
locally on port 8000 (DEBUG=1 TEST=1 ./bin/start
). - Run
python manage.py setup_dev --no-data
on posthog repo, which sets up a demo account. - Optional: rebuild array.js on changes:
nodemon -w src/ --exec bash -c "yarn build-array"
. - Export browserstack credentials:
export BROWSERSTACK_USERNAME=xxx BROWSERSTACK_ACCESS_KEY=xxx
. - Run tests:
npx testcafe "browserstack:ie" testcafe/e2e.spec.js
.
Use yarn link
. Run yarn link
in posthog-js
, and then yarn link posthog-js
in posthog
. Once you're done, remember to yarn unlink posthog-js
in posthog
, and yarn unlink
in posthog-js
.
An alternative is to update dependency in package.json to e.g. "posthog-js": "link:../posthog-js"
, yarn
and run yarn build && yarn build-module
Use Yalc
Run npm install -g yalc
- run
yalc publish
- run
yalc add posthog-js
- run
yarn
- run
yarn copy-scripts
- run
yalc publish
- run
yalc update
- run
yarn
- run
yarn copy-scripts
- run
yalc remove posthog-js
- run
yarn install
The posthog-js
snippet for a website loads static js from the main PostHog/posthog
repo. Which means, when testing the snippet with a website, there's a bit of extra setup required:
- Run
PostHog/posthog
locally - Link the
posthog-js
dependency to your local version (see above) - Run
yarn serve
inposthog-js
. (This ensuresdist/array.js
is being generated) - In your locally running
PostHog/posthog
build, runyarn copy-scripts
. (This copies the scripts generated in step 3 to the static assets folder forPostHog/posthog
)
Further, it's a good idea to modify start-http
script to add development mode: webpack serve --mode development
, which doesn't minify the resulting js (which you can then read in your browser).
Just bump up version
in package.json
on the main branch and the new version will be published automatically,
with a matching PR in the main PostHog repo created.
It's advised to use bump patch/minor/major
label on PRs - that way the above will be done automatically
when the PR is merged.
Courtesy of GitHub Actions.
To release a new version, make sure you're logged into npm (npm login
).
We tend to follow the following steps:
- Merge your changes into master.
- Release changes as a beta version:
npm version 1.x.x-beta.0
npm publish --tag beta
git push --tags
- Create a PR linking to this version in the main PostHog repo.
- Once deployed and tested, write up CHANGELOG.md, and commit.
- Release a new version:
npm version 1.x.x
npm publish
git push --tags
- Create a PR linking to this version in the main PostHog repo.