InfraStudio Agents Start free

Guides

Connect analytics and Sentry

Connect Google Analytics 4, PostHog, Sentry and Microsoft Clarity, and turn on the weekly analytics review and the daily error triage.

Last updated

After this guide, the agents read your numbers and your errors, and suggest what to change.

Who can do it:

  • A key for every product: a workspace admin or owner.
  • A key for one product: a workspace admin or owner, or a person who may change the product's own keys and tools.
  • Turning on the review agents and the product's settings: a workspace admin or owner, or a person who may change everything in that product.

See Roles.

Which agent reads what

  • The Product analytics review runs once a week. It reads Google Analytics 4 or PostHog, and Sentry and Clarity add to it. It writes a ranked report, and each of its suggestions waits for your answer. It needs GA4 or PostHog.
  • Error triage runs every morning. It reads new and rising errors in Sentry, finds their cause in the code and suggests fixes. It needs Sentry.

Both start off. Every connection is read-only, and the agents never see its key.

Google Analytics 4

  1. In Google Cloud, make a service account and a JSON key for it.
  2. In Google Analytics, give the service account Viewer access to your GA4 property.
  3. In the app, open Settings → Integrations. In the group Your numbers and errors, press Connect on the row Google Analytics 4.
  4. Paste the JSON key into Service account key, or press Or choose the key file.
  5. Choose the place under Use it for, and press Save and test.

PostHog

  1. In PostHog, open Settings → Personal API keys. Make a key with the "MCP Server" preset, limited to the PostHog project of this product.
  2. In the app, open Settings → Integrations, and press Connect on the row PostHog.
  3. Paste the key into Personal API key, and press Save and test.
  4. Open the product's settings, then Technical settings → Analytics and AI.
  5. Type the number of your PostHog project in PostHog project ID. It is the number in PostHog's address, such as …/project/12345.
  6. Press Save in the bar at the bottom of the window.

The agents read only this PostHog project.

Sentry

  1. In Sentry, make an auth token with these read scopes only: org:read, project:read, event:read.
  2. In the app, open Settings → Integrations, and press Connect on the row Sentry.
  3. Paste the token into Auth token, and press Save and test.

Microsoft Clarity

Clarity's key belongs to one product only.

  1. In Clarity, open Settings → Data export, and make a token.
  2. In the app, open Settings → Integrations, and press Connect on the row Microsoft Clarity.
  3. Paste the token into Data export token, and press Save and test.

Clarity allows 10 requests a day. So the page does not test the key at once. The Collector (Clarity) is the test: it saves yesterday's Clarity numbers on its schedule, for the Product analytics review.

To set up the collector:

  1. Add a file .agents/clarity-queries.txt to the default branch of your repository. See Write your own instructions.
  2. Open the product's settings, then Technical settings → Other scheduled work.
  3. Press Add scheduled work.
  4. Type a Short name, such as clarity. In Kind, choose Collector (Clarity). Type a Name.
  5. In Schedule (cron, the platform's local time), type when it runs. For example, 30 2 * * * runs it every day at 02:30.
  6. Press Add scheduled work under the form.

Turn on the review agents

  1. Open Agents in the side bar.
  2. Turn on Product analytics review, Error triage, or both.

If an agent's key is missing, its row in Product settings says which key it needs, with a link to Integrations.

To get the first suggestions now, open Suggestions and press Look for suggestions now. The review is a large job. It takes 10 to 60 minutes, and your AI provider bills it.

What you see when it worked

  • The integration's row says Connected, and Working after its test.
  • The agent's switch says On, and Next start says when it starts.
  • After the review, its report is under Documents, and its suggestions are under Suggestions.

Read the first suggestion and its evidence before you say yes to it.

More