Skip to content

Products

Product analytics card

Per-product performance figures, with defaults supplied for the prototype.
Available
Needs mock props

Examples

Rendered live from the maintained Storybook story. Lantern stores only the story id and embeds Storybook rather than duplicating the component or its demo.

Product analytics card

Rendered live from Storybook

Storybook must be running for this to load — bun run start:storybook from the monorepo root, or set NEXT_PUBLIC_STORYBOOK_URL to a deployed instance.

Props

The component's public API, read from its TypeScript source. Descriptions come from TSDoc on the prop, so this table cannot drift from the component.

PropTypeDefaultDescription
productId*string—Used to build the default share URL.
statsProductAnalyticsStatsDEFAULT_PRODUCT_ANALYTICS_STATSThe figures to display. Defaults to `DEFAULT_PRODUCT_ANALYTICS_STATS`.
statsForRange(rangeKey: string) => ProductAnalyticsStats | undefined—Optional per-range figures, so changing the date range in a demo re-renders plausible numbers without inventing them. Return `undefined` to fall back to `stats`. Must be a pure function of the range key.
defaultDateRangestring"30d"Uncontrolled initial date range key.
dateRangestring—Controlled date range key — one of the `DATE_RANGE_PRESETS` values, or `"custom"`.
onDateRangeChange(rangeKey: string, start: Date, end: Date) => void—Undocumented — add TSDoc to the prop in the library.
defaultPanelOpenbooleanfalseUncontrolled seed for the date-range panel, so "panel open" is a snapshot.
panelOpenboolean—Controlled date-range panel state.
onPanelOpenChange(open: boolean) => void—Undocumented — add TSDoc to the prop in the library.
defaultShareOpenbooleanfalseUncontrolled seed for the share modal.
shareOpenboolean—Controlled share modal state.
onShareOpenChange(open: boolean) => void—Undocumented — add TSDoc to the prop in the library.
shareUrlstring—URL offered in the share modal. Defaults to `https://bts.space/store/{productId}`.
titlestring"Analytics"Heading text beside the range button.
currencySymbolstring"$"Prefix on the revenue figure. BTS reports in AUD, hence the bare `$`.
nowDateDATE_RANGE_DEFAULT_NOWReference "today" for the relative presets.
epochDateDATE_RANGE_DEFAULT_EPOCHStart of the "All time" range.
usePortalForPanelbooleantrueRender the date-range panel into `document.body`. False keeps it in flow, which is what a docs page wants.
anchorPanelToHeaderbooleantruePin the date-range panel under the header row (the app's behaviour). Set false and the panel uses `DateRangePickerPanel`'s un-anchored fallback inset instead. Why this is a prop: the panel measures its anchor once, in a layout effect fired when `open` flips. A story that opens the panel *on mount* races the stylesheet — the measurement can land before the CSS applies and produce a zero-width panel. Un-anchoring sidesteps the race, which is what `DateRangePanelOpen` does.
classNamestring—Undocumented — add TSDoc to the prop in the library.

Reference

Transcribed from the component audit. If this disagrees with the source, the source is right.

Source
src/components/products/ProductAnalyticsCard.tsx
Portability
Needs its app dependencies replaced by props before it renders in isolation.