---
name: aiola
description: Connect web applications to Aiola for website analytics, server-side AI crawler tracking, user feedback forms, and application error logs, or query live project data through Aiola's hosted Model Context Protocol (MCP) server.
---

# Aiola Agent Skill

This skill guides AI coding agents in integrating Aiola into web and mobile codebases and interacting with Aiola's hosted data services.

## Product Summary

Aiola is a desktop app for macOS and 64-bit Windows with companion iPhone, iPad and Android apps for building, running, and supporting applications with AI coding agents. It unifies repository chat with live production telemetry:
- **Website Analytics**: Privacy-first, lightweight browser tracking for visitors, sessions, pageviews, custom events, goals, and funnels.
- **AI Crawler Tracking**: Server-side and edge detection for AI bots, web crawlers, and search indexing agents that bypass client JavaScript.
- **User Feedback Forms**: Issue and feature request dialogs routed securely through your server.
- **App Logs**: Exception and error capture for browser, server and edge JavaScript runtimes through `@aiolaapp/logger`, plus a plain HTTP endpoint for any other language, with source map support.
- **Hosted MCP Server**: OAuth-authenticated Model Context Protocol endpoint giving AI clients access to live analytics, logs, and feedback.

## Required Inputs and Secrets

| Input | Where to find it in Aiola | Purpose & Secrecy |
| --- | --- | --- |
| `tracking_id` | Workspace **Settings → Analytics → Tracking** | Public identifier for browser analytics and server crawler tracking. Not secret. |
| `domain` | Workspace **Settings → Analytics → Tracking → Domain** | Production hostname restriction (e.g. `example.com`). Subdomains are permitted. |
| `project_key` | Workspace **Settings → API Key** | Shared project key for Feedback and App Logs. Keep `AIOLA_KEY` server-side for Feedback and server-only logging. Direct browser logging exposes this key; keep it secret by forwarding browser errors through your backend. |

## Setup Workflows

### 1. Website Analytics

Full guide: https://docs.aiola.app/guides/set-up-analytics.md

1. **Prerequisites**: Pro plan or active 7-day trial. Analytics enabled with domain saved in **Settings → Analytics**.
2. **Install Browser Tag**: Add this single script tag inside `<head>` or in the root application layout:

```html
<script defer
  src="https://cdn.aiola.app/analytics.js"
  data-site-id="YOUR_TRACKING_ID"
  data-domain="example.com"></script>
```

- In **Next.js App Router** (`app/layout.tsx`), import `Script from "next/script"` and use `<Script src="https://cdn.aiola.app/analytics.js" data-site-id="YOUR_TRACKING_ID" data-domain="example.com" strategy="afterInteractive" />`.
- Leave `data-host-url` unset. Events post directly to `https://aiola.app/api/collect`.
- Custom events: `window.aiola.track('event_name', { key: 'value' })` or HTML attributes `data-aiola-event="event_name"` `data-aiola-event-plan="pro"`.
- User identification: `window.aiola.identify('user_123', { email: 'user@example.com' })`.

### 2. Server-Side AI Crawler Tracking

Full guide: https://docs.aiola.app/guides/track-ai-crawlers.md

Crawlers that do not execute JavaScript bypass the browser tag. Server-side tracking captures these requests.

1. **Endpoint**: `POST https://aiola.app/api/bot-crawl-ingest` (or `POST https://lhrsgoaselmgophvbqme.supabase.co/functions/v1/bot-crawl-ingest` for Cloudflare Pages Functions).
2. **Marker**: Keep the exact comment `// aiola-bot-tracking v2` in the integration file for Setup Health detection.
3. **Payload**: JSON with `tracking_id`, `url_path`, `url_host`, `ua`, optional `signature_agent`, `country` (in JSON body), and `status` (integer 100-599).
4. **Implementation Patterns**:
   - **Next.js**: Add `middleware.ts` (or `proxy.ts` in Next.js 16+) to intercept requests matching `BOT_RE` or `Signature-Agent: chatgpt.com`, skipping static assets (`ASSET_RE`). In App Router, add status 404 logging in `app/not-found.tsx` using `after()` from `next/server`.
   - **Cloudflare Pages**: Add `functions/_middleware.ts` using `onRequest(context)`, `await context.next()`, and `context.waitUntil()`. Merge into an existing `_middleware.ts` if there is one.
   - **Express / Node.js**: Add middleware before routes using `res.once("finish", ...)` to capture final status codes.

### 3. User Feedback Forms

Full guide: https://docs.aiola.app/guides/set-up-feedback.md

1. **Upstream Endpoint**: `POST https://lhrsgoaselmgophvbqme.supabase.co/functions/v1/submit-feedback`
2. **Authentication**: `Authorization: Bearer <AIOLA_KEY>`
3. **Security Rule**: The Project API Key is secret. Keep `AIOLA_KEY` on your backend server. Do NOT expose it in client-side code or public variables.
4. **Server Route**: Create a backend endpoint (`app/api/report/route.ts` in Next.js, or `/api/report` in Express) that accepts client JSON and forwards it to the upstream endpoint with `Authorization: Bearer ${process.env.AIOLA_KEY}`.
5. **Form Dialogs**:
   - **Issue form**: With unchanged defaults, requires `title`, `email`, `device`, and `description`.
   - **Feature request form**: With unchanged defaults, requires `title` and `description`. For customized forms, send the saved field keys and all saved required values.
   - Send `type: "issue"` or `type: "feature_request"`.

### 4. Application Error Logs (App Logs)

Full guide: https://docs.aiola.app/guides/set-up-app-logs.md
HTTP reference: https://docs.aiola.app/reference/app-logs-http.md

1. **Packages**:
   - JavaScript / TypeScript: `@aiolaapp/logger@0.5.5`
   - Python: Aiola has not published a Python package, so do not run `pip install aiola`. Send errors over HTTP: https://docs.aiola.app/reference/app-logs-http.md
2. **Environment Variables**:
   - Next.js: `NEXT_PUBLIC_AIOLA_KEY=your_key` in `.env.local`
   - Vite: `VITE_AIOLA_KEY=your_key` in `.env.local`
   - Node.js / Server / Python: `AIOLA_KEY=your_key`
3. **Initialization**:
   - Next.js (15.3+): `instrumentation-client.ts` for browser capture, `instrumentation.ts` for server capture:
     ```ts
     import { Aiola } from '@aiolaapp/logger'
     Aiola.init({ apiKey: process.env.NEXT_PUBLIC_AIOLA_KEY!, environment: 'production', release: '1.4.2' })
     ```
4. **Handler Wrapping**: Wrap server handlers with `Aiola.wrapRouteHandler`, `Aiola.wrapServerAction`, or `Aiola.wrapDenoServe`, and await `Aiola.flushAsync()` before short-lived serverless invocations terminate.
5. **Source Maps**: Enable source-map generation before building. For Next.js, merge `productionBrowserSourceMaps: true` into your existing Next configuration. For Vite, merge `build: { sourcemap: true }` into its configuration and upload from `dist`. Keep the uploaded release identical to `Aiola.init`.

   ```bash
   export AIOLA_KEY='your_api_key'
   npm run build
   npx --package=@aiolaapp/logger@0.5.5 aiola-logger upload-sourcemaps --dir=.next/static --release=1.4.2
   ```

### 5. Revenue and Search Integrations

Full guide: https://docs.aiola.app/guides/connect-integrations.md

1. **Stripe**: Connect a restricted key (`rk_live_` or `rk_test_`) with Read on Charges, Refunds, Checkout Sessions, Customers, Payment Intents, Subscriptions, and Write on Webhook endpoints.
2. **Attribution**: At Checkout Session creation on your server, read browser cookies `aiola_visitor_id` and `aiola_session_id` and copy them into `metadata.aiola_visitor_id` and `metadata.aiola_session_id`.
3. **Google & Bing**: Connect accounts in **Settings → Integrations** and map search properties under **Settings → Analytics → Search Keywords**.

### 6. Hosted MCP Client Setup

Full guides: https://docs.aiola.app/guides/mcp-connector.md and https://docs.aiola.app/core-features/hosted-mcp.md

- **Endpoint**: `https://aiola.app/api/mcp`
- **Transport**: Streamable HTTP with OAuth 2.1 authentication
- **Tools (11)**:
  - `list_projects`: Discover available projects and flags (`hasAnalytics`, `hasLogs`, `hasFeedback`).
  - `get_analytics_overview`: High-level metrics for period (`7d`, `30d`, etc.).
  - `get_analytics`: Run named query pipes (e.g. `analytics_summary`, `analytics_timeseries`, `bot_crawls_summary`).
  - `get_analytics_definitions`: Inspect saved funnels and conversion calculations.
  - `get_search_keywords`: Query Google and Bing search terms and positions.
  - `get_indexing_issues`: Check indexing and crawl errors.
  - `get_app_logs`: List grouped errors and warnings.
  - `get_app_log_events`: Read event instances and stack traces for a `group_hash`.
  - `update_app_log_status`: Set status (`open`, `in_progress`, `human_review`, `closed`, `ignored`).
  - `get_feedback`: Retrieve issue and feature request submissions.
  - `update_feedback`: Update feedback status.

## Plan Constraints and Limits

- **Plan Requirement**: Hosted Analytics, AI crawler tracking, Feedback, App Logs, and hosted MCP require Pro or an active 7-day trial. GUI Lifetime is limited to local desktop tools, local workspaces, and workspace MCP servers.
- **Analytics Quotas**: Pro includes shared account-wide monthly event allowances (100k, 500k, 1M, 5M events). AI crawler requests do not consume this allowance.
- **Rate Limits**:
  - Ingestion: Analytics collector has IP and site backstops. Feedback and App Logs enforce per-minute rate limits; App Logs defaults to 600 requests per minute per project. See https://docs.aiola.app/reference/api.md.
  - Hosted MCP: 120 weighted units per minute, 2,000 units per day per user.
- **Retention**: Analytics events and AI crawler visits are retained for 60 months (5 years). App Logs events are retained for 12 months.

## Verification Checklist

1. **Setup Health**: Open Aiola Desktop **Home** or expand the **Needs attention** sidebar card. In **Settings → Analytics** and **Settings → App Logs**, click **Check now** under **Installation check**. Warning banners also offer **Check again**. Confirm eligible checks report **All checks passed**; a skipped check does not verify installation or deployed delivery.
2. **Analytics**: Visit the deployed site and confirm pageviews in **Analytics → Traffic**.
3. **AI Crawlers**: After deploying crawler tracking, replace `https://example.com/` with the project’s deployed URL and run `curl -A 'GPTBot' https://example.com/`. Open **Analytics → AI** for the matching project and check for the test hit.
4. **Feedback**: Send a test issue form submission and verify it appears in **Feedback**.
5. **App Logs**: Trigger a test exception (`Aiola.captureException(new Error('test'))`) and verify it appears in **App Logs**.

## Documentation and Agent Resources

- **Index**: `https://docs.aiola.app/llms.txt`
- **Full Bundle**: `https://docs.aiola.app/llms-full.txt`
- **Docs MCP Server**: `https://docs.aiola.app/mcp`
- **Per-page Markdown**: Add `.md` to any guide URL (e.g., `https://docs.aiola.app/guides/set-up-analytics.md`)
