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.
| Prop | Type | Default | Description |
|---|---|---|---|
productId* | string | — | Used to build the default share URL. |
stats | ProductAnalyticsStats | DEFAULT_PRODUCT_ANALYTICS_STATS | The 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. |
defaultDateRange | string | "30d" | Uncontrolled initial date range key. |
dateRange | string | — | 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. |
defaultPanelOpen | boolean | false | Uncontrolled seed for the date-range panel, so "panel open" is a snapshot. |
panelOpen | boolean | — | Controlled date-range panel state. |
onPanelOpenChange | (open: boolean) => void | — | Undocumented — add TSDoc to the prop in the library. |
defaultShareOpen | boolean | false | Uncontrolled seed for the share modal. |
shareOpen | boolean | — | Controlled share modal state. |
onShareOpenChange | (open: boolean) => void | — | Undocumented — add TSDoc to the prop in the library. |
shareUrl | string | — | URL offered in the share modal. Defaults to `https://bts.space/store/{productId}`. |
title | string | "Analytics" | Heading text beside the range button. |
currencySymbol | string | "$" | Prefix on the revenue figure. BTS reports in AUD, hence the bare `$`. |
now | Date | DATE_RANGE_DEFAULT_NOW | Reference "today" for the relative presets. |
epoch | Date | DATE_RANGE_DEFAULT_EPOCH | Start of the "All time" range. |
usePortalForPanel | boolean | true | Render the date-range panel into `document.body`. False keeps it in flow, which is what a docs page wants. |
anchorPanelToHeader | boolean | true | Pin 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. |
className | string | — | 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.