@starko-one/sdk 0.0.0-stage → 0.1.0-beta.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 (108) hide show
  1. package/CHANGELOG.md +248 -0
  2. package/LICENSE +17 -0
  3. package/NOTICE +58 -0
  4. package/README.md +81 -2
  5. package/dist/api-BAFm4Lxj.d.ts +558 -0
  6. package/dist/api-DNrctwJu.d.cts +558 -0
  7. package/dist/browser/index.cjs +168 -0
  8. package/dist/browser/index.d.cts +131 -0
  9. package/dist/browser/index.d.ts +131 -0
  10. package/dist/browser/index.js +7 -0
  11. package/dist/build/rollup.cjs +22 -0
  12. package/dist/build/rollup.d.cts +34 -0
  13. package/dist/build/rollup.d.ts +34 -0
  14. package/dist/build/rollup.js +3 -0
  15. package/dist/build/vite.cjs +51 -0
  16. package/dist/build/vite.d.cts +23 -0
  17. package/dist/build/vite.d.ts +23 -0
  18. package/dist/build/vite.js +46 -0
  19. package/dist/build/webpack.cjs +18 -0
  20. package/dist/build/webpack.d.cts +39 -0
  21. package/dist/build/webpack.d.ts +39 -0
  22. package/dist/build/webpack.js +3 -0
  23. package/dist/chunk-2PM4FRM5.cjs +431 -0
  24. package/dist/chunk-335HNCOJ.js +249 -0
  25. package/dist/chunk-3AW5B2WW.js +115 -0
  26. package/dist/chunk-3R5TQAWD.js +216 -0
  27. package/dist/chunk-6H5MOPTQ.cjs +1230 -0
  28. package/dist/chunk-7TKNT3QJ.cjs +2487 -0
  29. package/dist/chunk-A4WLNFMU.cjs +220 -0
  30. package/dist/chunk-ALYFFOPR.cjs +134 -0
  31. package/dist/chunk-BVVFVRMO.js +1113 -0
  32. package/dist/chunk-CIHNKN62.cjs +15 -0
  33. package/dist/chunk-CMGCH6HD.js +1212 -0
  34. package/dist/chunk-D6QAPQ7L.cjs +56 -0
  35. package/dist/chunk-DUO5V6WZ.js +213 -0
  36. package/dist/chunk-EC2WZ6PG.js +90 -0
  37. package/dist/chunk-EFURLFJT.cjs +187 -0
  38. package/dist/chunk-EROUORMY.js +53 -0
  39. package/dist/chunk-LXBXFOAP.cjs +96 -0
  40. package/dist/chunk-MF6SA6DB.js +563 -0
  41. package/dist/chunk-N5R6ORIB.js +413 -0
  42. package/dist/chunk-N6R6BWHK.cjs +142 -0
  43. package/dist/chunk-QAGGN2T7.cjs +225 -0
  44. package/dist/chunk-QV4HRIDD.cjs +659 -0
  45. package/dist/chunk-TKNDYQB3.cjs +583 -0
  46. package/dist/chunk-UI5YC4TH.js +131 -0
  47. package/dist/chunk-VEHZYLK6.cjs +1151 -0
  48. package/dist/chunk-VNCWOGTI.js +12 -0
  49. package/dist/chunk-VWNIOGE6.js +180 -0
  50. package/dist/chunk-WDKRKGYF.js +608 -0
  51. package/dist/chunk-XOZIXBUK.js +2462 -0
  52. package/dist/chunk-ZS3K3SDR.cjs +258 -0
  53. package/dist/cli/index.cjs +2780 -0
  54. package/dist/common-DLFAqL2d.d.cts +36 -0
  55. package/dist/common-DbSXkaw6.d.ts +36 -0
  56. package/dist/dedupe-Bh5riD8Z.d.cts +13 -0
  57. package/dist/dedupe-DoYiSx-9.d.ts +13 -0
  58. package/dist/handler-BcnsnvhF.d.cts +82 -0
  59. package/dist/handler-qHzilC9T.d.ts +82 -0
  60. package/dist/index.cjs +309 -0
  61. package/dist/index.d.cts +187 -0
  62. package/dist/index.d.ts +187 -0
  63. package/dist/index.js +4 -0
  64. package/dist/next/client.cjs +113 -0
  65. package/dist/next/client.d.cts +26 -0
  66. package/dist/next/client.d.ts +26 -0
  67. package/dist/next/client.js +41 -0
  68. package/dist/next/config.cjs +277 -0
  69. package/dist/next/config.d.cts +193 -0
  70. package/dist/next/config.d.ts +193 -0
  71. package/dist/next/config.js +263 -0
  72. package/dist/next/index.cjs +148 -0
  73. package/dist/next/index.d.cts +32 -0
  74. package/dist/next/index.d.ts +32 -0
  75. package/dist/next/index.js +59 -0
  76. package/dist/node/index.cjs +257 -0
  77. package/dist/node/index.d.cts +145 -0
  78. package/dist/node/index.d.ts +145 -0
  79. package/dist/node/index.js +83 -0
  80. package/dist/options-BUhWuWJX.d.cts +79 -0
  81. package/dist/options-BUhWuWJX.d.ts +79 -0
  82. package/dist/react/index.cjs +107 -0
  83. package/dist/react/index.d.cts +84 -0
  84. package/dist/react/index.d.ts +84 -0
  85. package/dist/react/index.js +103 -0
  86. package/dist/scope-D1ouJm2h.d.cts +628 -0
  87. package/dist/scope-D1ouJm2h.d.ts +628 -0
  88. package/dist/server-edge-7624N3WF.cjs +51 -0
  89. package/dist/server-edge-BEEXWL7T.js +48 -0
  90. package/dist/server-node-ET4LIPEC.cjs +27 -0
  91. package/dist/server-node-TQUVMZUC.js +24 -0
  92. package/dist/session-C_WzbEN2.d.cts +4 -0
  93. package/dist/session-C_WzbEN2.d.ts +4 -0
  94. package/dist/session-propagation-Pr0Zb9Zn.d.cts +30 -0
  95. package/dist/session-propagation-RM5py1bp.d.ts +30 -0
  96. package/dist/starko.min.js +6 -0
  97. package/docs/browser.md +386 -0
  98. package/docs/configuration.md +310 -0
  99. package/docs/nextjs.md +488 -0
  100. package/docs/node.md +427 -0
  101. package/docs/other-backends.md +232 -0
  102. package/docs/privacy.md +112 -0
  103. package/docs/react.md +187 -0
  104. package/docs/source-maps.md +482 -0
  105. package/docs/troubleshooting.md +263 -0
  106. package/docs/widget.md +84 -0
  107. package/docs/wire-format.md +547 -0
  108. package/package.json +191 -4
@@ -0,0 +1,187 @@
1
+ import { F as FramePlatform, M as Mechanism, b as WireException, c as StackFrame, B as Breadcrumb, W as WireEvent, R as RemoteConfig, d as SuppressionRule } from './scope-D1ouJm2h.cjs';
2
+ export { e as BreadcrumbBuffer, D as DEBUG_ID_COMMENT, f as DEBUG_ID_GLOBAL, g as DEBUG_ID_NAMESPACE, h as DEFAULT_HOST, I as IngestRejectReason, i as IngestResponse, j as LIMITS, L as Level, N as NATIVE_DEBUG_ID_GLOBAL, P as PATHS, k as Platform, l as REDACTED, m as RELEASE_GLOBAL, n as SENSITIVE_QUERY_PARAMS, o as SESSION_ID_PATTERN, p as SOURCEMAP_BULK_MAX_CHECK, q as SOURCEMAP_BULK_MAX_MAPS, r as SOURCEMAP_BULK_MAX_OBJECT_BYTES, s as SOURCEMAP_BULK_REQUEST_CONCURRENCY, t as SOURCEMAP_BULK_UPLOAD_CONCURRENCY, u as SOURCEMAP_BULK_VERIFY_PER_WORKSPACE, v as SOURCEMAP_MAX_BYTES, w as SOURCEMAP_MAX_CHUNKS_PER_CHECK, x as SOURCEMAP_MAX_FILE_NAME, y as SOURCEMAP_MAX_PARTS, z as SOURCEMAP_PART_BYTES, A as SOURCEMAP_ROUTE_MAX_SECONDS, S as Scope, C as SourcemapBulkCheckRequest, E as SourcemapBulkCheckResponse, G as SourcemapBulkFinishRequest, H as SourcemapBulkFinishResponse, J as SourcemapBulkFinishStatus, K as SourcemapBulkStartRequest, O as SourcemapBulkStartResponse, Q as SourcemapBulkStartStatus, T as SourcemapCheckRequest, U as SourcemapCheckResponse, V as SourcemapCompleteRequest, X as SourcemapCompleteResponse, Y as SourcemapUploadResponse, Z as SourcemapUploadTarget, _ as WIRE_VERSION, $ as WireEnvelope, a as WireUser } from './scope-D1ouJm2h.cjs';
3
+ import { q as StackParser, P as ParsedFrame, r as StackLineParser } from './api-DNrctwJu.cjs';
4
+ export { C as Client, t as ClientOptions, E as EventHint, u as EventQueue, I as Integration, L as Logger, O as Options, v as PlatformOptions, Q as QueueOptions, S as SDK_VERSION, x as ScopeManager, a as Transport, T as TransportOptions, b as TransportResult, y as TransportSendOptions, c as addBreadcrumb, d as captureException, e as captureMessage, f as close, z as createLogger, A as eventUrl, g as flush, h as getClient, i as getCurrentScope, j as getGlobalScope, k as identify, B as safely, s as setContext, D as setCurrentClient, l as setExtra, m as setExtras, F as setScopeManager, n as setTag, o as setTags, p as setUser, G as uuid4, w as withScope } from './api-DNrctwJu.cjs';
5
+ export { d as dedupeIntegration } from './dedupe-Bh5riD8Z.cjs';
6
+
7
+ /**
8
+ * Client-side rate limits, so a render loop or a crash loop never becomes a
9
+ * firehose:
10
+ * - a token bucket per key (`rateKey`: the first exception's type and its
11
+ * message with numbers and ids masked, so one noisy error never uses up
12
+ * the allowance of a different bug of the same type): `burst` events at
13
+ * once, then one more every `refillMs`. At most `MAX_BUCKETS` keys are
14
+ * kept, the least recently used dropped first (a noisy key in use is
15
+ * never reset by a stream of new ones);
16
+ * - a budget of events per rolling minute, all keys together (servers: a
17
+ * loop throwing many different errors);
18
+ * - a cap on events for the lifetime of the page (browsers). Servers have
19
+ * none: a process that runs for weeks must keep reporting.
20
+ */
21
+ interface RateLimiterOptions {
22
+ /** Bucket size. Default 10. */
23
+ burst?: number;
24
+ /** One token back every this many ms. Default 10 000. */
25
+ refillMs?: number;
26
+ /** Events allowed for the lifetime of the page or process. Default: no cap. */
27
+ lifetimeCap?: number;
28
+ /** Events allowed in any 60 s window, all types together. Default: no budget. */
29
+ perMinute?: number;
30
+ }
31
+ type LimitReason = "lifetime cap" | "per-minute budget" | "rate limited";
32
+ declare class RateLimiter {
33
+ private buckets;
34
+ private sent;
35
+ /** Send times within the last minute (only kept when there is a per-minute budget). */
36
+ private recent;
37
+ readonly burst: number;
38
+ readonly refillMs: number;
39
+ readonly lifetimeCap: number;
40
+ readonly perMinute: number;
41
+ constructor(opts?: RateLimiterOptions);
42
+ /** `null` when the event may go; otherwise why it may not. Consumes a token when allowed. */
43
+ check(key: string, now?: number): LimitReason | null;
44
+ /** What `check` would answer, without consuming anything. */
45
+ peek(key: string, now?: number): LimitReason | null;
46
+ private test;
47
+ get count(): number;
48
+ }
49
+
50
+ /**
51
+ * Any thrown value → `exception_list`.
52
+ *
53
+ * Coercers (first match wins): ErrorEvent, PromiseRejectionEvent (and the
54
+ * CustomEvent some extensions turn it into), Error and DOMException,
55
+ * other DOM Events, plain objects, strings, primitives. `cause` and
56
+ * `AggregateError.errors` become chained exceptions linked by
57
+ * `mechanism.exception_id / parent_id`, depth-first, at most
58
+ * `LIMITS.MAX_EXCEPTIONS`, cycles cut.
59
+ */
60
+
61
+ /** Intermediate form of one exception. */
62
+ interface ExceptionLike {
63
+ type: string;
64
+ value: string;
65
+ stack?: string;
66
+ /** Frames to drop from the top of `stack`. */
67
+ skip?: number;
68
+ synthetic?: boolean;
69
+ /** Values to chain after this one, with their `mechanism.source`. */
70
+ children?: Array<[source: string, value: unknown]>;
71
+ }
72
+ interface BuildContext {
73
+ parser: StackParser;
74
+ framePlatform: FramePlatform;
75
+ isInApp?: (filename: string | undefined) => boolean | undefined;
76
+ /** Stack of an Error made at the capture site, for values that carry none. */
77
+ synthetic?: {
78
+ stack?: string;
79
+ skip: number;
80
+ };
81
+ }
82
+ interface BuiltExceptions {
83
+ exceptions: WireException[];
84
+ /** A plain object thrown as an error, serialised: goes to `extra.__serialized__`. */
85
+ serialized?: unknown;
86
+ }
87
+ /** Turns one value into an ExceptionLike (no chaining yet). */
88
+ declare function coerce(value: unknown, ctx: BuildContext, serialized?: {
89
+ value?: unknown;
90
+ }): ExceptionLike;
91
+ /** Parsed frames → wire frames: platform, in_app, chunk_id. Most recent first. */
92
+ declare function toWireFrames(parsed: ParsedFrame[], ctx: BuildContext): StackFrame[];
93
+ /**
94
+ * Builds the whole `exception_list` for a thrown value: the value first,
95
+ * then its causes / aggregated errors depth-first.
96
+ */
97
+ declare function buildExceptions(value: unknown, mechanism: Partial<Mechanism> | undefined, ctx: BuildContext): BuiltExceptions;
98
+ /** The event id an error was already captured as, if any. */
99
+ declare function capturedAs(value: unknown): string | undefined;
100
+ /** Remember that `value` (and what an ErrorEvent / rejection wraps) became `eventId`. */
101
+ declare function markCaptured(value: unknown, eventId: string): void;
102
+
103
+ /**
104
+ * Stack-string parsers. Original code; the formats covered (and the test
105
+ * samples) follow the cases Sentry's and PostHog's parsers document.
106
+ *
107
+ * Output order is the order of the stack string: MOST RECENT CALL FIRST
108
+ * (`frames[0]` is the throw site). Sentry and PostHog reverse theirs; we
109
+ * do not.
110
+ *
111
+ * Formats:
112
+ * - V8 (Chrome, Edge, Node, Deno, Bun): ` at fn (file:line:col)`,
113
+ * ` at file:line:col`, `async`, `new`, `[as alias]`, eval frames
114
+ * (`eval at outer (file:l:c), <anonymous>:l:c` → the outer location),
115
+ * `<anonymous>`, `native`, `index N` (Promise.all).
116
+ * - Gecko (Firefox) and JavaScriptCore (Safari): `fn@file:line:col`,
117
+ * `@file:line:col`, Firefox `async*fn@…`, `fn/<@…`, eval/Function frames
118
+ * (`file line N > eval:l:c` → file, line N), Safari `[native code]`,
119
+ * `global code@…`, frames without `@`.
120
+ */
121
+
122
+ /** One V8 line (` at …`): Chrome, Edge, Node, Deno, Bun. */
123
+ declare const v8LineParser: StackLineParser;
124
+ /** One Firefox or Safari line (`fn@file:line:col`). */
125
+ declare const geckoLineParser: StackLineParser;
126
+ /**
127
+ * Builds a parser from line parsers. The format is decided per stack: a
128
+ * stack with any `at ` line is V8 (so a message line containing `@` is never
129
+ * read as a Gecko frame); otherwise every line goes to the Gecko parser.
130
+ */
131
+ declare function createStackParser(v8?: StackLineParser, gecko?: StackLineParser): StackParser;
132
+ /** Chrome, Firefox and Safari stacks. */
133
+ declare const browserStackParser: StackParser;
134
+ /**
135
+ * Node stacks (`at fn (/app/x.js:1:2)`, `node:internal/…`, `file:///…`,
136
+ * Windows paths). The V8 line parser covers them; exported separately so
137
+ * the node SDK has a named parser to reuse.
138
+ */
139
+ declare const nodeStackParser: StackParser;
140
+
141
+ type IdMap = Record<string, string>;
142
+ /** `filename → debug id` for every registered bundle; empty when nothing is registered. */
143
+ declare function getDebugIdMap(parser: StackParser): IdMap;
144
+ /** The release the build injected (`globalThis._starkoRelease`: a string or `{ id }`). */
145
+ declare function getInjectedRelease(): string | undefined;
146
+
147
+ /**
148
+ * Trims an event to `LIMITS` (src/types/wire.ts) so the server never has
149
+ * to truncate or reject it, and rebuilds it from its known fields as plain
150
+ * JSON: whatever `beforeSend` or a hint put there (a bigint, a cycle, a
151
+ * throwing getter) cannot make the event, or the batch it travels in,
152
+ * unserialisable. URLs get the privacy defaults (core/url.ts), including
153
+ * frame file names and URLs inside messages. Runs last, after `beforeSend`.
154
+ * Returns a new event; the input is not modified.
155
+ */
156
+
157
+ /** One event's serialised budget, so 20 of them always stay far below the body limit's worst case. */
158
+ declare const MAX_EVENT_BYTES: number;
159
+ /** Oldest first; drops the OLDEST until count and bytes fit. */
160
+ declare function trimBreadcrumbs(crumbs: Breadcrumb[]): Breadcrumb[];
161
+ declare function trimEvent(input: WireEvent): WireEvent;
162
+
163
+ /** A JSON-safe copy of `value`, at most `depth` levels deep. Never throws. */
164
+ declare function normalize(value: unknown, depth?: number): unknown;
165
+ /** JSON.stringify that never throws (falls back to a marker string). */
166
+ declare function safeStringify(v: unknown): string;
167
+ /**
168
+ * `normalize` within a byte budget: retries with shallower depth, then gives
169
+ * up with a marker object. The result serialises to at most `maxBytes`.
170
+ */
171
+ declare function normalizeToSize<T = unknown>(value: unknown, maxBytes: number, depth?: number): T;
172
+
173
+ /**
174
+ * Remote config (`GET /api/v1/ingest/config`): whether the SDK runs, the
175
+ * server-side sample rate and suppression rules. A missing or malformed
176
+ * answer means "enabled with defaults".
177
+ */
178
+
179
+ declare const DEFAULT_REMOTE_CONFIG: RemoteConfig;
180
+ /** Validates whatever the server (or a broken proxy) returned. */
181
+ declare function normalizeRemoteConfig(raw: unknown): RemoteConfig;
182
+ /** True when the event matches a rule (every field the rule sets must match the first exception). */
183
+ declare function isSuppressed(event: WireEvent, rules: SuppressionRule[]): boolean;
184
+
185
+ declare function sanitizeUrl(url: string): string;
186
+
187
+ export { Breadcrumb, type BuildContext, DEFAULT_REMOTE_CONFIG, type ExceptionLike, FramePlatform, MAX_EVENT_BYTES, Mechanism, ParsedFrame, RateLimiter, type RateLimiterOptions, RemoteConfig, StackFrame, StackLineParser, StackParser, SuppressionRule, WireEvent, WireException, browserStackParser, buildExceptions, capturedAs, coerce, createStackParser, geckoLineParser, getDebugIdMap, getInjectedRelease, isSuppressed, markCaptured, nodeStackParser, normalize, normalizeRemoteConfig, normalizeToSize, safeStringify, sanitizeUrl, toWireFrames, trimBreadcrumbs, trimEvent, v8LineParser };
@@ -0,0 +1,187 @@
1
+ import { F as FramePlatform, M as Mechanism, b as WireException, c as StackFrame, B as Breadcrumb, W as WireEvent, R as RemoteConfig, d as SuppressionRule } from './scope-D1ouJm2h.js';
2
+ export { e as BreadcrumbBuffer, D as DEBUG_ID_COMMENT, f as DEBUG_ID_GLOBAL, g as DEBUG_ID_NAMESPACE, h as DEFAULT_HOST, I as IngestRejectReason, i as IngestResponse, j as LIMITS, L as Level, N as NATIVE_DEBUG_ID_GLOBAL, P as PATHS, k as Platform, l as REDACTED, m as RELEASE_GLOBAL, n as SENSITIVE_QUERY_PARAMS, o as SESSION_ID_PATTERN, p as SOURCEMAP_BULK_MAX_CHECK, q as SOURCEMAP_BULK_MAX_MAPS, r as SOURCEMAP_BULK_MAX_OBJECT_BYTES, s as SOURCEMAP_BULK_REQUEST_CONCURRENCY, t as SOURCEMAP_BULK_UPLOAD_CONCURRENCY, u as SOURCEMAP_BULK_VERIFY_PER_WORKSPACE, v as SOURCEMAP_MAX_BYTES, w as SOURCEMAP_MAX_CHUNKS_PER_CHECK, x as SOURCEMAP_MAX_FILE_NAME, y as SOURCEMAP_MAX_PARTS, z as SOURCEMAP_PART_BYTES, A as SOURCEMAP_ROUTE_MAX_SECONDS, S as Scope, C as SourcemapBulkCheckRequest, E as SourcemapBulkCheckResponse, G as SourcemapBulkFinishRequest, H as SourcemapBulkFinishResponse, J as SourcemapBulkFinishStatus, K as SourcemapBulkStartRequest, O as SourcemapBulkStartResponse, Q as SourcemapBulkStartStatus, T as SourcemapCheckRequest, U as SourcemapCheckResponse, V as SourcemapCompleteRequest, X as SourcemapCompleteResponse, Y as SourcemapUploadResponse, Z as SourcemapUploadTarget, _ as WIRE_VERSION, $ as WireEnvelope, a as WireUser } from './scope-D1ouJm2h.js';
3
+ import { q as StackParser, P as ParsedFrame, r as StackLineParser } from './api-BAFm4Lxj.js';
4
+ export { C as Client, t as ClientOptions, E as EventHint, u as EventQueue, I as Integration, L as Logger, O as Options, v as PlatformOptions, Q as QueueOptions, S as SDK_VERSION, x as ScopeManager, a as Transport, T as TransportOptions, b as TransportResult, y as TransportSendOptions, c as addBreadcrumb, d as captureException, e as captureMessage, f as close, z as createLogger, A as eventUrl, g as flush, h as getClient, i as getCurrentScope, j as getGlobalScope, k as identify, B as safely, s as setContext, D as setCurrentClient, l as setExtra, m as setExtras, F as setScopeManager, n as setTag, o as setTags, p as setUser, G as uuid4, w as withScope } from './api-BAFm4Lxj.js';
5
+ export { d as dedupeIntegration } from './dedupe-DoYiSx-9.js';
6
+
7
+ /**
8
+ * Client-side rate limits, so a render loop or a crash loop never becomes a
9
+ * firehose:
10
+ * - a token bucket per key (`rateKey`: the first exception's type and its
11
+ * message with numbers and ids masked, so one noisy error never uses up
12
+ * the allowance of a different bug of the same type): `burst` events at
13
+ * once, then one more every `refillMs`. At most `MAX_BUCKETS` keys are
14
+ * kept, the least recently used dropped first (a noisy key in use is
15
+ * never reset by a stream of new ones);
16
+ * - a budget of events per rolling minute, all keys together (servers: a
17
+ * loop throwing many different errors);
18
+ * - a cap on events for the lifetime of the page (browsers). Servers have
19
+ * none: a process that runs for weeks must keep reporting.
20
+ */
21
+ interface RateLimiterOptions {
22
+ /** Bucket size. Default 10. */
23
+ burst?: number;
24
+ /** One token back every this many ms. Default 10 000. */
25
+ refillMs?: number;
26
+ /** Events allowed for the lifetime of the page or process. Default: no cap. */
27
+ lifetimeCap?: number;
28
+ /** Events allowed in any 60 s window, all types together. Default: no budget. */
29
+ perMinute?: number;
30
+ }
31
+ type LimitReason = "lifetime cap" | "per-minute budget" | "rate limited";
32
+ declare class RateLimiter {
33
+ private buckets;
34
+ private sent;
35
+ /** Send times within the last minute (only kept when there is a per-minute budget). */
36
+ private recent;
37
+ readonly burst: number;
38
+ readonly refillMs: number;
39
+ readonly lifetimeCap: number;
40
+ readonly perMinute: number;
41
+ constructor(opts?: RateLimiterOptions);
42
+ /** `null` when the event may go; otherwise why it may not. Consumes a token when allowed. */
43
+ check(key: string, now?: number): LimitReason | null;
44
+ /** What `check` would answer, without consuming anything. */
45
+ peek(key: string, now?: number): LimitReason | null;
46
+ private test;
47
+ get count(): number;
48
+ }
49
+
50
+ /**
51
+ * Any thrown value → `exception_list`.
52
+ *
53
+ * Coercers (first match wins): ErrorEvent, PromiseRejectionEvent (and the
54
+ * CustomEvent some extensions turn it into), Error and DOMException,
55
+ * other DOM Events, plain objects, strings, primitives. `cause` and
56
+ * `AggregateError.errors` become chained exceptions linked by
57
+ * `mechanism.exception_id / parent_id`, depth-first, at most
58
+ * `LIMITS.MAX_EXCEPTIONS`, cycles cut.
59
+ */
60
+
61
+ /** Intermediate form of one exception. */
62
+ interface ExceptionLike {
63
+ type: string;
64
+ value: string;
65
+ stack?: string;
66
+ /** Frames to drop from the top of `stack`. */
67
+ skip?: number;
68
+ synthetic?: boolean;
69
+ /** Values to chain after this one, with their `mechanism.source`. */
70
+ children?: Array<[source: string, value: unknown]>;
71
+ }
72
+ interface BuildContext {
73
+ parser: StackParser;
74
+ framePlatform: FramePlatform;
75
+ isInApp?: (filename: string | undefined) => boolean | undefined;
76
+ /** Stack of an Error made at the capture site, for values that carry none. */
77
+ synthetic?: {
78
+ stack?: string;
79
+ skip: number;
80
+ };
81
+ }
82
+ interface BuiltExceptions {
83
+ exceptions: WireException[];
84
+ /** A plain object thrown as an error, serialised: goes to `extra.__serialized__`. */
85
+ serialized?: unknown;
86
+ }
87
+ /** Turns one value into an ExceptionLike (no chaining yet). */
88
+ declare function coerce(value: unknown, ctx: BuildContext, serialized?: {
89
+ value?: unknown;
90
+ }): ExceptionLike;
91
+ /** Parsed frames → wire frames: platform, in_app, chunk_id. Most recent first. */
92
+ declare function toWireFrames(parsed: ParsedFrame[], ctx: BuildContext): StackFrame[];
93
+ /**
94
+ * Builds the whole `exception_list` for a thrown value: the value first,
95
+ * then its causes / aggregated errors depth-first.
96
+ */
97
+ declare function buildExceptions(value: unknown, mechanism: Partial<Mechanism> | undefined, ctx: BuildContext): BuiltExceptions;
98
+ /** The event id an error was already captured as, if any. */
99
+ declare function capturedAs(value: unknown): string | undefined;
100
+ /** Remember that `value` (and what an ErrorEvent / rejection wraps) became `eventId`. */
101
+ declare function markCaptured(value: unknown, eventId: string): void;
102
+
103
+ /**
104
+ * Stack-string parsers. Original code; the formats covered (and the test
105
+ * samples) follow the cases Sentry's and PostHog's parsers document.
106
+ *
107
+ * Output order is the order of the stack string: MOST RECENT CALL FIRST
108
+ * (`frames[0]` is the throw site). Sentry and PostHog reverse theirs; we
109
+ * do not.
110
+ *
111
+ * Formats:
112
+ * - V8 (Chrome, Edge, Node, Deno, Bun): ` at fn (file:line:col)`,
113
+ * ` at file:line:col`, `async`, `new`, `[as alias]`, eval frames
114
+ * (`eval at outer (file:l:c), <anonymous>:l:c` → the outer location),
115
+ * `<anonymous>`, `native`, `index N` (Promise.all).
116
+ * - Gecko (Firefox) and JavaScriptCore (Safari): `fn@file:line:col`,
117
+ * `@file:line:col`, Firefox `async*fn@…`, `fn/<@…`, eval/Function frames
118
+ * (`file line N > eval:l:c` → file, line N), Safari `[native code]`,
119
+ * `global code@…`, frames without `@`.
120
+ */
121
+
122
+ /** One V8 line (` at …`): Chrome, Edge, Node, Deno, Bun. */
123
+ declare const v8LineParser: StackLineParser;
124
+ /** One Firefox or Safari line (`fn@file:line:col`). */
125
+ declare const geckoLineParser: StackLineParser;
126
+ /**
127
+ * Builds a parser from line parsers. The format is decided per stack: a
128
+ * stack with any `at ` line is V8 (so a message line containing `@` is never
129
+ * read as a Gecko frame); otherwise every line goes to the Gecko parser.
130
+ */
131
+ declare function createStackParser(v8?: StackLineParser, gecko?: StackLineParser): StackParser;
132
+ /** Chrome, Firefox and Safari stacks. */
133
+ declare const browserStackParser: StackParser;
134
+ /**
135
+ * Node stacks (`at fn (/app/x.js:1:2)`, `node:internal/…`, `file:///…`,
136
+ * Windows paths). The V8 line parser covers them; exported separately so
137
+ * the node SDK has a named parser to reuse.
138
+ */
139
+ declare const nodeStackParser: StackParser;
140
+
141
+ type IdMap = Record<string, string>;
142
+ /** `filename → debug id` for every registered bundle; empty when nothing is registered. */
143
+ declare function getDebugIdMap(parser: StackParser): IdMap;
144
+ /** The release the build injected (`globalThis._starkoRelease`: a string or `{ id }`). */
145
+ declare function getInjectedRelease(): string | undefined;
146
+
147
+ /**
148
+ * Trims an event to `LIMITS` (src/types/wire.ts) so the server never has
149
+ * to truncate or reject it, and rebuilds it from its known fields as plain
150
+ * JSON: whatever `beforeSend` or a hint put there (a bigint, a cycle, a
151
+ * throwing getter) cannot make the event, or the batch it travels in,
152
+ * unserialisable. URLs get the privacy defaults (core/url.ts), including
153
+ * frame file names and URLs inside messages. Runs last, after `beforeSend`.
154
+ * Returns a new event; the input is not modified.
155
+ */
156
+
157
+ /** One event's serialised budget, so 20 of them always stay far below the body limit's worst case. */
158
+ declare const MAX_EVENT_BYTES: number;
159
+ /** Oldest first; drops the OLDEST until count and bytes fit. */
160
+ declare function trimBreadcrumbs(crumbs: Breadcrumb[]): Breadcrumb[];
161
+ declare function trimEvent(input: WireEvent): WireEvent;
162
+
163
+ /** A JSON-safe copy of `value`, at most `depth` levels deep. Never throws. */
164
+ declare function normalize(value: unknown, depth?: number): unknown;
165
+ /** JSON.stringify that never throws (falls back to a marker string). */
166
+ declare function safeStringify(v: unknown): string;
167
+ /**
168
+ * `normalize` within a byte budget: retries with shallower depth, then gives
169
+ * up with a marker object. The result serialises to at most `maxBytes`.
170
+ */
171
+ declare function normalizeToSize<T = unknown>(value: unknown, maxBytes: number, depth?: number): T;
172
+
173
+ /**
174
+ * Remote config (`GET /api/v1/ingest/config`): whether the SDK runs, the
175
+ * server-side sample rate and suppression rules. A missing or malformed
176
+ * answer means "enabled with defaults".
177
+ */
178
+
179
+ declare const DEFAULT_REMOTE_CONFIG: RemoteConfig;
180
+ /** Validates whatever the server (or a broken proxy) returned. */
181
+ declare function normalizeRemoteConfig(raw: unknown): RemoteConfig;
182
+ /** True when the event matches a rule (every field the rule sets must match the first exception). */
183
+ declare function isSuppressed(event: WireEvent, rules: SuppressionRule[]): boolean;
184
+
185
+ declare function sanitizeUrl(url: string): string;
186
+
187
+ export { Breadcrumb, type BuildContext, DEFAULT_REMOTE_CONFIG, type ExceptionLike, FramePlatform, MAX_EVENT_BYTES, Mechanism, ParsedFrame, RateLimiter, type RateLimiterOptions, RemoteConfig, StackFrame, StackLineParser, StackParser, SuppressionRule, WireEvent, WireException, browserStackParser, buildExceptions, capturedAs, coerce, createStackParser, geckoLineParser, getDebugIdMap, getInjectedRelease, isSuppressed, markCaptured, nodeStackParser, normalize, normalizeRemoteConfig, normalizeToSize, safeStringify, sanitizeUrl, toWireFrames, trimBreadcrumbs, trimEvent, v8LineParser };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { Client, DEFAULT_REMOTE_CONFIG, EventQueue, MAX_EVENT_BYTES, RateLimiter, browserStackParser, createStackParser, dedupeIntegration, eventUrl, geckoLineParser, isSuppressed, nodeStackParser, normalizeRemoteConfig, sanitizeUrl, trimBreadcrumbs, trimEvent, v8LineParser } from './chunk-CMGCH6HD.js';
2
+ export { buildExceptions, capturedAs, coerce, getDebugIdMap, getInjectedRelease, markCaptured, toWireFrames } from './chunk-335HNCOJ.js';
3
+ export { BreadcrumbBuffer, SDK_VERSION, Scope, addBreadcrumb, captureException, captureMessage, close, createLogger, flush, getClient, getCurrentScope, getGlobalScope, identify, normalize, normalizeToSize, safeStringify, safely, setContext, setCurrentClient, setExtra, setExtras, setScopeManager, setTag, setTags, setUser, uuid4, withScope } from './chunk-WDKRKGYF.js';
4
+ export { DEBUG_ID_COMMENT, DEBUG_ID_GLOBAL, DEBUG_ID_NAMESPACE, DEFAULT_HOST, LIMITS, NATIVE_DEBUG_ID_GLOBAL, PATHS, REDACTED, RELEASE_GLOBAL, SENSITIVE_QUERY_PARAMS, SESSION_ID_PATTERN, SOURCEMAP_BULK_MAX_CHECK, SOURCEMAP_BULK_MAX_MAPS, SOURCEMAP_BULK_MAX_OBJECT_BYTES, SOURCEMAP_BULK_REQUEST_CONCURRENCY, SOURCEMAP_BULK_UPLOAD_CONCURRENCY, SOURCEMAP_BULK_VERIFY_PER_WORKSPACE, SOURCEMAP_MAX_BYTES, SOURCEMAP_MAX_CHUNKS_PER_CHECK, SOURCEMAP_MAX_FILE_NAME, SOURCEMAP_MAX_PARTS, SOURCEMAP_PART_BYTES, SOURCEMAP_ROUTE_MAX_SECONDS, WIRE_VERSION } from './chunk-3AW5B2WW.js';
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ var chunkTKNDYQB3_cjs = require('../chunk-TKNDYQB3.cjs');
4
+ require('../chunk-ALYFFOPR.cjs');
5
+ require('../chunk-6H5MOPTQ.cjs');
6
+ var chunkLXBXFOAP_cjs = require('../chunk-LXBXFOAP.cjs');
7
+ require('../chunk-CIHNKN62.cjs');
8
+ require('../chunk-ZS3K3SDR.cjs');
9
+ var chunkQV4HRIDD_cjs = require('../chunk-QV4HRIDD.cjs');
10
+ require('../chunk-N6R6BWHK.cjs');
11
+
12
+ // src/next/client.ts
13
+ function init2(options) {
14
+ try {
15
+ const user = options.integrations;
16
+ return chunkTKNDYQB3_cjs.init({
17
+ ...options,
18
+ // Precedence: see `buildTimeRelease`. Unset here, the client reads the injected global per event.
19
+ release: options.release || chunkLXBXFOAP_cjs.buildTimeRelease(),
20
+ integrations: (defaults) => {
21
+ const withNext = [...defaults, chunkLXBXFOAP_cjs.nextControlFlowIntegration()];
22
+ return typeof user === "function" ? user(withNext) : [...withNext, ...user || []];
23
+ }
24
+ });
25
+ } catch {
26
+ return void 0;
27
+ }
28
+ }
29
+ function captureGlobalError(error, options = {}) {
30
+ try {
31
+ if (chunkLXBXFOAP_cjs.isNextControlFlow(error)) return "";
32
+ const digest = chunkLXBXFOAP_cjs.digestOf(error);
33
+ if (digest && !(options && options.serverErrors)) return "";
34
+ return chunkQV4HRIDD_cjs.captureException(error, { mechanism: { type: "next.global-error", handled: true }, ...digest ? { tags: { "next.digest": digest } } : {} });
35
+ } catch {
36
+ return "";
37
+ }
38
+ }
39
+
40
+ Object.defineProperty(exports, "getDefaultIntegrations", {
41
+ enumerable: true,
42
+ get: function () { return chunkTKNDYQB3_cjs.getDefaultIntegrations; }
43
+ });
44
+ Object.defineProperty(exports, "sessionPropagationIntegration", {
45
+ enumerable: true,
46
+ get: function () { return chunkTKNDYQB3_cjs.sessionPropagationIntegration; }
47
+ });
48
+ Object.defineProperty(exports, "isNextControlFlow", {
49
+ enumerable: true,
50
+ get: function () { return chunkLXBXFOAP_cjs.isNextControlFlow; }
51
+ });
52
+ Object.defineProperty(exports, "nextControlFlowIntegration", {
53
+ enumerable: true,
54
+ get: function () { return chunkLXBXFOAP_cjs.nextControlFlowIntegration; }
55
+ });
56
+ Object.defineProperty(exports, "addBreadcrumb", {
57
+ enumerable: true,
58
+ get: function () { return chunkQV4HRIDD_cjs.addBreadcrumb; }
59
+ });
60
+ Object.defineProperty(exports, "captureException", {
61
+ enumerable: true,
62
+ get: function () { return chunkQV4HRIDD_cjs.captureException; }
63
+ });
64
+ Object.defineProperty(exports, "captureMessage", {
65
+ enumerable: true,
66
+ get: function () { return chunkQV4HRIDD_cjs.captureMessage; }
67
+ });
68
+ Object.defineProperty(exports, "close", {
69
+ enumerable: true,
70
+ get: function () { return chunkQV4HRIDD_cjs.close; }
71
+ });
72
+ Object.defineProperty(exports, "flush", {
73
+ enumerable: true,
74
+ get: function () { return chunkQV4HRIDD_cjs.flush; }
75
+ });
76
+ Object.defineProperty(exports, "getClient", {
77
+ enumerable: true,
78
+ get: function () { return chunkQV4HRIDD_cjs.getClient; }
79
+ });
80
+ Object.defineProperty(exports, "identify", {
81
+ enumerable: true,
82
+ get: function () { return chunkQV4HRIDD_cjs.identify; }
83
+ });
84
+ Object.defineProperty(exports, "setContext", {
85
+ enumerable: true,
86
+ get: function () { return chunkQV4HRIDD_cjs.setContext; }
87
+ });
88
+ Object.defineProperty(exports, "setExtra", {
89
+ enumerable: true,
90
+ get: function () { return chunkQV4HRIDD_cjs.setExtra; }
91
+ });
92
+ Object.defineProperty(exports, "setExtras", {
93
+ enumerable: true,
94
+ get: function () { return chunkQV4HRIDD_cjs.setExtras; }
95
+ });
96
+ Object.defineProperty(exports, "setTag", {
97
+ enumerable: true,
98
+ get: function () { return chunkQV4HRIDD_cjs.setTag; }
99
+ });
100
+ Object.defineProperty(exports, "setTags", {
101
+ enumerable: true,
102
+ get: function () { return chunkQV4HRIDD_cjs.setTags; }
103
+ });
104
+ Object.defineProperty(exports, "setUser", {
105
+ enumerable: true,
106
+ get: function () { return chunkQV4HRIDD_cjs.setUser; }
107
+ });
108
+ Object.defineProperty(exports, "withScope", {
109
+ enumerable: true,
110
+ get: function () { return chunkQV4HRIDD_cjs.withScope; }
111
+ });
112
+ exports.captureGlobalError = captureGlobalError;
113
+ exports.init = init2;
@@ -0,0 +1,26 @@
1
+ import { C as Client } from '../api-DNrctwJu.cjs';
2
+ export { E as EventHint, I as Integration, c as addBreadcrumb, d as captureException, e as captureMessage, f as close, g as flush, h as getClient, k as identify, s as setContext, l as setExtra, m as setExtras, n as setTag, o as setTags, p as setUser, w as withScope } from '../api-DNrctwJu.cjs';
3
+ import { B as BrowserOptions } from '../session-propagation-Pr0Zb9Zn.cjs';
4
+ export { g as getDefaultIntegrations, s as sessionPropagationIntegration } from '../session-propagation-Pr0Zb9Zn.cjs';
5
+ export { i as isNextControlFlow, n as nextControlFlowIntegration } from '../common-DLFAqL2d.cjs';
6
+ import '../scope-D1ouJm2h.cjs';
7
+
8
+ type NextClientOptions = BrowserOptions;
9
+ /** Start the browser SDK with Next's defaults. Never throws. */
10
+ declare function init(options: NextClientOptions): Client | undefined;
11
+ /**
12
+ * Report the error `app/global-error.tsx` (or an `error.tsx`) receives.
13
+ * Call it from an effect. Returns the event id ("" when nothing was
14
+ * captured). Not captured: Next's control flow; an error the SDK already
15
+ * captured (through a React root hook or the global handlers); and an error
16
+ * that came from the server: Next gives those a `digest`, and the server's
17
+ * `onRequestError` (`@starko-one/sdk/next`) has already reported it, with
18
+ * the same digest in the `next.digest` tag and this page's session id.
19
+ * Without the server SDK, pass `{ serverErrors: true }` to report those
20
+ * from the browser instead.
21
+ */
22
+ declare function captureGlobalError(error: unknown, options?: {
23
+ serverErrors?: boolean;
24
+ }): string;
25
+
26
+ export { BrowserOptions, Client, type NextClientOptions, captureGlobalError, init };
@@ -0,0 +1,26 @@
1
+ import { C as Client } from '../api-BAFm4Lxj.js';
2
+ export { E as EventHint, I as Integration, c as addBreadcrumb, d as captureException, e as captureMessage, f as close, g as flush, h as getClient, k as identify, s as setContext, l as setExtra, m as setExtras, n as setTag, o as setTags, p as setUser, w as withScope } from '../api-BAFm4Lxj.js';
3
+ import { B as BrowserOptions } from '../session-propagation-RM5py1bp.js';
4
+ export { g as getDefaultIntegrations, s as sessionPropagationIntegration } from '../session-propagation-RM5py1bp.js';
5
+ export { i as isNextControlFlow, n as nextControlFlowIntegration } from '../common-DbSXkaw6.js';
6
+ import '../scope-D1ouJm2h.js';
7
+
8
+ type NextClientOptions = BrowserOptions;
9
+ /** Start the browser SDK with Next's defaults. Never throws. */
10
+ declare function init(options: NextClientOptions): Client | undefined;
11
+ /**
12
+ * Report the error `app/global-error.tsx` (or an `error.tsx`) receives.
13
+ * Call it from an effect. Returns the event id ("" when nothing was
14
+ * captured). Not captured: Next's control flow; an error the SDK already
15
+ * captured (through a React root hook or the global handlers); and an error
16
+ * that came from the server: Next gives those a `digest`, and the server's
17
+ * `onRequestError` (`@starko-one/sdk/next`) has already reported it, with
18
+ * the same digest in the `next.digest` tag and this page's session id.
19
+ * Without the server SDK, pass `{ serverErrors: true }` to report those
20
+ * from the browser instead.
21
+ */
22
+ declare function captureGlobalError(error: unknown, options?: {
23
+ serverErrors?: boolean;
24
+ }): string;
25
+
26
+ export { BrowserOptions, Client, type NextClientOptions, captureGlobalError, init };
@@ -0,0 +1,41 @@
1
+ import { init } from '../chunk-MF6SA6DB.js';
2
+ export { getDefaultIntegrations, sessionPropagationIntegration } from '../chunk-MF6SA6DB.js';
3
+ import '../chunk-UI5YC4TH.js';
4
+ import '../chunk-CMGCH6HD.js';
5
+ import { nextControlFlowIntegration, buildTimeRelease, isNextControlFlow, digestOf } from '../chunk-EC2WZ6PG.js';
6
+ export { isNextControlFlow, nextControlFlowIntegration } from '../chunk-EC2WZ6PG.js';
7
+ import '../chunk-VNCWOGTI.js';
8
+ import '../chunk-335HNCOJ.js';
9
+ import { captureException } from '../chunk-WDKRKGYF.js';
10
+ export { addBreadcrumb, captureException, captureMessage, close, flush, getClient, identify, setContext, setExtra, setExtras, setTag, setTags, setUser, withScope } from '../chunk-WDKRKGYF.js';
11
+ import '../chunk-3AW5B2WW.js';
12
+
13
+ // src/next/client.ts
14
+ function init2(options) {
15
+ try {
16
+ const user = options.integrations;
17
+ return init({
18
+ ...options,
19
+ // Precedence: see `buildTimeRelease`. Unset here, the client reads the injected global per event.
20
+ release: options.release || buildTimeRelease(),
21
+ integrations: (defaults) => {
22
+ const withNext = [...defaults, nextControlFlowIntegration()];
23
+ return typeof user === "function" ? user(withNext) : [...withNext, ...user || []];
24
+ }
25
+ });
26
+ } catch {
27
+ return void 0;
28
+ }
29
+ }
30
+ function captureGlobalError(error, options = {}) {
31
+ try {
32
+ if (isNextControlFlow(error)) return "";
33
+ const digest = digestOf(error);
34
+ if (digest && !(options && options.serverErrors)) return "";
35
+ return captureException(error, { mechanism: { type: "next.global-error", handled: true }, ...digest ? { tags: { "next.digest": digest } } : {} });
36
+ } catch {
37
+ return "";
38
+ }
39
+ }
40
+
41
+ export { captureGlobalError, init2 as init };