tracebck-sdk 0.3.1 → 0.4.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,82 @@
1
+ /**
2
+ * Captured network request event passed to `sanitizeRequest`.
3
+ * Return the (modified) event to keep it, or `null` / `undefined` to drop it.
4
+ */
5
+ export interface NetworkEvent {
6
+ method: string;
7
+ url: string;
8
+ statusCode: number;
9
+ startTime: number;
10
+ /** Duration in milliseconds */
11
+ duration: number;
12
+ requestHeaders: Record<string, string>;
13
+ requestBody: string | null;
14
+ requestBodyTruncated: boolean;
15
+ responseHeaders?: Record<string, string>;
16
+ responseBody?: string | null;
17
+ responseBodyTruncated?: boolean;
18
+ /** Present only when the request failed */
19
+ error?: string;
20
+ initiator: "fetch" | "xhr";
21
+ }
22
+
23
+ export interface InitOptions {
24
+ /** Your project API key (starts with `sk_`). Required. */
25
+ apiKey: string;
26
+ /** Milliseconds between automatic event flushes. Default: `5000`. */
27
+ flushInterval?: number;
28
+ /** Mask all input field values in the recording. Default: `false`. */
29
+ maskAllInputs?: boolean;
30
+ /** Capture network requests (fetch & XHR). Default: `true`. */
31
+ captureNetwork?: boolean;
32
+ /** Capture console output (log, warn, error, info, debug) and uncaught errors. Default: `true`. */
33
+ captureConsole?: boolean;
34
+ /** URL patterns to exclude from network capture. Strings use `includes()`, RegExp uses `test()`. */
35
+ networkDenyUrls?: (string | RegExp)[];
36
+ /** Hook to redact or drop captured network events before they are recorded. Return `null` to drop. */
37
+ sanitizeRequest?: (event: NetworkEvent) => NetworkEvent | null;
38
+ /** Extra rrweb `record()` options, spread into the recorder config. */
39
+ options?: Record<string, unknown>;
40
+ }
41
+
42
+ export interface SessionIdentifier {
43
+ /** Identifier type. Default: `"custom"`. */
44
+ type?: "email" | "custom";
45
+ /** Identifier value. Required. */
46
+ value: string;
47
+ }
48
+
49
+ export interface StartSessionOptions {
50
+ /** How to identify the user being recorded. `value` is required. */
51
+ identifier: SessionIdentifier;
52
+ /** Extra metadata attached to the session (merged with auto-collected browser info). */
53
+ metadata?: Record<string, unknown>;
54
+ }
55
+
56
+ /**
57
+ * Initialize the Tracebck SDK. Must be called before `startSession()`.
58
+ *
59
+ * @example
60
+ * ```js
61
+ * Tracebck.init({ apiKey: 'sk_...' });
62
+ * ```
63
+ */
64
+ export function init(options: InitOptions): void;
65
+
66
+ /**
67
+ * Start a recording session. Automatically stops any previous active session.
68
+ *
69
+ * @example
70
+ * ```js
71
+ * await Tracebck.startSession({
72
+ * identifier: { type: 'email', value: 'user@example.com' },
73
+ * metadata: { plan: 'pro' },
74
+ * });
75
+ * ```
76
+ */
77
+ export function startSession(options: StartSessionOptions): Promise<void>;
78
+
79
+ /**
80
+ * Stop the current recording session, flush remaining events, and notify the API.
81
+ */
82
+ export function stopSession(): Promise<void>;