Embeds, badges, and capture snippets
Embeds, badges, and capture snippets make selected status information available outside the main public status page. They provide small monitor views, current event views, image URLs, and analytics hooks that external sites can consume without access to the management area. This page is a child of Status publishing and relates to Public status pages, Monitoring history, and Incidents and maintenance events.
External status views
External status views are focused public surfaces for a monitor or for current operational events. They use the same service data and event records as the full status page, but they omit the main navigation and page frame so another site can display the result in a smaller area.
The views are served through a separate embed layout. The layout applies site colors, fonts, language data, and the selected light or dark theme, while the view itself requests the status data that it needs.
flowchart LR
A[External site] --> B{Published view}
B -->|monitor tag| C[Status bar or latency chart]
B -->|event filters| D[Live incidents and maintenance]
C --> E[Monitor data]
D --> F[Current event records]
Monitor status embeds
The monitor status embed is a compact status bar for one monitor. It shows the monitor's uptime percentage, average latency when available, and daily status indicators across the selected history window. The view accepts a light or dark theme and limits the history window to 90 days. src/…/+page.server.ts• L3-16 and src/…/+page.svelte• L29-85
The embed fetches its monitor summary after it loads. A missing or invalid monitor produces a small load error instead of the full status page. This makes the view suitable for a fixed space in a dashboard or product page, but it does not turn the embed into a push-based status feed.
References: src/…/+page.server.ts• L6-16 src/…/+page.svelte• L34-59 src/…/get.ts• L31-53
Latency embeds
The latency embed adds a time-series chart to the monitor summary. It shows uptime and one latency measure over a chosen history window, with average as the default and maximum or minimum as alternatives. The chart height can be set by the caller, with a minimum of 50 pixels, and the history window remains capped at 90 days. src/…/+page.server.ts• L4-23 and src/…/+page.svelte• L30-99
The chart and its summary use the same monitor-bar data as the status embed. Changing the metric changes which value is selected from that data; it does not create a separate monitor check or alter stored monitoring history.
References: src/…/+page.server.ts• L8-23 src/…/+page.svelte• L31-53 src/…/get.ts• L17-28
Live event embeds
The live event embed presents ongoing incidents and maintenance events without the rest of a status page. It can show either event class or both, and it can limit the result to a comma-separated set of monitor tags. When no event filters are supplied, it shows both incidents and maintenance events. src/…/+page.server.ts• L6-35
The view reads the current event set when the page request runs. It shows incident summaries without comments and shows maintenance entries with their event details. An empty result is a valid state and produces a clear no-events message. src/…/+page.svelte• L15-52
References: src/…/+page.server.ts• L7-35 src/…/+page.svelte• L26-52 src/…/IncidentItem.svelte• L1-80 src/…/MaintenanceItem.svelte• L1-80
Embed publication
Embed publication turns a selected view into a URL or a code fragment that an operator can place on another website. The main choices are an iframe, which is the direct view, and a script tag, which creates and manages an iframe for the host page.
Embed generator
The management embed generator lets an operator select an active monitor view or the live event view, choose a theme, and copy a complete URL and HTML snippet. Status and latency views also accept a history window; latency views accept chart height and metric; event views accept incident, maintenance, and monitor-tag filters. The page requires access to settings and starts with an iframe status view. src/…/+page.svelte• L24-143 and src/…/EGM.md• L5-19
The generator previews the selected URL in an iframe before it is copied. Its output is a presentation contract: the query values become part of the external link, so a change to a monitor tag or a view's supported parameters can affect every published placement that uses the generated code.
References: src/…/+page.svelte• L59-143 src/…/+page.svelte• L441-497 src/…/EGM.md• L7-25
Generated script behavior
The monitor script endpoint returns JavaScript that finds its own script tag, creates a sandboxed iframe, and inserts the monitor view beside that tag. The iframe starts with no useful size and listens for messages from the view so it can adjust its height and width to the rendered content. src/…/+server.ts• L3-73
This script form is useful when the host page needs a dynamically sized widget. Direct iframe output is the simpler boundary because it does not depend on script discovery or iframe resize messages. The generator can offer script output for latency and live event views, but only the monitor view has a matching /js endpoint. Those other script snippets point to an unavailable resource and do not produce a working widget. src/…/EGM.md• L9-12
References: src/…/+server.ts• L11-65 src/…/code.txt• L23-63 src/…/+page.svelte• L110-143 src/…/EGM.md• L9-12
Badge resources
Badges are image resources for places that can display an image but cannot host a full status view. They are generated from current monitor status or calculated monitoring history, so a badge request returns a fresh SVG rather than a saved image file.
Status and live-dot badges
The status badge reports the latest state for one active, visible monitor. It can also represent the combined state of all active monitors by using the all-monitors tag. The message is localized when the requested locale is enabled, and the badge uses the configured status color unless the caller supplies a color. src/…/+server.ts• L4-13 and src/…/monitorsController.ts• L543-612
The live-dot badge is a smaller SVG signal for the latest state. It supports a plain dot and an optional ping animation. It follows the same single-monitor or all-monitor status choice, but it exposes a fill color and animation option rather than a text label. src/…/+server.ts• L9-63
References: src/…/+server.ts• L4-13 src/…/+server.ts• L9-37 src/…/monitorsController.ts• L547-612
Uptime and latency badges
The uptime badge reports the calculated uptime for a time range. The latency badge reports average, maximum, or minimum latency for the same kind of range. Both default to 90 days, accept a sinceLast range in seconds, and can hide the duration from the label. src/…/+server.ts• L4-14, src/…/+server.ts• L4-15, and src/…/monitorsController.ts• L614-679
These badges can represent one active visible monitor or all active visible monitors. For one monitor, the uptime result can use that monitor's configured uptime formula. This keeps the badge value aligned with the monitor's normal uptime view rather than treating the image as an unrelated metric.
References: src/…/+server.ts• L4-14 src/…/+server.ts• L4-15 src/…/monitorsController.ts• L637-664
Badge presentation
Badge presentation is controlled by query values for the label, label color, value color, and style. Supported styles are flat, plastic, flat-square, for-the-badge, and social; the default is flat. Status badges can also select an enabled language, while uptime and latency badges can show or hide their time range. src/…/global-constants.ts• L3-5 and src/…/monitorsController.ts• L681-700
The management badge generator builds the badge URL and ready-to-use Markdown and HTML forms. It includes the all-monitors choice and previews the image, so operators can confirm the label and value before publishing the link. src/…/+page.svelte• L52-105 and src/…/+page.svelte• L371-419
References: src/…/global-constants.ts• L3-5 src/…/global-constants.ts• L28-34 src/…/+page.svelte• L52-105 src/…/+page.svelte• L321-367
Analytics capture
Analytics capture connects public status-page activity to external analytics services. It is separate from the visual embed and badge responses: the normal public status layout adds a capture script, while the isolated embed layout does not add that script by default.
Public capture script
The public layout loads /capture.js as a JavaScript resource. That endpoint reads the enabled analytics settings, fills the matching provider templates, and returns one combined script. It escapes saved values before inserting them into the script, so a quote or line break in one setting does not make the whole response invalid. If no provider is enabled, it returns a valid JavaScript response with no tracking code. src/…/+layout.svelte• L27-58 and src/…/+server.ts• L14-40
This design lets several providers run at the same time. Provider credentials and endpoint choices are stored as site data, but the endpoint emits only the generated browser script needed by the public page. The management screen controls each provider independently and marks enabled providers as active. It includes OpenPanel with a client ID, API URL, and script URL. src/…/+page.svelte• L24-31 and src/…/+page.svelte• L208-237
References: src/…/+layout.svelte• L27-58 src/…/+server.ts• L14-40 src/…/+page.svelte• L208-237 src/…/+page.svelte• L240-320
Provider adapters and event signals
The capture layer supports Google Analytics, Plausible, Mixpanel, Amplitude, Microsoft Clarity, Umami, PostHog, and OpenPanel. Each provider has its own required identity fields and endpoint settings, while the public page uses one common event signal for interaction tracking. OpenPanel receives the same event name and data through its browser client after its script loads. src/…/+page.svelte• L39-237 and src/…/+server.ts• L100-110
The common signal is a browser analyticsEvent event. Kener prefixes the event name with kener_ and sends the event data through each enabled provider adapter, which maps it to that provider's tracking call. This keeps public UI code independent from provider-specific APIs.
References: src/…/+page.svelte• L39-237 src/…/+server.ts• L100-110 src/…/siteDataKeys.ts• L200-232 src/…/beacon.ts• L6-22 src/…/openpanel.js• L36-54
Change checklist
When these files or sections are changed, remember to consider these:
- When an embed route or query parameter changes, update the management generator, monitor detail share dialog, direct iframe examples, and any generated script behavior together.
- When monitor visibility rules change, keep status views, latency views, badges, live event filters, and monitor detail sharing aligned with the active and visible boundary.
- When the monitor-bar response changes, check both embed types because they select different values from the same response.
- When incident or maintenance scope changes, check the live event embed against the public page, event calendar, and event detail views.
- When a badge option changes, keep the route query contract, SVG output, all-monitors behavior, and Markdown or HTML snippets aligned.
- When analytics provider fields change, update site-data validation, the management form, template substitution, and the combined /capture.js output together.
- When analytics event names or payloads change, keep the common beacon event and every provider adapter compatible.
- When a capture snippet adds a provider, keep its saved requirement names, template placeholders, escaping rules, and provider event call aligned.
- When script output changes, keep the generator's format choices limited to views with a matching script endpoint or provide the endpoint before publishing that choice.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A published embed uses an inactive, hidden, or missing monitor tag | The view or badge cannot return the expected monitor data | Generate links from active visible monitors and treat the tag as a stable public URL value. |
| A caller requests more than 90 days for a monitor embed | The view silently uses the 90-day limit | Treat the server limit as part of the external view contract. |
| A live event embed omits both event filters | Both incidents and maintenance events appear | Set incidents=0 or maintenance=0 when a narrower event view is required. |
| A script snippet is used for a latency or live event view | The external page requests an unavailable JavaScript resource instead of loading the widget | Use an iframe for those views or provide a matching script endpoint before publishing script output. |
| A badge range is below 60 seconds or is not numeric | The badge falls back to a 90-day range | Use a valid sinceLast value and do not assume invalid input produces an error. |
| A requested badge locale is not enabled | The status text falls back to the configured default locale | Enable the locale before publishing a localized status badge. |
| All analytics providers are disabled | /capture.js contains no tracking code | Enable and save at least one provider before expecting analytics events. |
| An analytics setting contains a quote or line break | The capture response can become invalid JavaScript if the value is inserted without escaping | Keep the generated-value escaping in /capture.js when adding or changing provider fields. |
| A provider script is blocked by a content policy or ad blocker | Page activity is not sent to that provider even though the capture script loads | Allow the provider's script and data hosts or configure the provider's supported proxy or endpoint. |
Key files
| File | Why to read it |
|---|---|
| src/…/+page.svelte | Shows the central embed choices, preview behavior, URL parameters, and copied snippets. |
| src/…/EGM.md | Records the embed generator's supported views, access rule, defaults, and script endpoint gap. |
| src/…/+page.svelte | Shows the compact monitor status view used in external sites. |
| src/…/+page.svelte | Shows the latency chart view and metric selection. |
| src/…/+page.server.ts | Shows event filters and the current incident and maintenance scope. |
| src/…/+page.svelte | Shows the compact public event result and empty state. |
| src/…/+server.ts | Shows how the generated monitor script creates and resizes an iframe. |
| src/…/+page.svelte | Shows badge configuration and Markdown or HTML output. |
| src/…/monitorsController.ts | Shows how status, uptime, and latency values become SVG badges. |
| src/…/+server.ts | Shows the live-dot badge and optional ping animation. |
| src/…/+server.ts | Shows how enabled analytics settings become one browser script. |
| src/…/beacon.ts | Defines the common analytics event sent by public UI actions. |
| src/…/+page.svelte | Shows supported providers and their site-level configuration model. |
| src/…/openpanel.js | Shows how OpenPanel loads its client and receives the common analytics event. |