You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've got live, working example code that demonstrates PostHog in action. You can run these yourself to see events flow into your PostHog project.
4
4
5
-
## These are not production-grade
5
+
## Example apps are not production-grade
6
6
7
7
These are more like model airplanes. They're dramatically simplified to make it easy to see PostHog in action. You shouldn't use these as starter projects or put them into production. The authentication is fake!
8
8
9
9
But the leanness makes these useful for agent-driven development. Use these as context to help your agent make better integration decisions about PostHog.
10
10
11
11
## Contents
12
12
13
-
More examples coming soon.
14
-
15
13
```
16
14
examples/
17
15
├── basics/
18
-
│ ├── next-app-router/ # Next.js 15 with App Router
Same functionality as App Router example, using Pages Router patterns.
106
41
107
42
### basics/react-react-router
108
43
109
-
Coming soon.
44
+
React SPA with React Router demonstrating PostHog integration in a client-side app.
110
45
111
46
### basics/react-tanstack-router
112
47
113
-
Coming soon.
48
+
React SPA with TanStack Router demonstrating PostHog integration with file-based routing.
114
49
115
-
##Getting started
50
+
### basics/tanstack-start
116
51
117
-
Each example includes its own README with setup instructions. Generally:
52
+
Full-stack TanStack Start app with PostHog integration.
118
53
119
-
1. Navigate to the example directory
120
-
2. Install dependencies: `pnpm install`
121
-
3. Create `.env.local` with your PostHog credentials
122
-
4. Run the dev server: `pnpm run dev`
54
+
## MCP resources
123
55
124
-
See individual example READMEs for detailed instructions.
56
+
This repository serves as the **single source of truth**for PostHog integration resources accessed via the [PostHog MCP server](https://github.com/PostHog/posthog/tree/master/products/mcp).
125
57
126
-
##MCP manifest architecture
58
+
### Build outputs
127
59
128
-
This repository serves as the **single source of truth** for PostHog integration resources accessed via the [PostHog MCP server](https://github.com/PostHog/posthog/tree/main/products/mcp).
60
+
Run `npm run build:docs` to generate:
129
61
130
-
### How it works
131
-
132
-
1.**Build process** (`npm run build:docs`):
133
-
- Converts example projects to markdown
134
-
- Discovers workflow guides from `llm-prompts/`
135
-
- Discovers MCP prompts from `mcp-commands/`
136
-
- Generates `manifest.json` with all URIs and metadata
137
-
- Packages everything into `examples-mcp-resources.zip`
138
-
139
-
2.**MCP server** (runtime):
140
-
- Fetches the ZIP from GitHub releases
141
-
- Loads `manifest.json`
142
-
-**Purely reflects** the manifest - no hardcoded URIs or logic
62
+
| Output | Description |
63
+
|--------|-------------|
64
+
|`dist/*.md`| Example projects converted to markdown |
65
+
|`dist/manifest.json`| Resource URIs and metadata |
66
+
|`dist/examples-mcp-resources.zip`| Complete archive for MCP server |
143
67
144
68
### Manifest structure
145
69
146
70
The manifest defines:
147
71
-**Workflows**: Step-by-step guides with automatic next-step linking
148
-
-**Docs**: PostHog documentation URLs
72
+
-**Docs**: PostHog documentation URLs (fetched at runtime)
149
73
-**Prompts**: MCP command prompts with template variable substitution
150
74
-**Templates**: Resource templates for parameterized access (e.g., `posthog://examples/{framework}`)
151
75
@@ -159,12 +83,11 @@ The manifest defines:
159
83
160
84
The build script automatically discovers, orders, and generates URIs for all resources.
161
85
162
-
### Why this architecture?
86
+
### Architecture
163
87
164
-
-**Single source of truth**: All URIs defined in examples repo
165
-
-**Zero hardcoding**: MCP server has no URIs or business logic
88
+
-**Single source of truth**: All URIs defined in this repo
89
+
-**Zero hardcoding**: MCP server purely reflects the manifest for `resources` and `prompts` (as defined in the MCP [spec](https://modelcontextprotocol.io/specification/2025-11-25#features))
166
90
-**Easy to extend**: Add resources by creating properly named files
167
91
-**Version controlled**: Resources evolve with the examples
168
92
169
93
See `llm-prompts/README.md` for detailed workflow conventions.
Copy file name to clipboardExpand all lines: llm-prompts/basic-integration/1.0-begin.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,11 @@ description: Start the event tracking setup process by analyzing the project and
5
5
6
6
We're making an event tracking plan for this project.
7
7
8
-
From the project's file list, select between 10 and 15 files that might have interesting business value for event tracking, especially conversion and churn events. Also look for additional files related login that could be used for identifying users, along with error handling. Read the files.
8
+
Before proceeding, find any existing `posthog.capture()` code. Make note of event name formatting.
9
9
10
-
Create a new file with a JSON array at the root of the project: .posthog-events.json. It should include one object for each event we want to add: event name, event description, and the file path we want to place the event in.
10
+
From the project's file list, select between 10 and 15 files that might have interesting business value for event tracking, especially conversion and churn events. Also look for additional files related login that could be used for identifying users, along with error handling. Read the files. If a file is already well-covered by PostHog events, replace it with another option.
11
+
12
+
Create a new file with a JSON array at the root of the project: .posthog-events.json. It should include one object for each event we want to add: event name, event description, and the file path we want to place the event in. If events already exist, don't duplicate them; supplement them.
11
13
12
14
Track actions only, not pageviews. These can be captured automatically. Exceptions can be made for "viewed"-type events that correspond to the top of a conversion funnel.
0 commit comments