Enable platform widgets · option 3 · demo

Platform-drawn KPI cards

The platform draws the designer's card itself, from numbers its own server reads out of Metabase with a signed, locked request. Every pixel of the cards below is this page's HTML, so the design is fully under the platform's control.

Demo numbers. They are generated inside Metabase by three dummy-data questions and are not Enable figures.

KPI cards

Demo scope

The filter values live inside a signed token on the server. This page can only ask for one of three scopes that were signed in advance; it cannot change a filter, and the server refuses any other value without calling Metabase.

Environment

dev reads the three dummy-data questions through signed tokens, as before. qa and demo read each instance's own platform questions (Accommodation, Approval and Conversion rate; their own ids, never another environment's) under that instance's credential, and read every scope as all/all/all.

Accommodation rate

—

Approval rate

—

Conversion rate

—

Reading live numbers from Metabase…

Spark dots: before and now, same rows

Each pair below is drawn from the same rows: on the left by the renderer as it shipped before the dot (js/card-before.js, unchanged since SPARK-1), on the right by today's js/card.js (SPARK-DOT-1). Under each pair, the rows the card drew from, exactly as fetched. Environment shown: dev, with the scope picked above.

Tyler's QA page: one window (recorded numbers, not live)

The QA page that showed no line had one merchant whose six applications all fall in the current 30-day window. These rows hold the numbers recorded for that window in DEV-SHEET-v2 (November 3); this page does not hold that merchant's id and does not read it live. One window: before shows nothing under the number, now shows the dot.

Across environments

The same three cards in each environment, for the scope picked above, drawn by today's js/card.js from that environment's own question. Each column says which question it read.

One window: a dot until there are two

A line needs two 30-day windows with a value. When a scope has only one (every application is newer than 30 days), the card draws a single dot at that value and says "trend after 30 days"; from the second window on it draws the line. Example rows, not live: both cards below are drawn by the same card.js from fixed rows in js/app.js (the first: 1 window; the second: 12 windows).

How it works

  1. Server signs. The platform's server signs a short-lived token naming the question and every locked filter (whitelabel, merchant, application). The signing secret never leaves the server.
  2. Server fetches. It calls Metabase's signed data request, GET /api/embed/card/<token>/query, server to server. Metabase answers no other site's browser (it sends no cross-origin headers), so this step cannot happen in the page.
  3. Server hands rows to the page. It returns only the columns and rows the card needs, from its own address (/api/widgets here).
  4. Page draws. The page turns rows into the label, the value, the change and the line, and draws the card exactly as designed.

Every code block below is fetched from the file this demo actually runs, so it cannot drift from what you see working above.

1. Sign on the server

HS256 over resource.question, params (every locked filter, one value each) and exp. File: /code/sign-token.js.

Loading…

2. Fetch on the server

The demo's server is a Cloudflare Pages Function. It holds three finished, expiring tokens per scope as a Cloudflare secret, never the signing secret. File: /code/widgets-handler.js (re-exported by functions/api/widgets.js).

Loading…
Loading…
Loading…

3. What the page receives

The response this page just received from /api/widgets (first two rows of each widget shown). Decimal cells arrive as JSON strings ("0.468800"): parse every numeric cell with Number(), and treat null or "" as "no value", never as zero. Window dates roll daily.

Loading…

4. Draw in the page

Value = the latest window's rate as a whole percent. Change = relative change against the previous window, the same arithmetic as Metabase's trend widget. File: /js/card.js.

Loading…
Loading…
Loading…

Ids are per environment

Every Metabase id belongs to one environment: the numeric ids (470, 211, …) and the entity_id strings alike. Metabase does not keep a supplied entity_id when a card is created, so a copy in another environment gets new ids of both kinds (checked on October 26, 2026).

ObjectProductionDev
Collection17867
Questions470–47567–72
Dashboard21134

Details, with each question's entity_id: the packet's shared/signing-and-fetching.md, section "Ids are per environment".

Rules