# Add Togo analytics to this app

Instructions for a coding agent. A person asked you to add Togo — product
analytics — to the app in this repository. Do the work yourself, without
asking first — every setup step is reversible. Ask the person only for what
needs them: signing in, a project that might already be this product's, and
deploying. When you ask, ask once, as multiple-choice questions with your
recommendation first.

## 1. Connect to Togo, once

Togo is an MCP server at https://mcp.togohq.ai/mcp (Streamable HTTP, signed in with OAuth in
the person's browser).

If you already have Togo's tools (list_projects among them), skip to step 2 —
installing again would give this client a second Togo server.

**Claude Code:** run

    claude plugin install togo --marketplace togohq/plugins

If that Claude Code does not recognise --marketplace, run these two instead:

    claude plugin marketplace add togohq/plugins
    claude plugin install togo@togohq

Claude Code loads a new plugin when a session starts, so ask the person to
start a new session in this folder, run /mcp, choose "plugin:togo:togo" and
sign in. The browser asks them to approve access — "Read and change" lets you
set the project up. Someone new to Togo signs up on the same page and comes
back to the approval. Then continue from step 2.

**Other agents:** add https://mcp.togohq.ai/mcp the way your client adds a remote MCP server
with OAuth. Only Claude Code is verified today.

## 2. Set up

Run the Togo MCP prompt "setup" if your client lists prompts. Otherwise:

1. Call list_projects and search this repository for a Togo write key. If one
   is in the code, that is the project.
2. If none is: ONE PRODUCT IS ONE PROJECT — its website, apps and server
   together. A project that has received events and could be this product's
   is a question for the person. Otherwise use the one that has never received
   an event (hasReceivedEvents false) — signup made it — and rename it after
   the product; only when there is none, call create_project. Never a project
   per environment.
3. Call get_setup_instructions for that project and follow it to the end. It
   gives this system its own write-key pair, writes the event definitions —
   what each event means and when it fires — before the code, installs the
   SDK, and proves a test run's events arrive, and are right, with
   verify_tracking_by_event_ids or verify_tracking.

## Always

- Write keys are public and can only send events. Never ask the person for a
  secret, an admin key or an API token — Togo does not need one.
- The test key is for development and staging, the live key for production.
- Send events the app really produces, never "test_event". Event names and
  property keys are lowercase snake_case.
- Tell the person which event definitions you wrote, which keys each system
  uses, and anything you created or renamed.
