aissue 0.0.0-stage → 2.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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +390 -2
  3. package/dist/cjs/browser.d.ts +16 -0
  4. package/dist/cjs/browser.js +80 -0
  5. package/dist/cjs/core/breadcrumbs.d.ts +48 -0
  6. package/dist/cjs/core/breadcrumbs.js +313 -0
  7. package/dist/cjs/core/client.d.ts +54 -0
  8. package/dist/cjs/core/client.js +293 -0
  9. package/dist/cjs/core/env.d.ts +19 -0
  10. package/dist/cjs/core/env.js +71 -0
  11. package/dist/cjs/core/event.d.ts +35 -0
  12. package/dist/cjs/core/event.js +187 -0
  13. package/dist/cjs/core/hub.d.ts +20 -0
  14. package/dist/cjs/core/hub.js +21 -0
  15. package/dist/cjs/core/instrument-browser.d.ts +16 -0
  16. package/dist/cjs/core/instrument-browser.js +208 -0
  17. package/dist/cjs/core/instrument-node.d.ts +5 -0
  18. package/dist/cjs/core/instrument-node.js +250 -0
  19. package/dist/cjs/core/instrument.d.ts +12 -0
  20. package/dist/cjs/core/instrument.js +137 -0
  21. package/dist/cjs/core/privacy.d.ts +25 -0
  22. package/dist/cjs/core/privacy.js +269 -0
  23. package/dist/cjs/core/stack.d.ts +13 -0
  24. package/dist/cjs/core/stack.js +147 -0
  25. package/dist/cjs/core/transport.d.ts +31 -0
  26. package/dist/cjs/core/transport.js +154 -0
  27. package/dist/cjs/core/types.d.ts +149 -0
  28. package/dist/cjs/core/types.js +2 -0
  29. package/dist/cjs/core/version.d.ts +2 -0
  30. package/dist/cjs/core/version.js +6 -0
  31. package/dist/cjs/index.d.ts +27 -0
  32. package/dist/cjs/index.js +83 -0
  33. package/dist/cjs/nextjs/client.d.ts +10 -0
  34. package/dist/cjs/nextjs/client.js +99 -0
  35. package/dist/cjs/nextjs/index.d.ts +31 -0
  36. package/dist/cjs/nextjs/index.js +99 -0
  37. package/dist/cjs/node.d.ts +48 -0
  38. package/dist/cjs/node.js +223 -0
  39. package/dist/cjs/package.json +3 -0
  40. package/dist/cjs/react.d.ts +40 -0
  41. package/dist/cjs/react.js +90 -0
  42. package/dist/esm/browser.d.ts +16 -0
  43. package/dist/esm/browser.js +71 -0
  44. package/dist/esm/cli.d.ts +2 -0
  45. package/dist/esm/cli.js +386 -0
  46. package/dist/esm/core/breadcrumbs.d.ts +48 -0
  47. package/dist/esm/core/breadcrumbs.js +296 -0
  48. package/dist/esm/core/client.d.ts +54 -0
  49. package/dist/esm/core/client.js +285 -0
  50. package/dist/esm/core/env.d.ts +19 -0
  51. package/dist/esm/core/env.js +62 -0
  52. package/dist/esm/core/event.d.ts +35 -0
  53. package/dist/esm/core/event.js +179 -0
  54. package/dist/esm/core/hub.d.ts +20 -0
  55. package/dist/esm/core/hub.js +17 -0
  56. package/dist/esm/core/instrument-browser.d.ts +16 -0
  57. package/dist/esm/core/instrument-browser.js +203 -0
  58. package/dist/esm/core/instrument-node.d.ts +5 -0
  59. package/dist/esm/core/instrument-node.js +214 -0
  60. package/dist/esm/core/instrument.d.ts +12 -0
  61. package/dist/esm/core/instrument.js +132 -0
  62. package/dist/esm/core/privacy.d.ts +25 -0
  63. package/dist/esm/core/privacy.js +257 -0
  64. package/dist/esm/core/stack.d.ts +13 -0
  65. package/dist/esm/core/stack.js +140 -0
  66. package/dist/esm/core/transport.d.ts +31 -0
  67. package/dist/esm/core/transport.js +149 -0
  68. package/dist/esm/core/types.d.ts +149 -0
  69. package/dist/esm/core/types.js +1 -0
  70. package/dist/esm/core/version.d.ts +2 -0
  71. package/dist/esm/core/version.js +3 -0
  72. package/dist/esm/index.d.ts +27 -0
  73. package/dist/esm/index.js +72 -0
  74. package/dist/esm/nextjs/client.d.ts +10 -0
  75. package/dist/esm/nextjs/client.js +90 -0
  76. package/dist/esm/nextjs/index.d.ts +31 -0
  77. package/dist/esm/nextjs/index.js +88 -0
  78. package/dist/esm/node.d.ts +48 -0
  79. package/dist/esm/node.js +210 -0
  80. package/dist/esm/react.d.ts +40 -0
  81. package/dist/esm/react.js +47 -0
  82. package/package.json +141 -4
@@ -0,0 +1,386 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * aissue CLI. Currently one command:
4
+ *
5
+ * aissue sourcemaps upload <dir> --release <release> --domain <domainId>
6
+ *
7
+ * Uploads every *.map file under <dir> to POST {host}/api/v1/domains/{domainId}/sourcemaps
8
+ * (one map per request, multipart/form-data: release, url, file). Node 18+, no dependencies.
9
+ */
10
+ import { readdir, readFile, stat, unlink, lstat } from 'node:fs/promises';
11
+ import { basename, join, posix, relative, resolve, sep } from 'node:path';
12
+ import { detectRelease, readEnv } from './core/env.js';
13
+ import { SDK_VERSION } from './core/version.js';
14
+ const DEFAULT_HOST = 'https://aissue.dev';
15
+ const UPLOAD_TIMEOUT_MS = 120000;
16
+ const JS_FILE_RE = /\.(?:m|c)?js$/i;
17
+ const USAGE = `Usage: aissue sourcemaps upload <dir> --release <release> --domain <domainId> [options]
18
+
19
+ Upload the JavaScript source maps (*.map) under <dir> to AIssue so that stack traces from
20
+ minified bundles point at your original source. Upload them for every release you deploy.
21
+
22
+ Options:
23
+ --release <release> Release the maps belong to. Must equal the release the SDK sends.
24
+ Default: the first env var set of AISSUE_RELEASE, VERCEL_GIT_COMMIT_SHA,
25
+ NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA, RENDER_GIT_COMMIT, RAILWAY_GIT_COMMIT_SHA,
26
+ HEROKU_SLUG_COMMIT, SOURCE_VERSION, CF_PAGES_COMMIT_SHA, GITHUB_SHA,
27
+ COMMIT_SHA, GIT_SHA, GIT_COMMIT.
28
+ --domain <domainId> AIssue domain id (default: AISSUE_DOMAIN).
29
+ --url-prefix <prefix> Prefix of the URL the minified files are served from (default "~/").
30
+ "~" matches any scheme and host, e.g. "~/assets" or "~/_next/static".
31
+ --host <url> AIssue host (default: AISSUE_HOST, then ${DEFAULT_HOST}).
32
+ --token <token> Account API token, aissue_pat_... (default: AISSUE_TOKEN).
33
+ --dry-run Show what would be uploaded; upload and delete nothing.
34
+ --delete-after Delete each .map file after it was uploaded (so maps are not deployed).
35
+ -h, --help Show this help.
36
+ -v, --version Show the version.
37
+
38
+ Each map is uploaded with url = <url-prefix> + its minified file's path relative to <dir>
39
+ (for example dist/assets/index-abc123.js.map -> ~/assets/index-abc123.js).
40
+
41
+ Exit codes: 0 all maps uploaded, 1 an upload failed (or no maps found), 2 invalid arguments.`;
42
+ class UsageError extends Error {
43
+ }
44
+ const VALUE_FLAGS = {
45
+ '--release': 'release',
46
+ '--domain': 'domain',
47
+ '--url-prefix': 'urlPrefix',
48
+ '--host': 'host',
49
+ '--token': 'token',
50
+ };
51
+ const BOOLEAN_FLAGS = {
52
+ '--dry-run': 'dryRun',
53
+ '--delete-after': 'deleteAfter',
54
+ };
55
+ function parseUploadArgs(args) {
56
+ const values = {};
57
+ const booleans = {};
58
+ const positional = [];
59
+ for (let i = 0; i < args.length; i++) {
60
+ const arg = args[i];
61
+ if (arg === '--') {
62
+ positional.push(...args.slice(i + 1));
63
+ break;
64
+ }
65
+ if (!arg.startsWith('-')) {
66
+ positional.push(arg);
67
+ continue;
68
+ }
69
+ if (!arg.startsWith('--'))
70
+ throw new UsageError(`Unknown option: ${arg}`);
71
+ const eq = arg.indexOf('=');
72
+ const flag = eq === -1 ? arg : arg.slice(0, eq);
73
+ if (flag in BOOLEAN_FLAGS) {
74
+ if (eq !== -1)
75
+ throw new UsageError(`${flag} takes no value`);
76
+ booleans[BOOLEAN_FLAGS[flag]] = true;
77
+ }
78
+ else if (flag in VALUE_FLAGS) {
79
+ let value;
80
+ if (eq !== -1)
81
+ value = arg.slice(eq + 1);
82
+ else {
83
+ value = args[i + 1];
84
+ i++;
85
+ }
86
+ if (value === undefined || (eq === -1 && value.startsWith('--')))
87
+ throw new UsageError(`${flag} needs a value`);
88
+ values[VALUE_FLAGS[flag]] = value;
89
+ }
90
+ else {
91
+ throw new UsageError(`Unknown option: ${flag}`);
92
+ }
93
+ }
94
+ if (positional.length === 0)
95
+ throw new UsageError('Missing <dir>: the directory that contains your built files.');
96
+ if (positional.length > 1)
97
+ throw new UsageError(`Unexpected argument: ${positional[1]}`);
98
+ const release = (values.release ?? '').trim() || detectRelease();
99
+ if (!release) {
100
+ throw new UsageError('Missing --release (and no release env var such as AISSUE_RELEASE or GITHUB_SHA is set).');
101
+ }
102
+ const domain = (values.domain ?? '').trim() || readEnv('AISSUE_DOMAIN');
103
+ if (!domain)
104
+ throw new UsageError('Missing --domain <domainId> (or AISSUE_DOMAIN).');
105
+ const host = ((values.host ?? '').trim() || readEnv('AISSUE_HOST') || DEFAULT_HOST).replace(/\/+$/, '');
106
+ if (!/^https?:\/\/[^/]+/i.test(host))
107
+ throw new UsageError(`--host must be an http(s) URL, got "${host}"`);
108
+ const token = (values.token ?? '').trim() || readEnv('AISSUE_TOKEN');
109
+ const dryRun = !!booleans.dryRun;
110
+ if (!token && !dryRun)
111
+ throw new UsageError('Missing --token (or AISSUE_TOKEN): an account API token (aissue_pat_...).');
112
+ return {
113
+ dir: positional[0],
114
+ release,
115
+ domain,
116
+ urlPrefix: values.urlPrefix ?? '~/',
117
+ host,
118
+ token,
119
+ dryRun,
120
+ deleteAfter: !!booleans.deleteAfter,
121
+ };
122
+ }
123
+ /** Every *.map file under `dir` (symlinked directories are not followed), sorted. */
124
+ async function findMaps(dir) {
125
+ const found = [];
126
+ async function walk(current) {
127
+ const entries = await readdir(current, { withFileTypes: true });
128
+ for (const entry of entries) {
129
+ const full = join(current, entry.name);
130
+ if (entry.isDirectory()) {
131
+ if (entry.name === 'node_modules')
132
+ continue;
133
+ await walk(full);
134
+ }
135
+ else if (entry.name.endsWith('.map')) {
136
+ if (entry.isFile())
137
+ found.push(full);
138
+ else if (entry.isSymbolicLink()) {
139
+ try {
140
+ if ((await stat(full)).isFile())
141
+ found.push(full);
142
+ }
143
+ catch {
144
+ // dangling link
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ await walk(dir);
151
+ return found.sort();
152
+ }
153
+ function toPosix(path) {
154
+ return path.split(sep).join('/');
155
+ }
156
+ async function exists(path) {
157
+ try {
158
+ return (await lstat(path)).isFile() || (await stat(path)).isFile();
159
+ }
160
+ catch {
161
+ return false;
162
+ }
163
+ }
164
+ /** Path (relative to the root, posix) of the minified file a map belongs to. */
165
+ async function minifiedPath(root, mapPath, mapFileField) {
166
+ const relMap = toPosix(relative(root, mapPath));
167
+ const stripped = relMap.slice(0, -'.map'.length);
168
+ if (await exists(join(root, stripped)))
169
+ return stripped;
170
+ if (typeof mapFileField === 'string' && mapFileField && !/^[a-z][a-z0-9+.-]*:/i.test(mapFileField)) {
171
+ // The map's own `file` is relative to the map's directory.
172
+ const candidate = posix.normalize(posix.join(posix.dirname(relMap), mapFileField.replace(/\\/g, '/')));
173
+ if (!candidate.startsWith('../') && !posix.isAbsolute(candidate) && candidate !== '..') {
174
+ if ((await exists(join(root, candidate))) || !JS_FILE_RE.test(stripped))
175
+ return candidate;
176
+ }
177
+ }
178
+ return stripped;
179
+ }
180
+ function joinUrl(prefix, path) {
181
+ if (!prefix)
182
+ return path;
183
+ return prefix.endsWith('/') ? prefix + path : `${prefix}/${path}`;
184
+ }
185
+ function formatSize(bytes) {
186
+ if (bytes < 1024)
187
+ return `${bytes} B`;
188
+ if (bytes < 1024 * 1024)
189
+ return `${(bytes / 1024).toFixed(1)} KB`;
190
+ return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
191
+ }
192
+ async function errorMessage(response) {
193
+ try {
194
+ const text = await response.text();
195
+ try {
196
+ const json = JSON.parse(text);
197
+ if (typeof json.error === 'string')
198
+ return json.error;
199
+ if (typeof json.detail === 'string')
200
+ return json.detail;
201
+ }
202
+ catch {
203
+ // not JSON
204
+ }
205
+ return text.trim().slice(0, 200) || response.statusText || 'request failed';
206
+ }
207
+ catch {
208
+ return response.statusText || 'request failed';
209
+ }
210
+ }
211
+ /** Upload all maps. Returns the process exit code. */
212
+ async function uploadSourcemaps(options, io) {
213
+ const root = resolve(options.dir);
214
+ let rootStat;
215
+ try {
216
+ rootStat = await stat(root);
217
+ }
218
+ catch {
219
+ io.err(`error: directory not found: ${options.dir}`);
220
+ return 1;
221
+ }
222
+ if (!rootStat.isDirectory()) {
223
+ io.err(`error: not a directory: ${options.dir}`);
224
+ return 1;
225
+ }
226
+ const maps = await findMaps(root);
227
+ if (maps.length === 0) {
228
+ io.err(`error: no .map files found in ${options.dir}. Build with source maps enabled first.`);
229
+ return 1;
230
+ }
231
+ const endpoint = `${options.host}/api/v1/domains/${encodeURIComponent(options.domain)}/sourcemaps`;
232
+ io.out(`${options.dryRun ? '[dry run] would upload' : 'Uploading'} ${maps.length} source map${maps.length === 1 ? '' : 's'} ` +
233
+ `for release ${options.release} to domain ${options.domain} (${options.host})`);
234
+ let uploaded = 0;
235
+ let failed = 0;
236
+ let skipped = 0;
237
+ let deleted = 0;
238
+ let notAttempted = 0;
239
+ let aborted;
240
+ for (const mapPath of maps) {
241
+ const relMap = toPosix(relative(root, mapPath));
242
+ if (aborted) {
243
+ notAttempted++;
244
+ continue;
245
+ }
246
+ let content;
247
+ let parsed;
248
+ try {
249
+ content = await readFile(mapPath);
250
+ parsed = JSON.parse(content.toString('utf8'));
251
+ if (!parsed || typeof parsed !== 'object' || (typeof parsed.mappings !== 'string' && !Array.isArray(parsed.sections))) {
252
+ throw new Error('not a source map (no "mappings")');
253
+ }
254
+ }
255
+ catch (error) {
256
+ failed++;
257
+ io.err(` failed ${relMap}: invalid source map (${error instanceof Error ? error.message : 'unreadable'})`);
258
+ continue;
259
+ }
260
+ const target = await minifiedPath(root, mapPath, parsed.file);
261
+ if (!JS_FILE_RE.test(target)) {
262
+ skipped++;
263
+ io.out(` skipped ${relMap} (not a JavaScript file: ${target})`);
264
+ continue;
265
+ }
266
+ const url = joinUrl(options.urlPrefix, target);
267
+ if (options.dryRun) {
268
+ uploaded++;
269
+ io.out(` would upload ${relMap} -> ${url} (${formatSize(content.length)})${options.deleteAfter ? ', then delete it' : ''}`);
270
+ continue;
271
+ }
272
+ try {
273
+ const form = new FormData();
274
+ form.append('release', options.release);
275
+ form.append('url', url);
276
+ form.append('file', new Blob([new Uint8Array(content)], { type: 'application/json' }), basename(mapPath));
277
+ const response = await fetch(endpoint, {
278
+ method: 'POST',
279
+ headers: { Authorization: `Bearer ${options.token}`, 'User-Agent': `aissue-cli/${SDK_VERSION}` },
280
+ body: form,
281
+ signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS),
282
+ });
283
+ if (response.status >= 200 && response.status < 300) {
284
+ uploaded++;
285
+ let size = content.length;
286
+ try {
287
+ const body = (await response.json());
288
+ if (typeof body.size === 'number')
289
+ size = body.size;
290
+ }
291
+ catch {
292
+ // body is optional
293
+ }
294
+ io.out(` uploaded ${relMap} -> ${url} (${formatSize(size)})`);
295
+ if (options.deleteAfter) {
296
+ try {
297
+ await unlink(mapPath);
298
+ deleted++;
299
+ }
300
+ catch (error) {
301
+ io.err(` warning could not delete ${relMap}: ${error instanceof Error ? error.message : error}`);
302
+ }
303
+ }
304
+ continue;
305
+ }
306
+ failed++;
307
+ const message = await errorMessage(response);
308
+ io.err(` failed ${relMap} -> ${url}: HTTP ${response.status} ${message}`);
309
+ if (response.status === 401 || response.status === 403 || response.status === 404) {
310
+ aborted =
311
+ response.status === 404
312
+ ? `domain ${options.domain} not found (or the token cannot see it)`
313
+ : 'the token was rejected; check --token / AISSUE_TOKEN (an account API token, aissue_pat_...)';
314
+ io.err(`error: ${aborted}. Stopping.`);
315
+ }
316
+ }
317
+ catch (error) {
318
+ failed++;
319
+ const reason = error instanceof Error ? (error.name === 'TimeoutError' ? 'timed out' : error.message) : String(error);
320
+ io.err(` failed ${relMap} -> ${url}: ${reason}`);
321
+ }
322
+ }
323
+ const parts = [`${uploaded} ${options.dryRun ? 'would be uploaded' : 'uploaded'}`];
324
+ if (failed)
325
+ parts.push(`${failed} failed`);
326
+ if (skipped)
327
+ parts.push(`${skipped} skipped`);
328
+ if (notAttempted)
329
+ parts.push(`${notAttempted} not attempted`);
330
+ if (deleted)
331
+ parts.push(`${deleted} deleted`);
332
+ const ok = failed === 0 && notAttempted === 0;
333
+ const summary = `${ok ? 'Done' : 'Done with errors'}: ${parts.join(', ')} (release ${options.release}).`;
334
+ (ok ? io.out : io.err)(summary);
335
+ return ok ? 0 : 1;
336
+ }
337
+ /** Run the CLI with argv (without "node" and the script). Returns the exit code. */
338
+ async function main(argv, io) {
339
+ const [command, sub, ...rest] = argv;
340
+ if (!command || command === '-h' || command === '--help' || command === 'help') {
341
+ io.out(USAGE);
342
+ return command ? 0 : 2;
343
+ }
344
+ if (command === '-v' || command === '--version') {
345
+ io.out(SDK_VERSION);
346
+ return 0;
347
+ }
348
+ if (command !== 'sourcemaps') {
349
+ io.err(`error: unknown command "${command}"\n\n${USAGE}`);
350
+ return 2;
351
+ }
352
+ if (sub === '-h' || sub === '--help' || (sub === 'upload' && (rest.includes('-h') || rest.includes('--help')))) {
353
+ io.out(USAGE);
354
+ return 0;
355
+ }
356
+ if (sub !== 'upload') {
357
+ io.err(`error: ${sub ? `unknown command "sourcemaps ${sub}"` : 'missing command "sourcemaps upload"'}\n\n${USAGE}`);
358
+ return 2;
359
+ }
360
+ let options;
361
+ try {
362
+ options = parseUploadArgs(rest);
363
+ }
364
+ catch (error) {
365
+ if (error instanceof UsageError) {
366
+ io.err(`error: ${error.message}\n\nRun "aissue sourcemaps upload --help" for usage.`);
367
+ return 2;
368
+ }
369
+ throw error;
370
+ }
371
+ if (typeof fetch !== 'function' || typeof FormData !== 'function' || typeof Blob !== 'function') {
372
+ io.err('error: Node 18 or newer is required (global fetch / FormData / Blob).');
373
+ return 1;
374
+ }
375
+ return uploadSourcemaps(options, io);
376
+ }
377
+ const io = {
378
+ out: (line) => process.stdout.write(line + '\n'),
379
+ err: (line) => process.stderr.write(line + '\n'),
380
+ };
381
+ main(process.argv.slice(2), io).then((code) => {
382
+ process.exitCode = code;
383
+ }, (error) => {
384
+ io.err(`error: ${error instanceof Error ? error.message : String(error)}`);
385
+ process.exitCode = 1;
386
+ });
@@ -0,0 +1,48 @@
1
+ import type { Breadcrumb, BreadcrumbInput, BreadcrumbLevel } from './types.js';
2
+ export declare const DEFAULT_MAX_BREADCRUMBS = 50;
3
+ /** Protocol limit: at most 100 breadcrumbs per event. */
4
+ export declare const MAX_BREADCRUMBS = 100;
5
+ export declare const MAX_BREADCRUMB_MESSAGE = 1000;
6
+ /** Which automatic breadcrumb sources are on (all by default). */
7
+ export type AutoBreadcrumbKind = 'console' | 'clicks' | 'fetch' | 'xhr' | 'navigation' | 'http';
8
+ /** Where the current breadcrumbs live: per request (Node AsyncLocalStorage) or the global buffer. */
9
+ export interface BreadcrumbStorage {
10
+ getStore(): Breadcrumb[] | undefined;
11
+ run<T>(store: Breadcrumb[], fn: () => T): T;
12
+ }
13
+ /** Cut to `max` characters, ellipsis included. */
14
+ export declare function clip(value: string, max: number): string;
15
+ /** Short, safe text for any value (used for console arguments and nested data values). */
16
+ export declare function describeValue(value: unknown, max?: number): string;
17
+ /**
18
+ * Turn user or instrumentation input into a protocol breadcrumb: valid type / level, ISO timestamp,
19
+ * message <= 1000 chars, flat data (<= 20 keys). Sensitive keys and secrets / emails in strings are filtered.
20
+ */
21
+ export declare function normalizeBreadcrumb(input: BreadcrumbInput | null | undefined): Breadcrumb | null;
22
+ /** The buffer breadcrumbs go to right now: the current request's (Node) or the global one. */
23
+ export declare function currentBuffer(): Breadcrumb[];
24
+ /** True when a client is enabled and keeps breadcrumbs (optionally: and this automatic source is on). */
25
+ export declare function breadcrumbsActive(kind?: AutoBreadcrumbKind): boolean;
26
+ /**
27
+ * Store a breadcrumb in `buffer` (default: the current one). Runs beforeBreadcrumb.
28
+ * Never throws; ignored when the SDK is disabled or while another breadcrumb is being recorded
29
+ * (so a console.log inside beforeBreadcrumb cannot loop).
30
+ */
31
+ export declare function recordBreadcrumb(input: BreadcrumbInput, buffer?: Breadcrumb[]): void;
32
+ /** Copy of the current breadcrumbs (oldest first) for an event. */
33
+ export declare function snapshotBreadcrumbs(): Breadcrumb[];
34
+ /** Empty the current buffer (the current request's in Node, otherwise the global one). */
35
+ export declare function clearCurrentBreadcrumbs(): void;
36
+ /** Run `fn` with its own, empty breadcrumb buffer (Node AsyncLocalStorage); plain call elsewhere. */
37
+ export declare function runWithBreadcrumbScope<T>(fn: () => T): T;
38
+ export declare function isWrapped(fn: unknown): boolean;
39
+ /**
40
+ * Mark `wrapper` as ours and copy the original's own properties (e.g. Next.js' `__nextPatched` on fetch)
41
+ * so code that inspects the function keeps working.
42
+ */
43
+ export declare function markWrapped<T extends Function>(wrapper: T, original: Function): T;
44
+ /** Replace obj[name] with makeWrapper(original) unless it is already our wrapper. Never throws. */
45
+ export declare function wrapMethod(obj: unknown, name: string, makeWrapper: (original: Function) => Function): boolean;
46
+ /** True for URLs that point at the AIssue host itself (the SDK's own requests). */
47
+ export declare function isAIssueUrl(url: string): boolean;
48
+ export declare function levelForStatus(status: number | undefined): BreadcrumbLevel;