/** What the library was doing when counting failed. */ export type UsageFaultOperation = /** Reading a window (a cap, a rate limit, the spend ceiling). */ "read" /** Recording usage. A dropped event is usage counted by nothing. */ | "write" /** Resolving the meter or the scope customer a read/write needs. */ | "resolve"; /** What the library DID as a result — the part that decides whether a customer * was over-served, under-served, or unaffected. */ export type UsageFaultOutcome = /** Reported 0. The window does not apply: nothing is refused. */ "counted-zero" /** Reported the last value read successfully. Stale, but bounded and sane. */ | "used-last-known" /** Refused: the call was denied because usage could not be established. */ | "refused" /** The event was not recorded. That usage is now uncountable, permanently. */ | "dropped"; export interface UsageFault { operation: UsageFaultOperation; outcome: UsageFaultOutcome; error: unknown; orgId?: string; /** `org` / `k:` / `u:` when the fault belongs to one. */ scope?: string; /** The value served instead, when one was. */ served?: number; } export type UsageFaultHandler = (fault: UsageFault) => void; /** * Be told when a usage read or write fails, and what was served instead. * * ```ts * onUsageFault((f) => { * if (f.outcome === "counted-zero") metrics.increment("billing.uncounted"); * logger.error({ ...f }, "usage counting degraded"); * }); * ``` * * Returns an unsubscribe function. Registering ANY handler silences the built-in * console warning, on the assumption that a deployment which asked to be told has * somewhere better to put it. */ export declare function onUsageFault(handler: UsageFaultHandler): () => void; /** Test seam: drop every handler, and the once-per-process de-duplication. */ export declare function resetUsageFaults(): void; export declare function reportUsageFault(fault: UsageFault): void; //# sourceMappingURL=usage-faults.d.ts.map