Agent setup: authorize Sight MCP and ask your agent to call get_tracking_setup. It configures this integration automatically.

Flask

Flask extension that forwards AI-crawler page requests to Sight's POST /api/v1/track, preserving the original User-Agent. Crawlers don't run JavaScript, so the browser tracker never fires for them unless they also fetch the script URL. This is the origin-side path.

Humans are not recorded here — they still use the browser tracker. Tracking every request would double-count people.

Part of Sight — see sightapp/sight-backend SPEC.md and tasks/plan.md (Track B4).

Install

pip install sight-flask

Usage

from flask import Flask
from sight_flask import SightCrawler

app = Flask(__name__)
SightCrawler(app, api_key="sk_...")

App-factory pattern:

sight = SightCrawler()

def create_app():
    app = Flask(__name__)
    sight.init_app(app, api_key="sk_...")
    return app

GET requests only; other methods are ignored. The send happens in a background thread — a slow/unreachable Sight backend never adds latency to the real request.

The UA token list matches sight-backend's internal/api/agents.go (GPTBot, ClaudeBot, PerplexityBot, …). Keep them in sync when that list grows.

Verify

curl -s http://localhost:5000/pricing -A "GPTBot/1.0"
curl -s "https://api.usesight.dev/api/v1/query/agent-traffic?days=1" \
  -H "X-API-Key: YOUR_API_KEY"

GPTBot should show up. A request with a Chrome UA should not.

Tests

pip install -e ".[dev]"  # or: pip install flask pytest
pytest

5 tests, all passing against a real Flask test client (no mocked framework internals): agent detection (case-insensitivity, browsers excluded), a GPTBot GET producing exactly one tracked call with the right path/UA, a human GET producing none, and the required-api_key check.

Source repository