07MCP

Fix errors with an agent

A coding agent can take an error from SnowAnalytics to a fix that production has confirmed. No AI runs on SnowAnalytics' servers: the agent is yours, working in your repository.

The loop

Read the error

The agent calls get_errors, then again with the issue_id it picks. It gets the stack with the code around the failing line, breadcrumbs, what the typical visitor did, linked feedback and up to three recordings near the errors.

Fix it

It finds the cause in your repository, reproduces it, fixes it and runs your checks. It ships the fix the way your repository does, with a commit, a pull request or a deploy.

Mark it fixed

It calls run_update with the issues.update action and markFixed, giving the release that carries the fix or the time it was deployed (deployedAt), and a link to the pull request or commit. From a terminal or CI that's snowanalytics fixed <issue> --release <sha> --link <url>.

Production checks it

SnowAnalytics checks again every 15 minutes. The agent can also call verify_fix to see where it stands, or leave and come back.

How verification decides

Right after a fix is marked, SnowAnalytics learns the error's old rate: how many sessions it hit per visit in the 14 days before the fix shipped. It then counts the visits since and works out how many sessions the error should have hit at the old rate.

ResultMeaning
verifyingNot enough visits yet to tell. verify_fix says how many more are needed.
verifiedNo session hit the error, and at least 3 were expected. The issue shows as confirmed.
failedThe error happened again on the fix release or a newer one. The issue is flagged so it can be reopened.
unverified14 days passed without enough traffic to tell either way.

With releases tagged, only sessions on the fix release or newer count, so visitors with an old cached page don't fail a good fix. Server errors compare requests per hour instead. A short grace period after the deploy keeps the old version still serving from counting against the fix.

Tag your releases and the check is precise. See Source maps for how releases are reported.

Replies stay drafts

Marking an issue fixed or a feedback note done normally emails the visitor who wrote in. When an agent does it, nothing is sent. The message is saved as a draft for a person to read and send from the dashboard.

Fix tickets automatically with GitHub Actions

Alerts can open a GitHub issue for each new error, carrying the fix prompt. This workflow runs an agent on every such issue labelled snowanalytics and opens a pull request.

Make an agent key

Create a key with Make changes for you on in Account → Connected apps and save it as the repository secret SNOWANALYTICS_AGENT_KEY. Add your coding agent's own key as a secret too, here ANTHROPIC_API_KEY.

Send error alerts to GitHub

Connect GitHub, then add GitHub issues as a destination in your site's alerts. Its issues carry the label snowanalytics.

Add the workflow

.github/workflows/fix-errors.yml
name: Fix SnowAnalytics errors
on:
  issues:
    types: [opened, labeled]

permissions:
  contents: write
  pull-requests: write
  issues: write

jobs:
  fix:
    if: contains(github.event.issue.labels.*.name, 'snowanalytics')
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          claude_args: >-
            --mcp-config '{"mcpServers":{"snowanalytics":{"type":"http","url":"https://mcp.snowanalytics.app/mcp","headers":{"Authorization":"Bearer ${{ secrets.SNOWANALYTICS_AGENT_KEY }}"}}}}'
          prompt: |
            Fix the SnowAnalytics error described in issue #${{ github.event.issue.number }}.
            Follow the fix_issue steps: read it with get_errors, reproduce, fix the cause,
            and open a pull request. Do not mark it fixed until the pull request is merged.

The issue text came from your own alert, but the error messages inside it came from visitors' browsers. The agent treats them as data. See Security.

Mark the issue fixed once the pull request merges and deploys, so the check starts from the real deploy time. The CLI's deploy recipe does it with the same key: the agent ends its fix commit with a Fixes-SnowAnalytics: <issue> line, and the job after your deploy runs snowanalytics fixed for each.

On this page