Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt

Use this file to discover all available pages before exploring further.

The Amplitude plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see Overview for setup context and the exact URL shape).
New to Corsair? See webhooks and hooks.

Webhook map

  • annotations
    • created (annotations.created)
    • updated (annotations.updated)
  • cohorts
    • computed (cohorts.computed)
  • events
    • identify (events.identify)
    • track (events.track)
  • experiments
    • exposure (experiments.exposure)
  • monitors
    • alert (monitors.alert)

HTTP handler setup

app/api/webhook/route.ts
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}

Events

Annotations

Created

annotations.created A new chart annotation was created Payload
NameTypeRequiredDescription
typeannotation.createdYes
annotation_idnumberYes
datestringYes
labelstringYes
detailsstringNo
app_idnumberNo
sourcestringNo
created_atstringYes
{
  type: annotation.created,
  annotation_id: number,
  date: string,
  label: string,
  details?: string,
  app_id?: number,
  source?: string,
  created_at: string
}
webhookHooks example
amplitude({
    webhookHooks: {
        annotations: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Updated

annotations.updated A chart annotation was updated Payload
NameTypeRequiredDescription
typeannotation.updatedYes
annotation_idnumberYes
datestringYes
labelstringYes
detailsstringNo
app_idnumberNo
sourcestringNo
updated_atstringYes
{
  type: annotation.updated,
  annotation_id: number,
  date: string,
  label: string,
  details?: string,
  app_id?: number,
  source?: string,
  updated_at: string
}
webhookHooks example
amplitude({
    webhookHooks: {
        annotations: {
            updated: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Cohorts

Computed

cohorts.computed A cohort finished computing Payload
NameTypeRequiredDescription
typecohort.computedYes
cohort_idstringYes
cohort_namestringYes
app_idnumberNo
sizenumberYes
computed_atstringYes
publishedbooleanNo
{
  type: cohort.computed,
  cohort_id: string,
  cohort_name: string,
  app_id?: number,
  size: number,
  computed_at: string,
  published?: boolean
}
webhookHooks example
amplitude({
    webhookHooks: {
        cohorts: {
            computed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Events

Identify

events.identify A user identify call was received by Amplitude Payload
NameTypeRequiredDescription
typeevent.identifyYes
user_idstringNo
device_idstringNo
timenumberYes
user_propertiesobjectNo
app_versionstringNo
platformstringNo
insert_idstringNo
{
}
{
  type: event.identify,
  user_id?: string,
  device_id?: string,
  time: number,
  user_properties?: {
  },
  app_version?: string,
  platform?: string,
  insert_id?: string
}
webhookHooks example
amplitude({
    webhookHooks: {
        events: {
            identify: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Track

events.track An event was tracked by Amplitude Payload
NameTypeRequiredDescription
typeevent.trackYes
event_idstringYes
event_typestringYes
user_idstringNo
device_idstringNo
timenumberYes
event_propertiesobjectNo
user_propertiesobjectNo
app_versionstringNo
platformstringNo
session_idnumberNo
insert_idstringNo
{
}
{
}
{
  type: event.track,
  event_id: string,
  event_type: string,
  user_id?: string,
  device_id?: string,
  time: number,
  event_properties?: {
  },
  user_properties?: {
  },
  app_version?: string,
  platform?: string,
  session_id?: number,
  insert_id?: string
}
webhookHooks example
amplitude({
    webhookHooks: {
        events: {
            track: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Experiments

Exposure

experiments.exposure An experiment exposure was tracked for a user Payload
NameTypeRequiredDescription
typeexperiment.exposureYes
flag_keystringYes
variantstringYes
userobjectYes
timenumberYes
experiment_keystringNo
metadataobjectNo
{
  user_id?: string,
  device_id?: string,
  user_properties?: {
  },
  country?: string,
  city?: string,
  region?: string,
  language?: string,
  platform?: string,
  os?: string
}
{
  deployment_name?: string,
  flag_version?: number
}
{
  type: experiment.exposure,
  flag_key: string,
  variant: string,
  user: {
    user_id?: string,
    device_id?: string,
    user_properties?: {
    },
    country?: string,
    city?: string,
    region?: string,
    language?: string,
    platform?: string,
    os?: string
  },
  time: number,
  experiment_key?: string,
  metadata?: {
    deployment_name?: string,
    flag_version?: number
  }
}
webhookHooks example
amplitude({
    webhookHooks: {
        experiments: {
            exposure: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Monitors

Alert

monitors.alert An alert monitor threshold was triggered Payload
NameTypeRequiredDescription
typemonitor.alertYes
monitor_idstringYes
monitor_namestringYes
alert_typestringYes
conditionstringNo
valuenumberNo
thresholdnumberNo
triggered_atstringYes
chart_idstringNo
dashboard_idnumberNo
recipientsstring[]No
{
  type: monitor.alert,
  monitor_id: string,
  monitor_name: string,
  alert_type: string,
  condition?: string,
  value?: number,
  threshold?: number,
  triggered_at: string,
  chart_id?: string,
  dashboard_id?: number,
  recipients?: string[]
}
webhookHooks example
amplitude({
    webhookHooks: {
        monitors: {
            alert: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})