Skip to content
Primetra

Install

Install the collector.

About five minutes. The collector runs on your stack, forwards bot, agent and AI-referral traffic only, and fails open: if we're down, your site isn't.

The collectors ship with our first design partners. The snippets show the shape of the install; exact names may change before release.

Install in three steps

  1. 01

    Set your keys

    Your workspace shows an ingest key once, when you create it. Keep it in your secrets manager. We recommend setting the hash secret too. Generate it yourself with openssl rand -hex 32; we never see it. It is also what lets us tell real AI crawlers from fakes on your site. Without it we group callers less precisely and cannot check crawlers that claim to be a well-known AI bot. We never see a visitor's address or can derive one from the hash; the only full IPs we receive belong to crawlers claiming to be a known AI bot, so we can check them.

    .env
    PRIMETRA_INGEST_URL=https://ingest.primetra.ai/v1/eventsPRIMETRA_INGEST_KEY=<your-ingest-key>IP_HASH_SECRET=<output of: openssl rand -hex 32>
  2. 02

    Add a collector

    Pick the one closest to your traffic. Full steps and a diagram for each are further down.

    bash
    npm install @primetra/collector-cloudflare
    src/index.ts
    export { default } from "@primetra/collector-cloudflare";
    All steps for Cloudflare Worker
  3. 03

    See the first event

    Within a few minutes of the first bot visit, your workspace shows the collector as healthy. If it goes quiet later, we tell you.

    Install checkWhat you'll see

Cloudflare Worker

@primetra/collector-cloudflareAbout 5 minutes

Any site behind Cloudflare.

How Cloudflare Worker fits in
Sent to Primetra
  • Bots, agents, AI referrals, and non-browser API and MCP calls
  • Method, path without the query string, status, size and latency
  • A truncated, hashed IP prefix
Never leaves your stack
  • Ordinary visitors browsing your site
  • Query strings, cookies and auth headers
  • Request and response bodies
  • Full IPs, except for a claimed vendor bot
  1. 01Add the package to a new Worker

    bash
    npm install @primetra/collector-cloudflare
  2. 02Export the collector

    It passes every request to your origin unchanged and does its work after the response is on its way.

    src/index.ts
    export { default } from "@primetra/collector-cloudflare";
  3. 03Route it in front of your site

    wrangler.toml
    name = "primetra-collector"main = "src/index.ts"compatibility_date = "2026-10-01"routes = [{ pattern = "yourdomain.com/*", zone_name = "yourdomain.com" }][vars]PRIMETRA_INGEST_URL = "https://ingest.primetra.ai/v1/events"
  4. 04Add the secrets and deploy

    bash
    npx wrangler secret put PRIMETRA_INGEST_KEYnpx wrangler secret put IP_HASH_SECRETnpx wrangler deploy
  • Runs inside ctx.waitUntil, so it adds no latency to your responses.
  • Any error inside the collector is swallowed. Your site never notices.

Next.js middleware

@primetra/collector-nextAbout 5 minutes

Next.js apps on Vercel or anywhere else.

How Next.js middleware fits in
Sent to Primetra
  • Bots, agents, AI referrals, and non-browser API and MCP calls
  • Method, path without the query string, status, size and latency
  • A truncated, hashed IP prefix
Never leaves your stack
  • Ordinary visitors browsing your site
  • Query strings, cookies and auth headers
  • Request and response bodies
  • Full IPs, except for a claimed vendor bot
  1. 01Install the package

    bash
    npm install @primetra/collector-next
  2. 02Add it to your proxy

    Next.js 16 calls this file proxy.ts. On older versions it's middleware.ts.

    proxy.ts · illustrative
    import { primetraMiddleware } from "@primetra/collector-next";// Already have a proxy? Wrap it instead: export default withPrimetra(yourProxy);export default primetraMiddleware();export const config = {  matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],};
  3. 03Set the environment variables

    Add the three variables from “Set your keys” to your hosting provider, then redeploy.

  • Sends in the background, after your response is on its way.
  • Vercel log drains don't include request headers. Use the middleware, not a drain, if you want bot verification.

MCP SDK

@primetra/mcpAbout 5 minutes

Your own MCP server. Needed for “got data” and “came back”.

How MCP SDK fits in
Sent to Primetra
  • Method, tool, client and duration
  • Outcome: data, empty, error or rejected
  • A truncated, hashed IP prefix
Never leaves your stack
  • Tool arguments (redacted capture is opt-in and stays on your server)
  • Tool results
  • Full IPs
  1. 01Install the package

    bash
    npm install @primetra/mcp
  2. 02Instrument your server

    One call after you register your tools. It never changes your tool schemas.

    server.ts · illustrative
    import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { instrument } from "@primetra/mcp";const server = new McpServer({ name: "your-server", version: "1.0.0" });// ...register your tools...instrument(server, {  ingestKey: process.env.PRIMETRA_INGEST_KEY!,  endpoint: process.env.PRIMETRA_INGEST_URL,  ipHashSecret: process.env.IP_HASH_SECRET,});
  • Tool arguments are never sent by default. Redacted capture is opt-in and, today, local only: it labels probe calls on your server and sends the label, not the values.
  • It records method, tool, client, duration and outcome (data, empty, error, rejected).

What leaves your stack

Sent to us
  • Requests from bots and agents
  • Visits that arrive from an AI assistant's answer (AI referrals): its referrer, or a utm_source the assistant documents (only the assistant's name is sent, never the query, and then not the referrer). With AI_REFERRAL_MODE=count_only, only an hourly count per assistant and page
  • Calls to your API and MCP paths from anything that isn't a browser, which can include your own scripts and apps
  • Time, method, path without the query string, status, size and latency
  • User agent and bot signature headers
  • Country (edge collectors) and, on Cloudflare, the network (ASN), from your platform's own lookup; sent with or without the hash secret
  • A truncated IP prefix, hashed under a secret only you hold. Without it, no IP prefix or hash is sent
  • Referrer host, and MCP method, tool, client and outcome
  • Which collector sent it, and whether the request was a signup
Never sent
  • Ordinary visitors browsing your site
  • Query strings, cookies and auth headers
  • Request and response bodies
  • MCP tool arguments (redacted capture is opt-in and stays on your server)

One exception: when a user agent claims to be a known vendor bot that publishes its addresses (GPTBot, Googlebot, ClaudeBot), the collector sends the full IP so we can check it against the vendor's published ranges. Our queue holds it only until that check; it is never stored.