|

Netlify

A Netlify Extension that deploys an Edge Function to detect AI bot traffic and report content_retrieved events. Install from the Netlify Extensions directory.

Extensions directory Edge function source_role: edge

How it works

flow
AI Bot ──GET──> Netlify Edge (Deno runtime)
                    │
                    ├── Edge Function intercepts request
                    ├── Classifies via managed bot detection
                    ├── Passes to origin (no delay)
                    └── fetch() POST to OA telemetry endpoint

Netlify Edge Functions run on Deno and support outbound fetch() calls. The extension installs an Edge Function that sits in front of all routes, detects AI bot traffic, and fires telemetry events without blocking the response.

Built-in precedent
Netlify's own User Agent Blocker extension follows the same pattern - an Edge Function that detects AI crawlers. The OA extension reports events instead of blocking. Both use Netlify's managed bot detection rather than hardcoded lists.

Setup

  1. Find OpenAttribution in the Netlify Extensions directory
  2. Click Install
  3. Enter your OA org ID
  4. The extension deploys an Edge Function automatically

Manual setup

If you prefer to add the Edge Function directly to your project. The extension ships with a managed bot detection module that updates with the extension - no hardcoded list in your code:

netlify/edge-functions/oa-telemetry.ts
import type { Context } from "@netlify/edge-functions";
import { isAiBot } from "@openattribution/netlify-edge";

export default async (request: Request, context: Context) => {
  // Pass to origin immediately
  const response = await context.next();

  const ua = request.headers.get('user-agent') || '';

  if (isAiBot(ua)) {
    const event = {
      type: 'content_retrieved',
      timestamp: new Date().toISOString(),
      content_url: request.url,
      source_role: 'edge',
      oa_telemetry_id: request.headers.get('OA-Telemetry-ID') || undefined,
      data: { user_agent: ua },
    };

    // Fire and forget
    context.waitUntil(
      fetch('https://telemetry.openattribution.dev/v1/events', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          events: [event],
          org_id: Netlify.env.get('OA_ORG_ID'),
        }),
      })
    );
  }

  return response;
};

export const config = { path: "/*" };
Bot detection updates
The @openattribution/netlify-edge package maintains the AI bot detection list and updates it independently of your deployment. When new AI agents appear, update the package to detect them - no code changes needed.

Publishing path

Netlify Extensions use a three-stage publishing workflow:

StageVisibilityReview
PrivateYour team onlyNone
Public unlistedAnyone with the linkNone
Public listedIn the Extensions directoryNetlify review required