Skip to content

@ogygia/devtools · API

@ogygia/devtools/profiler/storage

The storage interface that decides where the profiler keeps its reports. The adapters are @ogygia/devtools/profiler/storage/sqlite, /redis and /postgres.

On this page

This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.

Exports getProfilerStore · recordColumns · setProfilerStore · MemoryStore · ProfilerRecord · ProfilerStore · ProfilerVisitRecord · ProfilerSummary

import { … } from '@ogygia/devtools/profiler/storage';

getProfilerStore

function

The store set by setProfilerStore, if any — read by the profiler host on mount.

function getProfilerStore(): ProfilerStore | undefined;

recordColumns

function

Pull the summary columns off a record for storing them alongside the dump.

function recordColumns(rec: ProfilerRecord): ProfilerSummary;

setProfilerStore

function

function setProfilerStore(store: ProfilerStore): void;

MemoryStore

class

An in-memory store — a Map with an LRU cap. The profiler without a store keeps reports in its own memory already, so this adds nothing there; it is for tests and a model for a custom store. Nothing survives a restart.

MemoryStore.kind

A name for the dashboard ("sqlite", "redis", "postgres", "memory").

MemoryStore.constructor

MemoryStore.putReport

Write (or overwrite) a report.

MemoryStore.getReport

Read a report's full dump JSON, or null when absent.

MemoryStore.listReports

The most recent reports (summaries), newest first.

MemoryStore.deleteReport

Remove a report.

MemoryStore.prune

Keep at most keep reports, dropping the oldest — the store's own LRU, called after a put.

MemoryStore.putVisit

MemoryStore.listVisits

class MemoryStore implements ProfilerStore {/*…*/}
readonly kind: string;
constructor(cap?: number);
putReport(rec: ProfilerRecord): void;
getReport(id: string): string | null;
listReports(limit?: number): ProfilerSummary[];
deleteReport(id: string): void;
prune(keep: number): void;
putVisit(rec: ProfilerVisitRecord): void;
listVisits(page: string, limit?: number): ProfilerVisitRecord[];

ProfilerRecord

interface

One report as a store holds it: summary columns for the list, and the portable dump as JSON.

ProfilerRecord.id

ProfilerRecord.created

epoch ms the report was created

ProfilerRecord.page

the profiled page (page mode), else null

ProfilerRecord.trigger

window | page | request | trap

ProfilerRecord.label

a human label for the list (the page, or the request path)

ProfilerRecord.median

the median render in ms (page mode), else null — shown in the list

ProfilerRecord.dump

the portable dump as a JSON string: { kind, version, meta, analysis, extras }

interface ProfilerRecord {/*…*/}
id: string;
created: number;
page: string | null;
trigger: string;
label: string;
median: number | null;
dump: string;

ProfilerStore

interface

The storage contract. Report methods are required; visit methods are optional (with a store that omits them, a server window sees only its own instance's requests). All async so a network backend fits; a memory or SQLite store just resolves immediately.

ProfilerStore.init

Called once before first use — create tables, connect, etc. Optional.

ProfilerStore.putReport

Write (or overwrite) a report.

ProfilerStore.getReport

Read a report's full dump JSON, or null when absent.

ProfilerStore.listReports

The most recent reports (summaries), newest first.

ProfilerStore.deleteReport

Remove a report.

ProfilerStore.prune

Keep at most keep reports, dropping the oldest — the store's own LRU, called after a put.

ProfilerStore.putVisit

ProfilerStore.listVisits

ProfilerStore.close

Release connections. Optional.

ProfilerStore.kind

A name for the dashboard ("sqlite", "redis", "postgres", "memory").

interface ProfilerStore {/*…*/}
init?(): Promise<void> | void;
putReport(rec: ProfilerRecord): Promise<void> | void;
getReport(id: string): Promise<string | null> | string | null;
listReports(limit?: number): Promise<ProfilerSummary[]> | ProfilerSummary[];
deleteReport(id: string): Promise<void> | void;
prune?(keep: number): Promise<void> | void;
putVisit?(rec: ProfilerVisitRecord): Promise<void> | void;
listVisits?(page: string, limit?: number): Promise<ProfilerVisitRecord[]> | ProfilerVisitRecord[];
close?(): Promise<void> | void;
readonly kind: string;

ProfilerVisitRecord

interface

One visit row, as a store holds it: today, one request of a server window, written by whichever instance served it and listed together under the window's page key. Optional to support.

ProfilerVisitRecord.key

unique per row (it starts with page)

ProfilerVisitRecord.page

ProfilerVisitRecord.at

epoch ms

ProfilerVisitRecord.visit

the visit payload as a JSON string

interface ProfilerVisitRecord {/*…*/}
key: string;
page: string;
at: number;
visit: string;

ProfilerSummary

type

What the list needs — every column of a record except the (large) dump.

type ProfilerSummary = Omit<ProfilerRecord, "dump">;