@lightworkai.official/debug-capture 0.6.0
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.
- package/README.md +241 -0
- package/dist/budget.d.ts +22 -0
- package/dist/bundle.d.ts +20 -0
- package/dist/capture/actionTrail.d.ts +7 -0
- package/dist/capture/cause.d.ts +3 -0
- package/dist/capture/consoleBuffer.d.ts +4 -0
- package/dist/capture/crashWatcher.d.ts +1 -0
- package/dist/capture/networkBuffer.d.ts +4 -0
- package/dist/capture/redact.d.ts +9 -0
- package/dist/capture/stepCorrelation.d.ts +41 -0
- package/dist/config.d.ts +217 -0
- package/dist/context.d.ts +2 -0
- package/dist/debug-capture.js +116 -0
- package/dist/embed.d.ts +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.mjs +129 -0
- package/dist/install.d.ts +5 -0
- package/dist/mytickets/api.d.ts +115 -0
- package/dist/mytickets/format.d.ts +84 -0
- package/dist/mytickets/sanitize.d.ts +66 -0
- package/dist/mytickets/strings.d.ts +74 -0
- package/dist/mytickets/toolbar.d.ts +17 -0
- package/dist/reporter.d.ts +27 -0
- package/dist/screenshot.d.ts +7 -0
- package/dist/signature.d.ts +18 -0
- package/dist/submit.d.ts +8 -0
- package/dist/types.d.ts +175 -0
- package/dist/ui/annotator.d.ts +34 -0
- package/dist/ui/arrow.d.ts +25 -0
- package/dist/ui/element.d.ts +9 -0
- package/dist/ui/strings.d.ts +42 -0
- package/dist/ui/styles.d.ts +13 -0
- package/dist/ui/toast.d.ts +11 -0
- package/package.json +53 -0
- package/src/budget.ts +62 -0
- package/src/bundle.ts +274 -0
- package/src/capture/actionTrail.ts +693 -0
- package/src/capture/cause.ts +49 -0
- package/src/capture/consoleBuffer.ts +80 -0
- package/src/capture/crashWatcher.ts +61 -0
- package/src/capture/networkBuffer.ts +315 -0
- package/src/capture/redact.ts +117 -0
- package/src/capture/stepCorrelation.ts +160 -0
- package/src/config.ts +299 -0
- package/src/context.ts +81 -0
- package/src/embed.ts +35 -0
- package/src/index.ts +109 -0
- package/src/install.ts +59 -0
- package/src/mytickets/api.ts +226 -0
- package/src/mytickets/format.ts +191 -0
- package/src/mytickets/sanitize.ts +221 -0
- package/src/mytickets/strings.ts +217 -0
- package/src/mytickets/toolbar.ts +48 -0
- package/src/reporter.ts +53 -0
- package/src/screenshot.ts +238 -0
- package/src/signature.ts +40 -0
- package/src/styles.css +400 -0
- package/src/submit.ts +143 -0
- package/src/types.ts +169 -0
- package/src/ui/annotator.ts +698 -0
- package/src/ui/arrow.ts +62 -0
- package/src/ui/element.ts +362 -0
- package/src/ui/strings.ts +113 -0
- package/src/ui/styles.ts +96 -0
- package/src/ui/toast.ts +138 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape of a debug bundle.
|
|
3
|
+
*
|
|
4
|
+
* A bundle is a redacted, client-side snapshot of what the user was doing when
|
|
5
|
+
* something went wrong — recent network requests, console output, the trail of
|
|
6
|
+
* actions that led there, page/session context, a cause summary, and a
|
|
7
|
+
* screenshot. It is assembled entirely in the browser so support can reproduce
|
|
8
|
+
* an issue without a round of "what were you clicking".
|
|
9
|
+
*
|
|
10
|
+
* What changed on the way out of the original in-app reporter: anything that
|
|
11
|
+
* described ONE app — a Thai unit hierarchy, a permission-bypass dev flag, a
|
|
12
|
+
* fixed module vocabulary — is gone. Those arrive through config now, because a
|
|
13
|
+
* library that ships another company's org chart is not a library.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export type CaptureVia = "fetch" | "xhr";
|
|
17
|
+
|
|
18
|
+
export interface CapturedRequest {
|
|
19
|
+
id: string;
|
|
20
|
+
/** ISO timestamp when the request started. */
|
|
21
|
+
startedAt: string;
|
|
22
|
+
method: string;
|
|
23
|
+
/** Redacted URL (sensitive query params masked). */
|
|
24
|
+
url: string;
|
|
25
|
+
/** Redacted request headers. */
|
|
26
|
+
requestHeaders: Record<string, string>;
|
|
27
|
+
/** Redacted + truncated request body (JSON string / marker / null). */
|
|
28
|
+
requestBody: string | null;
|
|
29
|
+
status: number | null;
|
|
30
|
+
statusText: string | null;
|
|
31
|
+
/** Redacted response headers. */
|
|
32
|
+
responseHeaders?: Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Redacted response body, in full up to a per-response cap — not a snippet.
|
|
35
|
+
* Only captured for origins the consumer allowed: see `capture.bodyOrigins`.
|
|
36
|
+
*/
|
|
37
|
+
responseSnippet?: string | null;
|
|
38
|
+
durationMs: number | null;
|
|
39
|
+
/** Populated when the request rejected (network error / abort). */
|
|
40
|
+
error?: string;
|
|
41
|
+
via: CaptureVia;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ConsoleLevel = "log" | "info" | "warn" | "error" | "debug";
|
|
45
|
+
export type ConsoleEntryKind = ConsoleLevel | "exception" | "unhandledrejection";
|
|
46
|
+
|
|
47
|
+
export interface CapturedConsoleEntry {
|
|
48
|
+
id: string;
|
|
49
|
+
at: string;
|
|
50
|
+
level: ConsoleEntryKind;
|
|
51
|
+
/** Human-readable, truncated message. */
|
|
52
|
+
message: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type ActionKind = "click" | "input" | "navigate" | "submit" | "ui";
|
|
56
|
+
|
|
57
|
+
export interface ActionTrailEntry {
|
|
58
|
+
id: string;
|
|
59
|
+
at: string;
|
|
60
|
+
kind: ActionKind;
|
|
61
|
+
/** Human-readable description, e.g. `click ปุ่ม "บันทึกร่าง"`. */
|
|
62
|
+
detail: string;
|
|
63
|
+
/** Consecutive identical actions are collapsed; this is how many. */
|
|
64
|
+
count?: number;
|
|
65
|
+
/** Where a click leads — from the link's href or the nearest click target. */
|
|
66
|
+
source?: string;
|
|
67
|
+
/**
|
|
68
|
+
* A small, sanitized+redacted `outerHTML` of the clicked element, so a reader
|
|
69
|
+
* can see the ACTUAL control rather than a text label. Omitted when too large.
|
|
70
|
+
*
|
|
71
|
+
* MUST be re-sanitized before rendering. It is attacker-influenced markup that
|
|
72
|
+
* has travelled between origins.
|
|
73
|
+
*/
|
|
74
|
+
html?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The same control a moment later, once it visibly changed — disabled, busy,
|
|
77
|
+
* relabelled, or gone. A button's resting state says what was pressed; this
|
|
78
|
+
* says what pressing it DID, which is the half that was missing.
|
|
79
|
+
*/
|
|
80
|
+
afterHtml?: string;
|
|
81
|
+
/** One-line summary of that change, present even if `afterHtml` was dropped. */
|
|
82
|
+
afterNote?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type DebugReasonType = "manual" | "runtime-error" | "unhandledrejection" | "framework-error";
|
|
86
|
+
|
|
87
|
+
export interface DebugReason {
|
|
88
|
+
type: DebugReasonType;
|
|
89
|
+
message?: string;
|
|
90
|
+
stack?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A failed data-layer query the host chose to report (react-query, Apollo, …). */
|
|
94
|
+
export interface ErroredQuery {
|
|
95
|
+
key: string;
|
|
96
|
+
error: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface FailedRequestSummary {
|
|
100
|
+
method: string;
|
|
101
|
+
url: string;
|
|
102
|
+
status: number | null;
|
|
103
|
+
error?: string;
|
|
104
|
+
at: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The "smoking gun" — surfaced at the top of the report. */
|
|
108
|
+
export interface CauseSummary {
|
|
109
|
+
failedRequests: FailedRequestSummary[];
|
|
110
|
+
errors: string[];
|
|
111
|
+
erroredQueries: ErroredQuery[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Who was using the app. Every field optional: the library cannot know what a
|
|
116
|
+
* host knows about its users, and a half-filled identity is worth more than a
|
|
117
|
+
* shape the host has to lie to satisfy.
|
|
118
|
+
*/
|
|
119
|
+
export interface DebugUser {
|
|
120
|
+
id?: string | null;
|
|
121
|
+
email?: string | null;
|
|
122
|
+
fullName?: string | null;
|
|
123
|
+
/** Department / unit / team — whatever the host calls the thing. */
|
|
124
|
+
unit?: string | null;
|
|
125
|
+
roles?: string[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface DebugContext {
|
|
129
|
+
capturedAt: string;
|
|
130
|
+
route: { href: string; pathname: string; search: string };
|
|
131
|
+
/** Which part of the app this was, when the host declares one. */
|
|
132
|
+
module: { key: string; label: string } | null;
|
|
133
|
+
user: DebugUser;
|
|
134
|
+
/** Host-supplied request headers, redacted. Acting-as context and the like. */
|
|
135
|
+
apiHeaders: Record<string, string>;
|
|
136
|
+
app: { name: string; version: string; environment: string };
|
|
137
|
+
client: {
|
|
138
|
+
userAgent: string;
|
|
139
|
+
language: string;
|
|
140
|
+
platform: string;
|
|
141
|
+
online: boolean;
|
|
142
|
+
viewport: { width: number; height: number; dpr: number };
|
|
143
|
+
screen: { width: number; height: number };
|
|
144
|
+
};
|
|
145
|
+
performance: {
|
|
146
|
+
memoryUsedMb: number | null;
|
|
147
|
+
memoryLimitMb: number | null;
|
|
148
|
+
domContentLoadedMs: number | null;
|
|
149
|
+
loadEventMs: number | null;
|
|
150
|
+
};
|
|
151
|
+
/** Anything else the host wants on the record — feature flags, build id, … */
|
|
152
|
+
extra: Record<string, unknown>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type ScreenshotMethod = "display-media" | "html-to-image" | "none" | "cancelled";
|
|
156
|
+
|
|
157
|
+
export interface DebugBundle {
|
|
158
|
+
context: DebugContext;
|
|
159
|
+
reason: DebugReason;
|
|
160
|
+
note: string;
|
|
161
|
+
cause: CauseSummary;
|
|
162
|
+
actionTrail: ActionTrailEntry[];
|
|
163
|
+
network: CapturedRequest[];
|
|
164
|
+
console: CapturedConsoleEntry[];
|
|
165
|
+
/** PNG data URL, or null if capture failed / was skipped. */
|
|
166
|
+
screenshotDataUrl: string | null;
|
|
167
|
+
screenshotMethod: ScreenshotMethod;
|
|
168
|
+
meta: { generatedBy: string; schemaVersion: number };
|
|
169
|
+
}
|