Pyric
Navigate

API reference

@pyric/ui/traffic

74 published symbols from @pyric/ui

Generated from the TypeScript declarations shipped at this import path.

Interfaces

MetricPoint

Properties

PropertyTypeDescription
endnumber-
indexnumber0-based bucket index, left (oldest) to right (newest).
startnumberHalf-open bounds of this bucket [start, end) in epoch-ms.

MetricSeries

Properties

PropertyTypeDescription
keystring-
labelstring-
totalnumberSum of values — the period total (the legend/card number).
valuesnumber[]One count per bucket, aligned with points.

RuleHeatmapEntry

Properties

PropertyTypeDescription
allowsnumber-
deniesnumber-
denyRationumberdenies / total — 0 when the rule never denied.
operationsstring[]Union of all operations seen matching this rule.
ruleIndexnumberThe rule’s index in the rules file.
totalnumberTotal events that matched this rule.
unsupportednumber-

RuleHeatmapProps

Properties

PropertyTypeDescription
className?string-
emptyState?ReactNode-
entriesRuleHeatmapEntry[]Per-rule rollup from useRuleHeatmap.
onSelectRule?(ruleIndex: number) => voidFired when a rule row is clicked — wire this to the log filter for the cross-view “click a rule, see its traffic” interaction.
selectedRuleIndex?numberMarks one rule row as the active selection.

TimeWindow

A half-open time window [start, end) in epoch-ms. The timeline buckets events whose at falls inside it; events outside are dropped from the histogram (but still counted in outOfWindow).

Properties

PropertyType
endnumber
startnumber

TrafficAuthState

Properties

PropertyType
token?Record<string, unknown>
uidstring

TrafficBucket

Properties

PropertyTypeDescription
allowsnumbercount - denies — allowed + unsupported. The “non-deny” stack.
countnumberTotal events that fell in this bucket.
deniesnumberHow many of count were denied.
denyHeightRationumberdenies / maxCount — 0..1. The deny sub-stack height as a fraction of the tallest bucket, so the deny segment is drawn to the same scale as the full bar. Drives --pyric-bucket-deny-h.
endnumber-
heightRationumbercount / maxCount across all buckets — 0..1. The full bar height as a fraction of the tallest bucket. Drives --pyric-bucket-h.
indexnumber0-based bucket index, left (oldest) to right (newest).
startnumberHalf-open bounds of this bucket [start, end) in epoch-ms.

TrafficCounts

Properties

PropertyTypeDescription
deniednumberOf those, how many were denied.
listenernumberOf those, how many are listener re-evals.
totalnumberEvents currently in the buffer.

TrafficDetailProps

Properties

PropertyTypeDescription
className?string-
eventTrafficEvent-
formatTime?(at: number) => stringOverride the timestamp rendering. Default is HH:MM:SS.
onBack?() => voidFired by the back affordance. When absent, no back button.
renderClassification?(event: TrafficEvent) => ReactNodeRender-prop slot below the header — the playground drops its denial overlay (classification + LLM analysis) here. The library doesn’t own that analysis.

TrafficEvent

Properties

PropertyTypeDescription
atnumberDate.now() at op start.
authTrafficAuthState-
durationMs?numberCanonical service-operation duration.
evalMs?numberSimulator eval duration in ms. De-featured in the UI (local simulator) — present for the detail panel only.
groupId?stringShared across ops in one batch or transaction.
groupKind?| "transaction" | "batch" | string & { }-
idstringUnique per emission.
kind?"request" | "operation"Source event kind. Firestore request events omit this in older adapters.
matchedRule?TrafficMatchedRuleParsed from the matched Rule #N debug line — absent if none.
methodTrafficMethod-
originTrafficOrigin-
pathstring-
reasonsstring[]Simulator debug messages — Rule #N (op) → ALLOW format.
request?{ data?: unknown; query?: unknown; resourceData?: unknown; }Proposed write payload — absent on reads + delete.
request.data?unknown-
request.query?unknown-
request.resourceData?unknown-
resourceAfter?TrafficResourceStateProjected doc state after the write — absent on reads.
resourceBefore?TrafficResourceStateExisting doc state before the write (or the read target).
resultTrafficResult-
service?| "firestore" | "rtdb" | "auth" | "storage" | string & { }Service that emitted the event. Omitted means Firestore.
triggeredBy?{ method: string; path?: string; }For listener re-evals — the originating user op.
triggeredBy.methodstring-
triggeredBy.path?string-

TrafficFilterState

Properties

PropertyType
originTrafficOriginFilter
pathQuerystring
resultTrafficResultFilter

TrafficGroup

Properties

PropertyTypeDescription
countnumber-
deniesnumber-
eventsTrafficEvent[]-
keystringgroupId for batch/transaction; a synthetic key for listener runs. Stable enough for a React key.
kindTrafficGroupKind-
type"group"-

TrafficGroupRowProps

Properties

PropertyTypeDescription
className?string-
defaultExpanded?booleanWhether the group starts expanded. Default false — grouping exists to collapse volume, so collapsed is the useful default.
formatTime?(at: number) => stringPassed through to each member <TrafficRow>.
groupTrafficGroup-
onSelect?(event: TrafficEvent) => void-
renderClassification?(event: TrafficEvent) => ReactNodePassed through to each member <TrafficRow>.
selectedId?string-

TrafficLineChartProps

Properties

PropertyTypeDescription
className?string-
emptyState?ReactNode-
formatTime?(t: number) => string-
formatValue?(n: number) => string-
omitZeroSeries?booleanOmit all-zero series from the plot and tooltip while retaining their explicit total in the accompanying metric strip.
pointsreadonly MetricPoint[]-
seriesreadonly MetricSeries[]-
visible?ReadonlySet<string>Series keys currently drawn. Omit to draw every series. Pair with TrafficMetricCardsvisible/onToggle so the legend cards and the chart’s lines toggle in lockstep.

TrafficLogProps

Properties

PropertyTypeDescription
className?string-
emptyState?ReactNode-
eventsTrafficEvent[]Events to render, in display order. The hook layer decides the order — <TrafficLog> renders the array as given.
formatTime?(at: number) => stringPassed through to each <TrafficRow>.
items?TrafficLogItem[]Grouped items from useTrafficGroups. When provided, the log renders singles + collapsible group rows and does NOT virtualize — grouping is itself the volume reducer (a 250-event listener storm becomes one group row). events is ignored.
onSelect?(event: TrafficEvent) => void-
renderClassification?(event: TrafficEvent) => ReactNodePassed through to each <TrafficRow>.
renderRow?(event: TrafficEvent, selected: boolean) => ReactNodeFull escape hatch — render a row yourself instead of the default <TrafficRow>. Receives the event and its selected state. Applies to the flat (events) path only.
rowHeight?number | (index: number) => numberEstimated row height when virtualizing. Default 28.
selectedId?stringThe selected event’s id, marked with data-pyric-selected.
virtualizedHeight?string | numberPixel height the virtualized scroll container fills. Default '60vh'.
virtualizeThreshold?numberAbove this row count, the list virtualizes via <VirtualList>. Default 100 — a load-test-shaped session can emit 100k+ events, so virtualization is load-bearing, not polish.

TrafficMatchedRule

Properties

PropertyType
operationsstring[]
ruleIndexnumber

TrafficMetricCardsProps

Properties

PropertyTypeDescription
className?string-
formatValue?(n: number) => string-
onToggle?(key: string) => void-
seriesreadonly MetricSeries[]-
visible?ReadonlySet<string>When supplied (with onToggle), each card gets a checkbox and doubles as the chart’s legend — Console reference semantics (“toggle series visibility”). Omit for a read-only totals strip.

TrafficMetricsResult

Properties

PropertyTypeDescription
maxValuenumberThe largest single-bucket value across every series — the shared y-scale divisor a chart would use by default.
pointsMetricPoint[]-
seriesMetricSeries[]-

TrafficResourceState

Properties

PropertyType
dataunknown
existsboolean

TrafficRowProps

Properties

PropertyTypeDescription
className?string-
eventTrafficEvent-
formatTime?(at: number) => stringOverride the timestamp rendering. Default is HH:MM:SS.
onSelect?(event: TrafficEvent) => void-
renderClassification?(event: TrafficEvent) => ReactNodeRender-prop slot for a consumer-specific classification badge — e.g. the playground’s expected/ambiguous/unexpected verdict, which is app-source analysis the library doesn’t own. Returns null to render nothing.
selected?booleanMarks the row as the active selection (data-pyric-selected).

TrafficSingle

Properties

PropertyType
eventTrafficEvent
type"single"

TrafficStatBucket

Properties

PropertyType
countnumber
keystring

TrafficStatsProps

Properties

PropertyType
className?string
statsTrafficStatsSummary

TrafficStatsSummary

Properties

PropertyTypeDescription
allowsnumber-
byMethodTrafficStatBucket[]Counts by method, sorted descending.
byOriginTrafficStatBucket[]Counts by origin, sorted descending.
byPathTrafficStatBucket[]Counts by path, sorted descending, capped at topPaths.
deniesnumber-
denyRatenumberdenies / total — 0 for an empty buffer.
totalnumber-
unsupportednumber-

TrafficTimelineProps

Properties

PropertyTypeDescription
axis?ReactNode | (window: TimeWindow) => ReactNodeAxis slot — tick labels below the bars inside [data-pyric-timeline-axis]. The mock puts “14m ago · 7m · now” here. Receives the resolved window so labels can be derived.
brush?TimeWindowA brushed sub-range ([start, end)) drawn as an overlay over the bars. Position is derived from where it falls inside window, so a partly-out-of-window brush clamps to the chart edges.
bucketCount?numberNumber of bars. Default 30. Only used on the events path.
buckets?UseTrafficBucketsResultPre-bucketed counts — the escape hatch when the caller already ran useTrafficBuckets (or bucketTraffic) upstream, e.g. to share one bucketing pass across the timeline + a stats header. Takes precedence over events.
className?string-
emptyState?ReactNode-
events?TrafficEvent[]Raw traffic events to bucket. Ignored when buckets is supplied (the consumer pre-bucketed). Exactly one of events / buckets should drive the histogram.
header?ReactNodeHeader slot — title, deny summary, live label. Rendered above the bars inside [data-pyric-timeline-header]. The mock puts “142 requests · 16 denied · live” here.
liveAt?numberWhere the live edge marker sits, in epoch-ms. Defaults to window.end (the right edge = “now”). Omit / pass null to hide the marker entirely (e.g. a frozen, non-live window).
onBrush?(window: TimeWindow) => voidFired when a bar inside the brush region is clicked-through — the component itself is presentation-agnostic about drag, so the primary brush gesture is owned by the consumer. As a built-in affordance, clicking a bucket calls this with a one-bucket-wide window so a bare consumer still gets a working selection.
renderBucketSummary?(bucket: TrafficBucket) => ReactNodeDirect annotation shown while a bucket is hovered or keyboard-focused. The timeline owns preview state and positioning; the consumer owns the words and number formatting.
windowTimeWindowThe time range the histogram spans.

UseRuleHeatmapOptions

Properties

PropertyType
eventsTrafficEvent[]

UseRuleHeatmapResult

Properties

PropertyTypeDescription
entriesRuleHeatmapEntry[]Per-rule rollup, sorted by total descending (busiest first), ties broken by ruleIndex ascending.
unmatchedCountnumberEvents that matched no rule — counted here, not attributed to any entry.

UseTrafficBucketsOptions

Properties

PropertyTypeDescription
bucketCount?numberNumber of buckets to divide the window into. Default 30.
eventsTrafficEvent[]-
windowTimeWindowThe time range to bucket over.

UseTrafficBucketsResult

Properties

PropertyTypeDescription
bucketsTrafficBucket[]-
deniesnumberSum of denies across buckets.
maxCountnumberThe largest single-bucket count — the height-ratio divisor.
outOfWindownumberEvents whose at fell outside [window.start, window.end).
totalnumberSum of count across buckets (events inside the window).

UseTrafficFilterOptions

Properties

PropertyTypeDescription
eventsTrafficEvent[]-
initialOrigin?TrafficOriginFilterDefault user — the probe found listener traffic is 94–99.6% of events, so it’s hidden until explicitly asked for.
initialPathQuery?string-
initialResult?TrafficResultFilterDefault all — the probe found ~75–80% allow in realistic sessions, so hiding either side loses diagnostic signal.

UseTrafficFilterResult

Properties

PropertyTypeDescription
filterTrafficFilterState-
filteredTrafficEvent[]Events passing all three filters, in the input order.
setOrigin(origin: TrafficOriginFilter) => void-
setPathQuery(pathQuery: string) => void-
setResult(result: TrafficResultFilter) => void-

UseTrafficGroupsOptions

Properties

PropertyTypeDescription
eventsTrafficEvent[]-
groupBatches?booleanCollapse consecutive ops sharing a groupId. Default true.
groupListenerRuns?booleanCollapse a consecutive run of listener re-evals from the same originating op into one group — the probe found a single write can trigger 250+ re-evals. Default true.

UseTrafficGroupsResult

Properties

PropertyTypeDescription
itemsTrafficLogItem[]Events folded into a flat list of singles and groups, in the input order.

UseTrafficMetricsOptions

Properties

PropertyTypeDescription
bucketCount?numberNumber of buckets to divide the window into. The window itself should already be sized to the session (sandbox sessions run minutes, not days) — bucket count doesn’t need to change, only the window a caller passes in. Default 24.
eventsTrafficEvent[]-
isAdmin?(event: Pick<TrafficEvent, "origin">) => booleanOverride admin classification (e.g. a Studio caller with authLens provenance available — see the module doc). Defaults to origin === 'admin'.
windowTimeWindow-

UseTrafficMonitorOptions

Properties

PropertyTypeDescription
bufferSize?numberRing-buffer cap. Once exceeded, the oldest events are dropped. Default 5000 (~3 MB worst case — see the traffic-monitor probe findings).
paused?booleanWhether the buffer starts paused. Default false.
sourceTrafficSourceThe subscription function — sandbox.onRequest satisfies this directly. Pass a stable reference; the hook re-subscribes on identity change.
transform?(event: TrafficEvent) => TrafficEventRuns per event before buffering — return a (possibly trimmed) event. Lets the consumer shrink oversized payloads without the library knowing payload semantics. Identity is read fresh on each event, so it need not be memoized.

UseTrafficMonitorResult

Properties

PropertyTypeDescription
clear() => voidEmpty the buffer.
countsTrafficCounts-
eventsTrafficEvent[]The buffered events, oldest first.
isPausedboolean-
pause() => voidStop appending — incoming events are dropped while paused.
resume() => voidResume appending.

UseTrafficStatsOptions

Properties

PropertyTypeDescription
eventsTrafficEvent[]-
topPaths?numberCap on byPath entries — paths are unbounded. Default 10.

Type Aliases

BillableSeriesKey

type BillableSeriesKey = "reads" | "writes" | "deletes";

RulesSeriesKey

type RulesSeriesKey = "allows" | "denies" | "errors";

TrafficGroupKind

type TrafficGroupKind = "batch" | "transaction" | "listener-run";

TrafficLogItem

type TrafficLogItem = TrafficGroup | TrafficSingle;

TrafficMethod

type TrafficMethod =
  | "get"
  | "list"
  | "create"
  | "update"
  | "set"
  | "delete"
  | "remove"
  | "push"
  | "listen"
  | "transaction"
  | string & {
};

The traffic domain types. TrafficEvent is structurally identical to pyric/sandbox’s RequestEvent (locked in the design rationale) — but the library defines its own copy so it never imports pyric/sandbox. sandbox.onRequest is assignable as a TrafficSource with zero adapter code; a prod log feed can satisfy the same shape.


TrafficOrigin

type TrafficOrigin = "user" | "listener" | "transaction" | "batch" | "admin" | "system";

TrafficOriginFilter

type TrafficOriginFilter = "user" | "all" | "listener";

user keeps everything that isn’t a listener re-eval (user ops plus their transaction/batch sub-ops); listener keeps only listener re-evals; all keeps everything.


TrafficResult

type TrafficResult = "allow" | "deny" | "unsupported" | "error" | "not-applicable";

TrafficResultFilter

type TrafficResultFilter = "all" | "allow" | "deny";

TrafficSource()

type TrafficSource = (cb: (event: TrafficEvent) => void) => () => void;

A subscription function: register a callback, get back an unsubscribe. pyric/sandbox’s Sandbox.onRequest matches this signature exactly.

Parameters

ParameterType
cb(event: TrafficEvent) => void

Returns

(): void;
Returns

void

Variables

BILLABLE_SERIES_DEFS

const BILLABLE_SERIES_DEFS: ReadonlyArray<{
  key: BillableSeriesKey;
  label: string;
}>;

RULES_SERIES_DEFS

const RULES_SERIES_DEFS: ReadonlyArray<{
  key: RulesSeriesKey;
  label: string;
}>;

Functions

bucketBillableMetrics()

function bucketBillableMetrics(
   events: readonly TrafficEvent[],
   window: TimeWindow,
   bucketCount?: number,
   isAdmin?: (event: Pick<TrafficEvent, "origin">) => boolean): TrafficMetricsResult;

Pure kernel behind useBillableMetrics — usable outside React.

Parameters

ParameterType
eventsreadonly TrafficEvent[]
windowTimeWindow
bucketCount?number
isAdmin?(event: Pick<TrafficEvent, "origin">) => boolean

Returns

TrafficMetricsResult


bucketRulesMetrics()

function bucketRulesMetrics(
   events: readonly TrafficEvent[],
   window: TimeWindow,
   bucketCount?: number,
   isAdmin?: (event: Pick<TrafficEvent, "origin">) => boolean): TrafficMetricsResult;

Pure kernel behind useRulesMetrics — usable outside React.

Parameters

ParameterType
eventsreadonly TrafficEvent[]
windowTimeWindow
bucketCount?number
isAdmin?(event: Pick<TrafficEvent, "origin">) => boolean

Returns

TrafficMetricsResult


bucketTraffic()

function bucketTraffic(
   events: TrafficEvent[],
   window: TimeWindow,
   bucketCount?: number): UseTrafficBucketsResult;

The pure bucketing kernel behind useTrafficBuckets — usable outside React. Returns an empty result for a non-positive bucketCount or a zero/negative-width window.

Parameters

ParameterType
eventsTrafficEvent[]
windowTimeWindow
bucketCount?number

Returns

UseTrafficBucketsResult


classifyBillable()

function classifyBillable(event: Pick<TrafficEvent, "method" | "result" | "origin">, isAdmin?: (event: Pick<TrafficEvent, "origin">) => boolean): BillableSeriesKey;

Classify a billable op, or null if it isn’t one / never ran.

Parameters

ParameterType
eventPick<TrafficEvent, "method" | "result" | "origin">
isAdmin?(event: Pick<TrafficEvent, "origin">) => boolean

Returns

BillableSeriesKey


classifyRules()

function classifyRules(event: Pick<TrafficEvent, "result" | "origin">, isAdmin?: (event: Pick<TrafficEvent, "origin">) => boolean): RulesSeriesKey;

Classify a rules-engine verdict, or null if it isn’t one (bypassed, unsupported, or not-applicable).

Parameters

ParameterType
eventPick<TrafficEvent, "result" | "origin">
isAdmin?(event: Pick<TrafficEvent, "origin">) => boolean

Returns

RulesSeriesKey


defaultFormatTime()

function defaultFormatTime(at: number): string;

Default HH:MM:SS timestamp formatter. Components accept a formatTime prop to override — this is just the fallback so the library has no hard locale dependency.

Parameters

ParameterType
atnumber

Returns

string


isAdminEvent()

function isAdminEvent(event: Pick<TrafficEvent, "origin">): boolean;

Default admin predicate: the one signal the public TrafficEvent type declares. See the module doc for the known Firestore gap.

Parameters

ParameterType
eventPick<TrafficEvent, "origin">

Returns

boolean


reasonVerdict()

function reasonVerdict(reason: string): "allow" | "deny" | "neutral";

Classifies a simulator debug line as a deny / allow / neutral verdict so consumers can tint reason rows via [data-pyric-reason-verdict="…"].

Parameters

ParameterType
reasonstring

Returns

"allow" | "deny" | "neutral"


RuleHeatmap()

function RuleHeatmap(__namedParameters: RuleHeatmapProps): Element;

Headless rule heatmap — one row per rule, busiest first. Each row exposes two styling channels:

  • data-pyric-rule-heat — a discrete bucket (none/low/ medium/high) by deny ratio, for threshold-based coloring.
  • --pyric-deny-ratio — the raw 0–1 ratio as a CSS custom property, for a proportional bar / gradient.

Counts render as separate elements (data-pyric-rule-total, -allows, -denies) so the consumer can show numbers, bars, or both.

Styling hooks: [data-pyric-ui="rule-heatmap"], [data-pyric-rule-row] (with data-pyric-rule-index, data-pyric-rule-heat, data-pyric-selected).

Parameters

ParameterType
__namedParametersRuleHeatmapProps

Returns

Element


TrafficDetail()

function TrafficDetail(__namedParameters: TrafficDetailProps): Element;

Headless drill-in panel for a single traffic event. Renders the header (result + origin + timestamp + method/path + matched rule), a consumer classification slot, then JSON sections for auth, request payload, and resource before/after via <JsonView>, plus the reasons list, triggeredBy, and groupId.

evalMs appears here as a minor header field only — it is not a log column (local simulator; latency is de-featured per the design rationale).

Styling hooks: [data-pyric-ui="traffic-detail"], [data-pyric-traffic-section] (with data-pyric-section-label), [data-pyric-traffic-reason] (with data-pyric-reason-verdict).

Parameters

ParameterType
__namedParametersTrafficDetailProps

Returns

Element


TrafficGroupRow()

function TrafficGroupRow(__namedParameters: TrafficGroupRowProps): Element;

A collapsible group row — one header summarizing a batch, transaction, or listener-run, expanding to the member rows. The header carries data-pyric-group-kind and a data-pyric-group-* count/deny rollup; expansion state is data-pyric-expanded.

Styling hooks: [data-pyric-traffic-group], [data-pyric-traffic-group-header] (with data-pyric-group-kind), [data-pyric-traffic-group-members].

Parameters

ParameterType
__namedParametersTrafficGroupRowProps

Returns

Element


TrafficLineChart()

function TrafficLineChart(__namedParameters: TrafficLineChartProps): Element;

Hand-rolled SVG line chart, no charting dependency — plain lines over a 0..100 viewBox so CSS drives the actual size (intrinsic layout, no fixed pixel chart). Each series draws only when visible includes its key (or visible is omitted). The y-scale is the max value across the currently VISIBLE series only, so toggling a tall series off rescales the rest up — matching the Console reference.

Interaction: hovering (or focusing, via the invisible per-bucket hit targets) shows a tooltip with the bucket’s time range and each visible series’ value at that bucket — [data-pyric-chart-tooltip], positioned via --pyric-hover-x.

Styling hooks: [data-pyric-ui="traffic-line-chart"], [data-pyric-chart-svg], [data-pyric-chart-line] (with data-pyric-series-key, data-pyric-series-index — the same index a TrafficMetricCards card carries, so line + card colors line up), [data-pyric-chart-hit] (with data-pyric-point-index), [data-pyric-chart-tooltip], [data-pyric-tooltip-row].

Parameters

ParameterType
__namedParametersTrafficLineChartProps

Returns

Element


TrafficLog()

function TrafficLog(__namedParameters: TrafficLogProps): Element;

Headless traffic log — a Chrome DevTools Network-panel-style event stream. Below virtualizeThreshold it renders a plain <ul>; above it, TanStack-Virtual via <VirtualList>.

Styling hooks: [data-pyric-ui="traffic-log"], [data-pyric-traffic-entry] (the list item wrapper), plus the <TrafficRow> hooks.

Parameters

ParameterType
__namedParametersTrafficLogProps

Returns

Element


TrafficMetricCards()

function TrafficMetricCards(__namedParameters: TrafficMetricCardsProps): Element;

The period-total strip: one card per series, each showing the series’ total for the current window. Doubles as BOTH the chart’s legend row (pass visible + onToggle to get the checkbox-toggle semantics) AND the standalone fallback presentation when a chart isn’t warranted — this component never depends on TrafficLineChart.

Styling hooks: [data-pyric-ui="traffic-metric-cards"], [data-pyric-metric-card] (with data-pyric-metric-key, data-pyric-series-index — the color channel a chart’s lines also key off of, so a card and its line always match), [data-pyric-metric-hidden] when toggled off.

Parameters

ParameterType
__namedParametersTrafficMetricCardsProps

Returns

Element


TrafficRow()

function TrafficRow(__namedParameters: TrafficRowProps): Element;

One headless traffic row — timestamp, method badge, path, and an optional consumer classification slot. The raw result is exposed as data-pyric-result on the row (for tinting/filtering); rendering a verdict/outcome label is the consumer’s job via renderClassification — the row itself draws no result chip, so a consumer verdict never collides with a built-in one. Latency is intentionally absent: this is a local simulator, so evalMs lives in <TrafficDetail> only.

Styling hooks:

  • [data-pyric-traffic-row] — the row button, with data-pyric-result, data-pyric-origin, data-pyric-method
  • [data-pyric-traffic-row][data-pyric-selected] — active row
  • [data-pyric-traffic-time] / [data-pyric-traffic-path]
  • [data-pyric-traffic-service] — the service label (firestore / rtdb / storage / auth), rendered even when unknown (empty) so fixed-width styling keeps the columns aligned
  • method renders as <Badge> (data-pyric-badge-kind)

Parameters

ParameterType
__namedParametersTrafficRowProps

Returns

Element


TrafficStats()

function TrafficStats(__namedParameters: TrafficStatsProps): Element;

Headless aggregation panel. Renders the totals, the deny rate, and count breakdowns by method / origin / path. The deny rate is exposed both as text and as a --pyric-deny-rate CSS custom property on the root for a proportional meter.

Styling hooks: [data-pyric-ui="traffic-stats"], [data-pyric-stat] (with data-pyric-stat-key), [data-pyric-stat-group] (with data-pyric-stat-group-label), [data-pyric-stat-bucket].

Parameters

ParameterType
__namedParametersTrafficStatsProps

Returns

Element


TrafficTimeline()

function TrafficTimeline(__namedParameters: TrafficTimelineProps): Element;

Headless volume-over-time histogram — the time axis for the traffic lens. Buckets events into N bars; each bar stacks denies (dark, at the base) under the allow remainder, matching the Studio mock.

Per-bucket styling channels (on [data-pyric-bucket]):

  • data-pyric-bucket-count / -denies — raw integers.
  • --pyric-bucket-h — full bar height, 0..1 of the tallest bucket.
  • --pyric-bucket-deny-h — deny sub-stack height, same scale. The deny segment ([data-pyric-bucket-deny]) and allow segment ([data-pyric-bucket-allow]) are separate children so the consumer colors them independently.

A [data-pyric-brush] overlay marks a sub-range via --pyric-brush-left / --pyric-brush-right (0..1 fractions). The [data-pyric-live] edge marker sits at --pyric-live-x.

Styling hooks: [data-pyric-ui="traffic-timeline"], [data-pyric-timeline-header], [data-pyric-timeline-bars], [data-pyric-bucket] (with data-pyric-bucket-index, data-pyric-has-denies, data-pyric-bucket-selected), [data-pyric-bucket-summary], [data-pyric-brush], [data-pyric-live], [data-pyric-timeline-axis].

Parameters

ParameterType
__namedParametersTrafficTimelineProps

Returns

Element


useBillableMetrics()

function useBillableMetrics(__namedParameters: UseTrafficMetricsOptions): TrafficMetricsResult;

Reads / writes / deletes, bucketed over window. See the module doc for the billable mapping + the “read ops, not billable reads” caveat.

Parameters

ParameterType
__namedParametersUseTrafficMetricsOptions

Returns

TrafficMetricsResult


useRuleHeatmap()

function useRuleHeatmap(__namedParameters: UseRuleHeatmapOptions): UseRuleHeatmapResult;

Rolls a traffic buffer up by matchedRule.ruleIndex: how often each rule fired, and how that split across allow / deny / unsupported. Pure derivation — feed it the filtered or full event list depending on what the heatmap should reflect.

Parameters

ParameterType
__namedParametersUseRuleHeatmapOptions

Returns

UseRuleHeatmapResult


useRulesMetrics()

function useRulesMetrics(__namedParameters: UseTrafficMetricsOptions): TrafficMetricsResult;

Allows / denies / errors, bucketed over window. Excludes rules-bypassed (admin) ops — see the module doc.

Parameters

ParameterType
__namedParametersUseTrafficMetricsOptions

Returns

TrafficMetricsResult


useTrafficBuckets()

function useTrafficBuckets(__namedParameters: UseTrafficBucketsOptions): UseTrafficBucketsResult;

Buckets a traffic buffer into bucketCount equal time slices over window, counting total + denied events per slice. Pure derivation — the histogram component renders the result, this hook (and bucketTraffic under it) owns the math.

Each bucket carries a heightRatio and denyHeightRatio (0..1, scaled to the tallest bucket) so the consumer can map them straight onto a bar height without re-finding the max.

Parameters

ParameterType
__namedParametersUseTrafficBucketsOptions

Returns

UseTrafficBucketsResult


useTrafficFilter()

function useTrafficFilter(__namedParameters: UseTrafficFilterOptions): UseTrafficFilterResult;

Derives a filtered view over a traffic buffer along three dimensions: origin, result, and a case-insensitive path substring. Owns the filter state; pure derivation otherwise.

Parameters

ParameterType
__namedParametersUseTrafficFilterOptions

Returns

UseTrafficFilterResult


useTrafficGroups()

function useTrafficGroups(__namedParameters: UseTrafficGroupsOptions): UseTrafficGroupsResult;

Folds a traffic buffer into a list of singles and collapsible groups. Two grouping modes, both over consecutive events:

  • groupId — batch/transaction sub-ops sharing an id collapse into one batch / transaction group.
  • listener runs — a consecutive run of listener re-evals from the same originating op collapses into one listener-run group. A run of length 1 stays a single (no point collapsing one row).

Pure derivation; the input order is preserved.

Parameters

ParameterType
__namedParametersUseTrafficGroupsOptions

Returns

UseTrafficGroupsResult


useTrafficMonitor()

function useTrafficMonitor(__namedParameters: UseTrafficMonitorOptions): UseTrafficMonitorResult;

Buffers a traffic stream into a capped ring buffer with pause/resume/clear. Decoupled from pyric/sandboxsource is just a (cb) => unsubscribe function.

Pause is consumer-side: while paused, the subscription stays attached but incoming events are dropped (not queued). This matches the probe decision — a load-test-shaped session can emit 100k+ events, so queueing-while-paused would defeat the point.

Parameters

ParameterType
__namedParametersUseTrafficMonitorOptions

Returns

UseTrafficMonitorResult


useTrafficStats()

function useTrafficStats(__namedParameters: UseTrafficStatsOptions): TrafficStatsSummary;

Aggregations over a traffic buffer: totals, deny rate, and counts broken down by method, origin, and path. Pure derivation — feed it the filtered or full event list depending on what the panel should reflect.

Parameters

ParameterType
__namedParametersUseTrafficStatsOptions

Returns

TrafficStatsSummary