Beacons are counters for things that matter — a signup, a purchase, an error — recorded from your own code. Nothing is loaded in the browser and no third party is involved.

import { sendBeacon } from "apiker"; await sendBeacon("signup_completed"); await sendBeacon("purchase_completed", { plan: "pro", amount: 99 });

Names and properties

Event names are normalised — lowercased, with anything that is not a letter or number turned into an underscore, and truncated to 48 characters — so "Purchase Completed!" and "purchase_completed" are one event. You can attach up to eight properties, each up to 120 characters.

What gets stored

  • A count per event per hour, which is what the graphs are drawn from.
  • A count per event per country per day.
  • A rotating buffer of recent events, kept for drill-down, where new samples overwrite the oldest.

Writes are spread across eight instances so a busy event cannot serialise behind a single one.

Reading the report

1import { getBeaconReport, areBeaconsAvailable } from "apiker";
2
3if (areBeaconsAvailable()) {
4 const report = await getBeaconReport(7);
5 // report.totals — busiest events first, each with daily and per-country counts
6 // report.samples — the most recent individual events
7}

The admin panel renders exactly this report, so anything you record shows up there without extra work.

Add Beacons to objects to switch this on. Without it sendBeacon returns false and records nothing, so calls are safe to leave in place.