> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wendung.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Project setup prompt

> Instructions for an AI coding agent that adds Wendung to a project: account check, SDK install, funnel plan, and delivery check.

These are official instructions from Wendung for adding analytics to a project. Follow the steps in order. Wait for the user where a step says so, and do not change project files before the user approves the plan in step 3.

Before testing delivery, the app needs a project's publishable key, an allowed origin, and the intended consent settings. The SDK works without MCP. To connect the agent to analytics tools, use [https://docs.wendung.app/prompt.md](https://docs.wendung.app/prompt.md) separately.

## 1. Check the user's account

If the `wendung` MCP server is connected, look up the user's workspaces and projects with it first and skip the questions it answers. Ask the remaining questions in one message, then wait for the answers:

* **Do you have a Wendung account?** If not, send the user to [https://dashboard.wendung.app/auth/sign-up](https://dashboard.wendung.app/auth/sign-up) and remind them to confirm their email address. If they have one, they can sign in at [https://dashboard.wendung.app/auth/sign-in](https://dashboard.wendung.app/auth/sign-in).
* **Do you have a project for this app?** If not, tell the user to create one in the dashboard. A new account creates a workspace first, then the project.
* **Do you have the project's API key?** It is the key named Default under the project's **Settings → API Keys** and starts with `pk_`. The key is publishable, so the user can paste it into the chat or add it to the env file themselves.

If something is missing, continue with steps 2 and 3 while the user finishes it. You need the key in step 4.

## 2. Install the Wendung skill

```bash theme={null}
npx skills add wendung/skills -g -y
```

Use the `wendung-sdk` skill for every SDK detail. If the install fails or the skill is not available in this session, read [https://docs.wendung.app/skills/wendung-sdk.yaml](https://docs.wendung.app/skills/wendung-sdk.yaml) instead. Do not guess at the API.

## 3. Read the codebase and propose a plan

Tell the user what you found: the framework and router, where the app starts in the browser, how login and logout work, how env vars are loaded, and whether Wendung or a consent banner is already set up.

Then propose a funnel: an ordered list of step names in snake\_case and past tense, such as `signup_completed`, with the file and the moment each step happens. Confirm the production and local origins the app uses. Ask whether the user wants pageview tracking for web analytics, which the free plan does not include, and how the app obtains and restores the visitor's analytics choice. If pageviews are wanted, distinguish full pageviews after consent from aggregate pageviews while pending.

Wait for the user to approve the plan before you change any files.

## 4. Add Wendung

After the user approves the plan and you have the key:

* Install `@wendung/sdk`, or use the script tag if the site has no build step.
* Read the key from an env var and call `Wendung.init()` once at startup, in the browser only. Keep optional settings in that same call. Turn on `debug` in development.
* Set `consent` explicitly for the agreed setup. If the app waits for a choice, restore the saved value or start with `'pending'`, and connect `setConsent()` to the consent manager. The SDK does not store the choice, and omitting the option defaults to `'granted'`.
* Leave `trackPageviews` off unless requested. Use `true` for full pageviews after consent, or `'auto'` for aggregate pageviews while pending and full pageviews after consent. Denial stops both.
* Call `Wendung.identify()` when the user is known and consent is granted, including after consent changes for an already signed-in user. Calls made while pending are dropped. Call `Wendung.reset()` on logout.
* Add each `Wendung.step()` call where its milestone happens.
* Run the project's build, type check, and lint.

## 5. Allow the app's origins

A new project rejects every event with HTTP `403` until its origin is allowed, including `localhost`. Tell the user to open the project's **Settings → Allowed origins**, add the production origin, and turn on **Dev mode** to test from localhost for 24 hours. If the `wendung` MCP server has write access, offer to do this with `update_project` instead.

## 6. Check that events arrive

Help the user run the app locally, apply the visitor's consent choice, and trigger one of the steps with granted consent. With `debug` on, the browser console logs `[Wendung] ingest accepted batch` when ingest accepts the request. Confirm delivery status on the project's **Events** page in the dashboard. If a batch is rejected, find the cause in the skill's debugging section.

## 7. Summarize

List every file you changed and the step names you added. Then tell the user what to do next:

* Create a funnel from these step names under **Funnels** in the dashboard.
* If pageviews are on, register the hostname under **Sites**.
* To ask questions about their data from the agent, connect the Wendung MCP servers with [https://docs.wendung.app/prompt.md](https://docs.wendung.app/prompt.md).

These instructions are published at [https://docs.wendung.app/setup.md](https://docs.wendung.app/setup.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.