Recount
Node.js

Types

Every TypeScript type exported by the Recount Node.js SDK, from RecountOptions to table, chart and LLM span data.

Core

RecountOptions

type RecountOptions = {
  apiKey?: string;
  apiUrl?: string;
  debug?: boolean;
};

TraceOptions

type TraceOptions = {
  metadata?: Metadata;
  retentionPeriod?: RetentionPeriod;
};

RetentionPeriod

type RetentionPeriod = '1d' | '7d' | '30d' | '90d' | '1y';

IngestResult

type IngestResult = {
  traceId: string;
};

Spans

SpanType

type SpanType =
  | 'message'
  | 'json'
  | 'table'
  | 'http'
  | 'chart'
  | 'llm'
  | 'image'
  | 'db'
  | 'group';

SpanBaseOptions

Common options available on every span type.

type SpanBaseOptions = {
  description?: string;
  durationMs?: number;
  public?: boolean;
  redact?: string[];
};

GroupSpanOptions

type GroupSpanOptions = {
  description?: string;
  limit?: number;
  sample?: number;
  sampleThreshold?: number;
};

TableSpanOptions

type TableSpanOptions = SpanBaseOptions & {
  input?: TableData;
  output?: TableData;
};

ChartSpanOptions

type ChartSpanOptions = SpanBaseOptions & {
  input?: ChartData;
  output?: ChartData;
};

HttpSpanOptions

type HttpSpanOptions = SpanBaseOptions & {
  input?: HttpRequestInput;
  output?: HttpResponseOutput;
};

LlmSpanOptions

type LlmSpanOptions = SpanBaseOptions & {
  input?: LlmSpanInput;
  output?: LlmSpanOutput;
};

ImageSpanOptions

type ImageSpanOptions = SpanBaseOptions & {
  input?: ImageSpanData;
  output?: ImageSpanData;
};

DbSpanOptions

type DbSpanOptions = SpanBaseOptions & {
  metadata?: DbSpanMetadata;
  input?: { query?: string; params?: DbParamValue[]; [key: string]: unknown };
  output?: Record<string, unknown>;
  redactParams?: DbParamValue[];
};

JsonSpanOptions

type JsonSpanOptions = SpanBaseOptions & {
  input?: JsonObject;
  output?: JsonObject;
};

SpanOptions

Broad fallback type. Prefer the per-type options above when typing helper functions.

type SpanOptions = {
  description?: string;
  input?: JsonObject;
  output?: JsonObject;
  durationMs?: number;
  redact?: string[];
  redactParams?: unknown[];
  public?: boolean;
};

MessageSpanLevel

type MessageSpanLevel = 'info' | 'warn' | 'error';

MessageSpanOptions

type MessageSpanOptions = {
  description?: string;
  level?: MessageSpanLevel;
  public?: boolean;
};

DbSpanMetadata

type DbSpanMetadata = {
  collection?: string;
  table?: string;
  queryType?: 'sql' | 'nosql';
};

Alerts

SpanAlertLevel

type SpanAlertLevel = 'warn' | 'error';

SpanAlertOptions

Options passed to recount.addAlert() / g.alert(). See Alerts.

type SpanAlertOptions = {
  checks?: SpanAlertCheck[];
};

SpanAlert

The shape stored on a span after addAlert() attaches to it - not something you construct directly.

type SpanAlert = {
  label: string;
  level: SpanAlertLevel;
  checks?: SpanAlertCheck[];
};

SpanAlertCheck

type SpanAlertCheck = {
  target?: string;
  value: number;
};

HTTP

HttpRequestInput

type HttpRequestInput = {
  method: HttpMethod;
  url: string;
  headers?: Record<string, string | { __redacted: true }>;
  content_type?: HttpContentType;
  body?: JsonObject | string | null;
};

HttpResponseOutput

type HttpResponseOutput = {
  status: number;
  headers?: Record<string, string | { __redacted: true }>;
  content_type?: HttpContentType;
  body?: JsonObject | string | null;
};

HttpMethod

type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';

HttpContentType

type HttpContentType = 'json' | 'form' | 'text' | null;

LLM

LlmSpanInput

type LlmSpanInput = {
  prompt?: string;
  messages?: LlmMessage[];
  system?: string;
  provider?: string;
  model?: string;
};

LlmSpanOutput

type LlmSpanOutput = {
  response?: string | JsonObject;
  inputTokens?: number;
  outputTokens?: number;
  stopReason?: string;
};

LlmMessage

type LlmMessage = {
  role: 'system' | 'user' | 'assistant' | 'tool';
  content: string;
};

Images

ImageSpanData

type ImageSpanData = {
  url: string;
  label?: string;
};

Tables

TableData

A single table definition. Pass directly as span input or output.

type TableData = {
  title?: string;
  columns: TableColumn[];
  rows: unknown[][];
  rowHighlights?: (TableHighlight | null)[];
  cellHighlights?: (TableHighlight | null)[][];
  summary?: TableSummaryStat[];
};

TableSummaryStat

type TableSummaryStat = {
  text: string;
  highlight?: TableHighlight;
};

TableColumn

type TableColumn =
  | string
  | {
      label: string;
      span?: number;
      highlight?: TableHighlight;
    };

TableHighlight

type TableHighlight = 'danger' | 'warn' | 'success' | 'info' | 'muted';

TableCellSpan

type TableCellSpan = {
  readonly __cellSpan: true;
  readonly span: number;
  readonly value: unknown;
};

Charts

ChartData

A single chart definition. Pass directly as span input or output.

type ChartData = {
  title?: string;
  type: ChartType;
  labels: string[];
  series: ChartSeries[];
  referenceLines?: ChartReferenceLine[];
};

ChartType

type ChartType = 'line' | 'bar' | 'pie' | 'scatter';

ChartSeries

type ChartSeries = {
  name?: string;
  data: number[];
};

ChartReferenceLine

type ChartReferenceLine = {
  value: number;
  label?: string;
};

Database

DbParamValue

The allowed value types for database query parameters. Use REDACTED sentinel to redact a specific parameter.

type DbParamValue = string | number | boolean | null | { __redacted: true };

Utilities

JsonObject

type JsonObject = Record<string, unknown> | unknown[];

Metadata

type Metadata = Record<string, string | number | boolean | null>;

Errors

RecountError

Thrown by the Recount client when the API returns a non-OK response. The default SDK export swallows ingest errors silently, so you will only encounter this if using the Recount class directly.

class RecountError extends Error {
  readonly status: number;
}

On this page