|
1 |
| -# PostHog Template for the Next TypeScript Package |
| 1 | +# Hello World – a PostHog Plugin |
2 | 2 |
|
3 |
| -[](https://www.npmjs.com/package/♦️♦️♦️SET-YOUR-OWN-PACKAGE-NAME-HERE♦️♦️♦️) |
| 3 | +[](https://www.npmjs.com/package/posthog-plugin-hello-world) |
4 | 4 | [](https://opensource.org/licenses/MIT)
|
5 | 5 |
|
6 |
| -> Hey there! Starting a new JS/TS package? |
7 |
| -> |
8 |
| -> Whether it's a library, a plugin, an integration, a CLI, or anything else in the world: |
9 |
| -> |
10 |
| -> - Write it in TypeScript for best reliability and development experience. |
11 |
| -> - Use the battle-tested Yarn for dependency management. |
12 |
| -> - Test quickly and easily with Jest (plus `ts-jest` for TypeScript support). |
13 |
| -> - Adhere to PostHog Style™️ by formatting code with Prettier and ensuring best practices with ESLint |
14 |
| -> – or actually, don't do it: let pre-commit hooks handle this for you. |
15 |
| -> - Have GitHub Actions run all of the above when working on pull requests. Plus have them take care of publishing releases on npm and GitHub whenever the version is incremented. |
16 |
| -> |
17 |
| -> Start out using this template and hit the ground quickly with all of the above from the get-go. |
18 |
| -> |
19 |
| -> ## Get on with it |
20 |
| -> |
21 |
| -> 1. Update fields `name`, `description`, `keywords`, `respository`, `bugs` and `homepage` in `package.json`. |
22 |
| -> 2. Make sure that you have Yarn installed and run `yarn` to install dependencies. |
23 |
| -> Note: file `yarn.lock` will be created. Commit this. |
24 |
| -> 3. Write your package, starting with `src/index.ts`! |
25 |
| -> |
26 |
| -> _When publishing on GitHub, add an automation-type npm access token as GitHub secret `NPM_TOKEN` in order for auto-release to work._ |
| 6 | +This is an exemplary PostHog plugin. It adds property `"greeting"` to every event with a configurable value – `"Hello world!"` by default. |
27 | 7 |
|
28 |
| -_Now, erase the notes above and fill this README with something actually relevant! Don't forget to update the npm badge too._ |
| 8 | +A few goodies included with this plugin: |
| 9 | +- TypeScript for best reliability and development experience, |
| 10 | +- Jest for convenient testing, |
| 11 | +- Prettier and ESLint for code style and best practices – both handled by pre-commit hooks, |
| 12 | +- GitHub Actions set up to run code quality and functionality tests in pull requests, and also to publish a new npm release when the package version is incremented in `main` (the latter requires an automation type npm access token to be set with a repo secret `NPM_TOKEN`). |
29 | 13 |
|
30 | 14 | ## Questions?
|
31 | 15 |
|
|
0 commit comments