ekx-posthoglisted
Install: claude install-skill Ekinoxis-evm/claude-skills
# PostHog
Our product analytics (`posthog-js` + `posthog-node`).
---
## Environment
```bash
VITE_POSTHOG_KEY= # project API key — public by design
VITE_POSTHOG_HOST= # https://us.i.posthog.com
```
The project key is meant to be public — it can only write events. It is not a secret,
but it *is* a spam vector, so keep the ingestion endpoint behind a reverse proxy if
event volume ever becomes a cost problem.
---
## Client
```ts
posthog.init(import.meta.env.VITE_POSTHOG_KEY, {
api_host: import.meta.env.VITE_POSTHOG_HOST,
person_profiles: "identified_only", // don't bill for anonymous profiles
capture_pageview: true,
});
```
## Server
```ts
import { PostHog } from "posthog-node";
const posthog = new PostHog(key, { host });
posthog.capture({ distinctId: userId, event: "loan_requested", properties: { amount_usdc: 5000 } });
await posthog.shutdown(); // serverless: REQUIRED, or events are lost
```
**`await posthog.shutdown()` before a serverless function returns.** `posthog-node`
batches, and the function freezes with the batch unsent otherwise. This is the single
most common reason server events "don't appear".
---
## Identifying
```ts
posthog.identify(userId, { email: user.email }); // on login
posthog.reset(); // on logout — or the next user inherits the session
```
Use a **stable internal id** as `distinctId`. Not a wallet address (users have
several, and they rotate), not an email (it changes).
---
#