Skip to content
Merged

cdn #31

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 18 additions & 10 deletions .posthog/wizard-spellbook-3Pm3hv/skills/mcp-analytics/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---

name: mcp-analytics
description: >-
Add PostHog MCP analytics to a TypeScript, JavaScript, or Python MCP server.
Captures tool calls, agent intent, failures, and protocol revision, plus
self-reported model identity on supported TypeScript paths. Both SDKs support
legacy sessions and the handshake-free 2026-07-28 revision. Detects the server
style and wires in compatible instrumentation, credentials, conversation
correlation, and graceful shutdown.
Add PostHog MCP analytics to a TypeScript, JavaScript, or Python MCP server.
Captures tool calls, agent intent, failures, and protocol revision, plus
self-reported model identity on supported TypeScript paths. Both SDKs support
legacy sessions and the handshake-free 2026-07-28 revision. Detects the server
style and wires in compatible instrumentation, credentials, conversation
correlation, and graceful shutdown.
metadata:
author: PostHog
version: 1.59.0
author: PostHog
version: 1.59.0
---

# Add PostHog MCP analytics
Expand Down Expand Up @@ -204,15 +205,22 @@ const serverTools = getServerTools();
const advertisedTools = posthog.prepareToolList(serverTools);

// only on a 2025-11-25 initialize handshake:
posthog.captureInitialize({ clientName, clientVersion, distinctId, protocolVersion: "2025-11-25" });
posthog.captureInitialize({
clientName,
clientVersion,
distinctId,
protocolVersion: "2025-11-25",
});

// after each tools/call resolves (wrap the existing handler, time it):
const start = Date.now();
const originalTool = serverTools.find((tool) => tool.name === request.params.name);
const { args, intent, intentSource, llmModel, llmModelSource } = posthog.prepareToolCall(
request.params.name,
request.params.arguments,
{ originalTool },
{
originalTool,
},
);
const result = await runTool(request.params.name, args);
posthog.captureToolCall({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export const handleError: HandleClientError = async ({ error, status, message })

```ts
import type { Handle, HandleServerError } from "@sveltejs/kit";
import { getPostHogClient } from "$lib/server/posthog";
import { getPostHogClient } from "#lib/server/posthog";

// Handle requests - includes reverse proxy for PostHog
export const handle: Handle = async ({ event, resolve }) => {
Expand Down Expand Up @@ -451,7 +451,7 @@ export function getAuthContext(): AuthState {

```svelte
<script lang="ts">
import { getAuthContext } from '$lib/auth.svelte';
import { getAuthContext } from '#lib/auth.svelte';

const auth = getAuthContext();
</script>
Expand Down Expand Up @@ -481,7 +481,7 @@ export function getAuthContext(): AuthState {
## src/lib/index.ts

```ts
// place files you want to import through the `$lib` alias in this folder.
// place files you want to import through the `#lib` alias in this folder.
```

---
Expand Down Expand Up @@ -517,8 +517,8 @@ export async function shutdownPostHog() {

```svelte
<script lang="ts">
import { AuthState, setAuthContext } from '$lib/auth.svelte';
import Header from '$lib/components/Header.svelte';
import { AuthState, setAuthContext } from '#lib/auth.svelte';
import Header from '#lib/components/Header.svelte';
import '../app.css';

let { children } = $props();
Expand Down Expand Up @@ -546,7 +546,7 @@ export async function shutdownPostHog() {

```svelte
<script lang="ts">
import { getAuthContext } from '$lib/auth.svelte';
import { getAuthContext } from '#lib/auth.svelte';

const auth = getAuthContext();

Expand Down Expand Up @@ -618,7 +618,7 @@ export async function shutdownPostHog() {
```ts
import { json } from "@sveltejs/kit";
import type { RequestHandler } from "./$types";
import { getPostHogClient } from "$lib/server/posthog";
import { getPostHogClient } from "#lib/server/posthog";

const users = new Map<string, { username: string; burritoConsiderations: number }>();

Expand Down Expand Up @@ -674,7 +674,7 @@ export const POST: RequestHandler = async ({ request }) => {
import { goto } from '$app/navigation';
import { browser } from '$app/environment';
import posthog from 'posthog-js';
import { getAuthContext } from '$lib/auth.svelte';
import { getAuthContext } from '#lib/auth.svelte';

const auth = getAuthContext();

Expand Down Expand Up @@ -737,7 +737,7 @@ export const POST: RequestHandler = async ({ request }) => {
import { goto } from '$app/navigation';
import { browser } from '$app/environment';
import posthog from 'posthog-js';
import { getAuthContext } from '$lib/auth.svelte';
import { getAuthContext } from '#lib/auth.svelte';

const auth = getAuthContext();

Expand Down
4 changes: 2 additions & 2 deletions .posthog/wizard-spellbook-l9xBb6/skills/audit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name: audit
description: Audit an existing PostHog integration for correctness and best practices
metadata:
author: PostHog
version: 1.59.0
author: PostHog
version: 1.59.0
---

# PostHog Audit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ All these differences make it more likely that you'll misinterpret your data. Im
```

- For event names, use the **category:object\_action** framework to make it easier to find a specific event within a long list:

- **category** describes the context the event took place in – e.g., `account_settings` or `signup_flow`.

- **object** is a noun that refers to the component or location the event took place in – e.g., `forgot_password_button` or `pricing_page`.
Expand All @@ -91,7 +90,6 @@ All these differences make it more likely that you'll misinterpret your data. Im
- Putting all of these together, you get `account_settings:forgot_password_button_click` or `signup_flow:pricing_page_view`.

- For property names:

- Use the **object\_adjective** pattern – e.g., `user_id`, `item_price`, or `member_count`.

- Use **is/has** prefixes for boolean properties – e.g., `is_subscribed`, `has_seen_upsell`.
Expand Down Expand Up @@ -143,13 +141,11 @@ Backend analytics are more reliable than frontend analytics. There are 3 reasons
Where possible, it's a good idea to log events on your server instead of your client. Here's a guide to help you decide when to rely on frontend or backend analytics:

- Use frontend analytics where getting partial data is acceptable, for example:

- Understanding user journeys, such as the sequence of pages a user visits.
- Tracking user interactions like clicks, scrolls, or form submissions.
- Gathering data on client-side performance, like page load times and responsiveness.

- Use backend analytics (or query your database) if:

- You need accurate data – e.g., the number of users that signed up in the last week.
- You want to analyze data alongside other business metrics.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---

name: self-driving-setup
description: >-
Set up PostHog Self-driving — enable the right signal sources, tune the scout
troop, and design custom scouts
Set up PostHog Self-driving — enable the right signal sources, tune the scout
troop, and design custom scouts
metadata:
author: PostHog
version: 1.59.0
author: PostHog
version: 1.59.0
---

# PostHog Self-driving setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Load `wizard_ask` via `ToolSearch select:mcp__wizard-tools__wizard_ask`. Reach `
## Do

1. **Build a short list from the codebase scan, then ask once.** The full catalog is ~36 tools — too many to show at once. The run prompt carries a **"Tools detected in this codebase"** block (a deterministic dependency + env-key scan the wizard ran on this project). Use it to keep the first ask short:

- **Detected tools first.** From that block, take every tool whose `source_type` matches an entry in the connected-tools catalog (the `source_type` list in step 2 — e.g. detected `Sentry` → Sentry, `Github` → GitHub Issues). Ignore detected sources that are **not** in the catalog (Postgres, Stripe, …) — those belong to step 4, not this ask. List these first, right after "None of these". If the run prompt carries no detected block (older wizard), fall back to any step-2 evidence for ordering.
- **Then the SaaS basics** — always offer GitHub Issues, Linear, Jira, Sentry, and Zendesk even when the scan didn't flag them; skip any already added above.
- **Then "Show more (N more hidden)"** — a final `show-more` option that opens the full catalog. Set `N` to the number of catalog tools you did **not** list above (36 minus the detected-plus-basics rows), so the label says how many are behind it instead of leaving the user to guess.
Expand Down Expand Up @@ -120,14 +119,12 @@ Two things narrow what actually bills, so don't imply every record becomes a PR:
2. Call `external-data-sources-list` once (step 2's project profile also lists warehouse sources when it exists). For each picked tool whose source already exists, match its warehouse `source_type`: `Github` / `Linear` / `Jira` / `GitLab` / `Gitea` / `Shortcut` / `Sentry` / `Rollbar` / `Bugsnag` / `Honeybadger` / `Raygun` / `Zendesk` / `Freshdesk` / `Freshservice` / `Front` / `Gorgias` / `Kustomer` / `Dixa` / `Plain` / `PgAnalyze` / `Snyk` / `Sonarqube` / `Semgrep` / `Rapid7Insightvm` / `Featurebase` / `Frill` / `Aha` / `Uservoice` / `Productboard` / `Canny` / `Asknicely` / `Retently` / `Appfigures` / `Appfollow` / `JudgeMeReviews` / `GoogleSearchConsole`. Record "already connected" — no connector flow needed, just enable its responder row (step 4 below).

3. Dispatch each picked tool that's still missing:

- **GitHub Issues** → read `references/5a-github.md` and follow it.
- **Linear** → read `references/5b-linear.md` and follow it.
- **Zendesk / pganalyze / Jira** (and any other API-credential source) → read `references/5c-credentials.md` and follow it. It hands the user a secure PostHog connect link, waits for them to store their credentials in the browser, then creates the live source from that stored credential. If they skip or don't finish, it falls back to the dormant responder + follow-up (step 4 below).
- **Google Search Console** → read `references/5d-google-search-console.md` and follow it. It hands the user a PostHog connect link that runs Google's OAuth grant and property pick in the browser and creates the source there, then verifies it via `external-data-sources-list`. If they skip or don't finish, it falls back to the dormant responder + follow-up (step 4 below).

4. Enable the source row (step 4's write recipe) for every tool the user picked — created, verified, and picked-but-not-connected alike (a dormant row is harmless and saves a later trip):

- GitHub Issues → `github` / `issue`
- Linear → `linear` / `issue`. When `5b-linear.md` recorded `linear_team_ids`, add `config: { "linear_team_ids": [...] }` to the create. When a row already exists, **read it with `inbox-source-configs-retrieve` first** and send that row's existing `config` keys back with the team ids merged in — a partial update replaces `config` as one whole object, and `inbox-source-configs-list` doesn't return it, so team ids written on their own delete the user's `steering` text and `default_not_actionable` flag. Both keys drive the actionability gate, so losing them silently changes which Linear issues become signals and which ones get a paid draft PR. A failed retrieve → still write `enabled: true`, write no `config`, and record the team pick as a follow-up; reading every team costs the user less than losing their steering. No recorded pick (already connected, or picked but not connected) → write no `config`; the row reads every team.
- Jira → `jira` / `issue`
Expand Down Expand Up @@ -166,7 +163,6 @@ Two things narrow what actually bills, so don't imply every record becomes a PR:
- Google Search Console → `google_search_console` / `search_opportunity`

5. Record each picked tool's final class honestly — the report consumes these verbatim:

- **connected by this setup** — the connector flow created the source (you have its id; the first sync starts automatically). This now includes credential sources the user connected through the `5c-credentials.md` link, not just GitHub/Linear.
- **already connected** / **verified connected** — the source row was seen in `external-data-sources-list`
- **picked but not connected** — the user picked the tool but skipped or didn't finish its connect step, so no live warehouse source exists: a connect link they didn't complete (Zendesk / pganalyze / Jira), Linear when its integration didn't land, or a GitHub Issues fallback the user skipped. **Enable the dormant responder and add a "Connect <tool>…" follow-up** — this is harmless, because a responder only emits once its warehouse source actually syncs, so a dormant row just saves the user a later trip. Record it honestly — never write that the user "confirmed connecting" and never "not used". Phrase it as "you selected <tool>, but no warehouse source was connected — the responder is enabled and stays dormant until you add the source and it starts syncing", plus the follow-up with the new-warehouse-source URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ The connect page renders the right credential form for that kind on its own.
- **skip** → record "picked but not connected" and return to step 5 (enable the dormant responder + follow-up — harmless, since it only emits once a warehouse source syncs).

3. **On done, fetch the stored credential once.** Call `data-warehouse-stored-credentials-list` with `{ "source_type": "<Type>" }` and take the **newest** `credential_id`. Stored credentials are single-use and expire after 24 hours, so read it right after the user confirms.

- **Credential present** → create the source (below).
- **None present** (the user didn't actually store anything, or it expired) → **don't re-ask or wait** — record "picked but not connected" and return to step 5 (the dormant responder + follow-up cover it; the user can finish the connect page later). This run never nudges.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Reach both through the PostHog `exec` tool (`info` then `call`): `data-warehouse
- **skip** → record "picked but not connected" and return to step 5 (enable the dormant responder + follow-up — harmless, since it only emits once a warehouse source syncs).

3. **On done, verify once.** Call `external-data-sources-list` and look for a source whose `source_type` is `GoogleSearchConsole`.

- **Present** → record "connected by this setup (source id …, first sync started)". The connect page syncs `search_analytics_by_query_page` — the table the responder reads — by default, so there is nothing more to enable here.
- **Absent** (the user didn't finish, or closed the page early) → **don't re-ask or wait** — record "picked but not connected" and return to step 5 (the dormant responder + follow-up cover it; the user can finish the connect page later). This run never nudges.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ Core also owns loading the in-product `creating-replay-vision-scanners` skill (`
## Do

1. **Check recordings and existing scanners.** You already know from step 2 whether this project has recordings, and step 3 turned Session Replay on. Call `vision-scanners-list` once and reuse the inventory for every brief's re-run check.

- **No recordings yet** (a fresh project that has never recorded a session): still create the scanners — they cost nothing until recordings exist and start working the day they do, with no second setup. Note it in the report.
- **The team already runs its own scanners** covering a brief's ground (they fail core's re-run test): create only the briefs that add something, and say in the report which you skipped and why.

2. **Size before you ship**, per core. Two self-driving overlays:

- **Don't nag on a clearly-cheap create.** The briefs are deliberately small, so their projected spend is normally a tiny fraction of the budget — just create. Only when core's credit-to-credit comparison says the projected spend is a large fraction of (or exceeds) what's left, or the org is already `exhausted`, surface the concrete numbers in ONE `wizard_ask` (decline option first) — create-anyway vs skip — rather than creating blind. Record the estimate for the report either way.
- **Soft-degrade, never abort.** If the sizing skill or the estimate/quota tools aren't on this deploy, fall back to creating the briefs as-is — they can't burn a month at these defaults — and note in the report that spend wasn't verified. A missing tool here is a follow-up, not an abort. This step also always creates **standing** scanners: skip the in-product skill's "is a scanner even the right thing?" section and never substitute a one-off `vision-scanners-inline-scan-create`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Emit:
## Do

1. Write `./posthog-self-driving-report.md` (read any existing file first, then overwrite). Sections, in order:

- **Summary** — two or three sentences: what products and sources were turned on, and that findings will start appearing in the Self-driving inbox within ~30 minutes (include the inbox URL from the run prompt).
- **AI data processing** — approved. (The wizard's AI opt-in gate enforces organization approval before the run starts, so by the time you reach the report it is always granted — just record it as approved.)
- **GitHub** — connected (and whether it was already connected or connected during this run).
Expand Down
39 changes: 39 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "https://biomejs.dev/schemas/2.6.9/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"linter": {
"enabled": true,
"rules": {
"preset": "recommended"
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
},
"markdown": {
"parser": {
"frontmatter": true
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
Loading
Loading