@snapfail/browser 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ import type { CollectPayload, ConsoleEntry, NetworkEntry, ReplayEvent } from "@snapfail/protocol";
2
+ import type { CapturedError } from "./collectors/errors.ts";
3
+ export interface SnapfailConfig {
4
+ projectKey: string;
5
+ endpoint: string;
6
+ environment: "dev" | "prod";
7
+ bufferSeconds?: number;
8
+ }
9
+ export declare function buildPayload(config: SnapfailConfig, error: CapturedError, buffers: {
10
+ console: ConsoleEntry[];
11
+ network: NetworkEntry[];
12
+ replay: ReplayEvent[];
13
+ }): CollectPayload;
14
+ export declare function buildNormalizedMessage(message: string): string;
@@ -0,0 +1,14 @@
1
+ export type WithTimestamp<T> = T & {
2
+ timestamp: number;
3
+ };
4
+ export declare class RingBuffer<T extends {
5
+ timestamp: number;
6
+ }> {
7
+ private readonly windowMs;
8
+ private events;
9
+ constructor(windowMs: number);
10
+ push(event: T): void;
11
+ snapshot(): T[];
12
+ flush(): T[];
13
+ clear(): void;
14
+ }
@@ -0,0 +1,3 @@
1
+ import type { ConsoleEntry } from "@snapfail/protocol";
2
+ import { RingBuffer } from "../buffer.ts";
3
+ export declare function attachConsoleCollector(buffer: RingBuffer<ConsoleEntry>): () => void;
@@ -0,0 +1,7 @@
1
+ import type { StackFrame } from "@snapfail/protocol";
2
+ export interface CapturedError {
3
+ type: string;
4
+ message: string;
5
+ stack: StackFrame[];
6
+ }
7
+ export declare function attachErrorCollector(onError: (e: CapturedError) => void): () => void;
@@ -0,0 +1,5 @@
1
+ import type { NetworkEntry } from "@snapfail/protocol";
2
+ import { RingBuffer, type WithTimestamp } from "../buffer.ts";
3
+ type BufferedNetworkEntry = WithTimestamp<NetworkEntry>;
4
+ export declare function attachNetworkCollector(buffer: RingBuffer<BufferedNetworkEntry>): () => void;
5
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ReplayEvent } from "@snapfail/protocol";
2
+ import { RingBuffer, type WithTimestamp } from "../buffer.ts";
3
+ type BufferedReplayEvent = WithTimestamp<ReplayEvent>;
4
+ export declare function attachReplayCollector(buffer: RingBuffer<BufferedReplayEvent>): () => void;
5
+ export {};
@@ -0,0 +1,7 @@
1
+ import { type SnapfailConfig } from "./assembler.ts";
2
+ export type { SnapfailConfig };
3
+ export interface SnapfailInstance {
4
+ capture(error: unknown): void;
5
+ destroy(): void;
6
+ }
7
+ export declare function initSnapfail(config: SnapfailConfig): SnapfailInstance;