@interfere/types 9.0.0 → 9.0.3-canary.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.
Files changed (168) hide show
  1. package/README.md +3 -3
  2. package/dist/data/frame.cjs +1 -0
  3. package/dist/data/frame.d.cts +27 -0
  4. package/dist/data/frame.d.mts +18 -5
  5. package/dist/data/frame.mjs +2 -16
  6. package/dist/data/session.cjs +1 -0
  7. package/dist/data/session.d.cts +8 -0
  8. package/dist/data/session.d.mts +3 -2
  9. package/dist/data/session.mjs +2 -9
  10. package/dist/data/source-maps.cjs +1 -0
  11. package/dist/data/source-maps.d.cts +151 -0
  12. package/dist/data/source-maps.d.mts +138 -27
  13. package/dist/data/source-maps.mjs +2 -21
  14. package/dist/events/error.cjs +1 -0
  15. package/dist/events/error.d.cts +196 -0
  16. package/dist/events/error.d.mts +140 -35
  17. package/dist/events/error.mjs +2 -64
  18. package/dist/events/pageleave.cjs +1 -0
  19. package/dist/events/pageleave.d.cts +13 -0
  20. package/dist/events/pageleave.d.mts +3 -2
  21. package/dist/events/pageleave.mjs +2 -10
  22. package/dist/events/pageview.cjs +1 -0
  23. package/dist/events/pageview.d.cts +14 -0
  24. package/dist/events/pageview.d.mts +3 -2
  25. package/dist/events/pageview.mjs +2 -11
  26. package/dist/integrations/index.cjs +1 -0
  27. package/dist/integrations/index.d.cts +48 -0
  28. package/dist/integrations/index.d.mts +2 -1
  29. package/dist/integrations/index.mjs +2 -57
  30. package/dist/integrations/platforms/cli.cjs +1 -0
  31. package/dist/integrations/platforms/cli.d.cts +12 -0
  32. package/dist/integrations/platforms/cli.d.mts +12 -0
  33. package/dist/integrations/platforms/cli.mjs +2 -0
  34. package/dist/integrations/platforms/github.cjs +1 -0
  35. package/dist/integrations/platforms/github.d.cts +16 -0
  36. package/dist/integrations/platforms/github.d.mts +2 -1
  37. package/dist/integrations/platforms/github.mjs +2 -13
  38. package/dist/integrations/platforms/slack.cjs +1 -0
  39. package/dist/integrations/platforms/slack.d.cts +33 -0
  40. package/dist/integrations/platforms/slack.d.mts +33 -0
  41. package/dist/integrations/platforms/slack.mjs +2 -0
  42. package/dist/integrations/platforms/vercel.cjs +1 -0
  43. package/dist/integrations/platforms/vercel.d.cts +47 -0
  44. package/dist/integrations/platforms/vercel.d.mts +2 -1
  45. package/dist/integrations/platforms/vercel.mjs +2 -26
  46. package/dist/releases/definition.cjs +1 -0
  47. package/dist/releases/definition.d.cts +57 -0
  48. package/dist/releases/definition.d.mts +4 -2
  49. package/dist/releases/definition.mjs +2 -63
  50. package/dist/releases/slug.cjs +1 -0
  51. package/dist/releases/slug.d.cts +24 -0
  52. package/dist/releases/slug.d.mts +24 -0
  53. package/dist/releases/slug.mjs +2 -0
  54. package/dist/sdk/env.cjs +1 -0
  55. package/dist/sdk/env.d.cts +6 -0
  56. package/dist/sdk/env.d.mts +2 -1
  57. package/dist/sdk/env.mjs +2 -17
  58. package/dist/sdk/envelope.cjs +1 -0
  59. package/dist/sdk/envelope.d.cts +1489 -0
  60. package/dist/sdk/envelope.d.mts +163 -35
  61. package/dist/sdk/envelope.mjs +2 -114
  62. package/dist/sdk/errors.cjs +2 -0
  63. package/dist/sdk/errors.d.cts +154 -0
  64. package/dist/sdk/errors.d.mts +88 -30
  65. package/dist/sdk/errors.mjs +3 -253
  66. package/dist/sdk/geo.cjs +1 -0
  67. package/dist/sdk/geo.d.cts +11 -0
  68. package/dist/sdk/geo.d.mts +2 -1
  69. package/dist/sdk/geo.mjs +2 -17
  70. package/dist/sdk/identify.cjs +1 -0
  71. package/dist/sdk/identify.d.cts +35 -0
  72. package/dist/sdk/identify.d.mts +3 -2
  73. package/dist/sdk/identify.mjs +2 -43
  74. package/dist/sdk/plugins/context/browser.cjs +1 -0
  75. package/dist/sdk/plugins/context/browser.d.cts +92 -0
  76. package/dist/sdk/plugins/context/browser.d.mts +10 -1
  77. package/dist/sdk/plugins/context/browser.mjs +2 -81
  78. package/dist/sdk/plugins/context/edge.cjs +1 -0
  79. package/dist/sdk/plugins/context/edge.d.cts +10 -0
  80. package/dist/sdk/plugins/context/edge.d.mts +2 -1
  81. package/dist/sdk/plugins/context/edge.mjs +2 -9
  82. package/dist/sdk/plugins/context/next.cjs +1 -0
  83. package/dist/sdk/plugins/context/next.d.cts +62 -0
  84. package/dist/sdk/plugins/context/next.d.mts +2 -1
  85. package/dist/sdk/plugins/context/next.mjs +2 -50
  86. package/dist/sdk/plugins/context/node.cjs +1 -0
  87. package/dist/sdk/plugins/context/node.d.cts +13 -0
  88. package/dist/sdk/plugins/context/node.d.mts +13 -0
  89. package/dist/sdk/plugins/context/node.mjs +2 -0
  90. package/dist/sdk/plugins/manifest.cjs +1 -0
  91. package/dist/sdk/plugins/manifest.d.cts +60 -0
  92. package/dist/sdk/plugins/manifest.d.mts +7 -1
  93. package/dist/sdk/plugins/manifest.mjs +2 -62
  94. package/dist/sdk/plugins/payload/errors.cjs +1 -0
  95. package/dist/sdk/plugins/payload/errors.d.cts +65 -0
  96. package/dist/sdk/plugins/payload/errors.d.mts +29 -19
  97. package/dist/sdk/plugins/payload/errors.mjs +2 -37
  98. package/dist/sdk/plugins/payload/page-events.cjs +1 -0
  99. package/dist/sdk/plugins/payload/page-events.d.cts +20 -0
  100. package/dist/sdk/plugins/payload/page-events.d.mts +4 -3
  101. package/dist/sdk/plugins/payload/page-events.mjs +2 -25
  102. package/dist/sdk/plugins/payload/rage-click.cjs +1 -0
  103. package/dist/sdk/plugins/payload/rage-click.d.cts +16 -0
  104. package/dist/sdk/plugins/payload/rage-click.d.mts +2 -1
  105. package/dist/sdk/plugins/payload/rage-click.mjs +2 -17
  106. package/dist/sdk/plugins/payload/replay.cjs +1 -0
  107. package/dist/sdk/plugins/payload/replay.d.cts +14 -0
  108. package/dist/sdk/plugins/payload/replay.d.mts +2 -1
  109. package/dist/sdk/plugins/payload/replay.mjs +2 -17
  110. package/dist/sdk/remote-config.cjs +1 -0
  111. package/dist/sdk/remote-config.d.cts +39 -0
  112. package/dist/sdk/remote-config.d.mts +32 -4
  113. package/dist/sdk/remote-config.mjs +2 -5
  114. package/dist/sdk/runtime.cjs +1 -0
  115. package/dist/sdk/runtime.d.cts +22 -0
  116. package/dist/sdk/runtime.d.mts +2 -1
  117. package/dist/sdk/runtime.mjs +2 -35
  118. package/package.json +122 -53
  119. package/dist/data/frame.d.mts.map +0 -1
  120. package/dist/data/frame.mjs.map +0 -1
  121. package/dist/data/session.d.mts.map +0 -1
  122. package/dist/data/session.mjs.map +0 -1
  123. package/dist/data/source-maps.d.mts.map +0 -1
  124. package/dist/data/source-maps.mjs.map +0 -1
  125. package/dist/events/error.d.mts.map +0 -1
  126. package/dist/events/error.mjs.map +0 -1
  127. package/dist/events/pageleave.d.mts.map +0 -1
  128. package/dist/events/pageleave.mjs.map +0 -1
  129. package/dist/events/pageview.d.mts.map +0 -1
  130. package/dist/events/pageview.mjs.map +0 -1
  131. package/dist/integrations/index.d.mts.map +0 -1
  132. package/dist/integrations/index.mjs.map +0 -1
  133. package/dist/integrations/platforms/github.d.mts.map +0 -1
  134. package/dist/integrations/platforms/github.mjs.map +0 -1
  135. package/dist/integrations/platforms/vercel.d.mts.map +0 -1
  136. package/dist/integrations/platforms/vercel.mjs.map +0 -1
  137. package/dist/releases/definition.d.mts.map +0 -1
  138. package/dist/releases/definition.mjs.map +0 -1
  139. package/dist/sdk/env.d.mts.map +0 -1
  140. package/dist/sdk/env.mjs.map +0 -1
  141. package/dist/sdk/envelope.d.mts.map +0 -1
  142. package/dist/sdk/envelope.mjs.map +0 -1
  143. package/dist/sdk/errors.d.mts.map +0 -1
  144. package/dist/sdk/errors.mjs.map +0 -1
  145. package/dist/sdk/geo.d.mts.map +0 -1
  146. package/dist/sdk/geo.mjs.map +0 -1
  147. package/dist/sdk/identify.d.mts.map +0 -1
  148. package/dist/sdk/identify.mjs.map +0 -1
  149. package/dist/sdk/plugins/context/browser.d.mts.map +0 -1
  150. package/dist/sdk/plugins/context/browser.mjs.map +0 -1
  151. package/dist/sdk/plugins/context/edge.d.mts.map +0 -1
  152. package/dist/sdk/plugins/context/edge.mjs.map +0 -1
  153. package/dist/sdk/plugins/context/next.d.mts.map +0 -1
  154. package/dist/sdk/plugins/context/next.mjs.map +0 -1
  155. package/dist/sdk/plugins/manifest.d.mts.map +0 -1
  156. package/dist/sdk/plugins/manifest.mjs.map +0 -1
  157. package/dist/sdk/plugins/payload/errors.d.mts.map +0 -1
  158. package/dist/sdk/plugins/payload/errors.mjs.map +0 -1
  159. package/dist/sdk/plugins/payload/page-events.d.mts.map +0 -1
  160. package/dist/sdk/plugins/payload/page-events.mjs.map +0 -1
  161. package/dist/sdk/plugins/payload/rage-click.d.mts.map +0 -1
  162. package/dist/sdk/plugins/payload/rage-click.mjs.map +0 -1
  163. package/dist/sdk/plugins/payload/replay.d.mts.map +0 -1
  164. package/dist/sdk/plugins/payload/replay.mjs.map +0 -1
  165. package/dist/sdk/remote-config.d.mts.map +0 -1
  166. package/dist/sdk/remote-config.mjs.map +0 -1
  167. package/dist/sdk/runtime.d.mts.map +0 -1
  168. package/dist/sdk/runtime.mjs.map +0 -1
@@ -1,114 +1,2 @@
1
- import { z } from "zod";
2
- import { sessionIdSchema } from "#data/session";
3
- import { browserContextSchema } from "#sdk/plugins/context/browser";
4
- import { edgeContextSchema } from "#sdk/plugins/context/edge";
5
- import { nextjsContextSchema } from "#sdk/plugins/context/next";
6
- import { errorEnvelopePayloadSchema } from "#sdk/plugins/payload/errors";
7
- import { pageleavePayloadSchema, pageviewPayloadSchema, uiEventPayloadSchema } from "#sdk/plugins/payload/page-events";
8
- import { rageClickPayloadSchema } from "#sdk/plugins/payload/rage-click";
9
- import { replayChunkPayloadSchema } from "#sdk/plugins/payload/replay";
10
- import { envSchema, runtimeSchema } from "#sdk/runtime";
11
- //#region src/sdk/envelope.ts
12
- /**
13
- * Indicates how the sessionId was resolved on the server.
14
- *
15
- * - "header": Extracted from x-interfere-request header (ideal case)
16
- * - "async_context": Retrieved from AsyncLocalStorage context
17
- * - "fallback": Generated as server-side fallback (breaks session continuity)
18
- * - "client": Session ID was set on the client (browser SDK)
19
- */
20
- const sessionSourceSchema = z.enum([
21
- "header",
22
- "async_context",
23
- "fallback",
24
- "client"
25
- ]).optional().meta({
26
- id: "SessionSource",
27
- title: "SessionSource",
28
- description: "How the server resolved the sessionId for this envelope."
29
- });
30
- const envelopeContextSchema = z.discriminatedUnion("runtime", [
31
- browserContextSchema,
32
- nextjsContextSchema,
33
- edgeContextSchema
34
- ]).meta({
35
- id: "EnvelopeContext",
36
- title: "EnvelopeContext",
37
- description: "Runtime-specific request context attached to every envelope."
38
- });
39
- const envelopeHeadersShape = {
40
- buildId: z.string(),
41
- clientTs: z.int(),
42
- context: envelopeContextSchema.optional(),
43
- environment: envSchema,
44
- producerVersion: z.string().optional(),
45
- releaseId: z.string().nullable(),
46
- runtime: runtimeSchema,
47
- sdkStack: z.array(z.string()).optional(),
48
- sessionId: sessionIdSchema.nullable(),
49
- sessionSource: sessionSourceSchema,
50
- uuid: z.uuidv7(),
51
- v: z.literal(0)
52
- };
53
- const errorEnvelopeSchema = z.object({
54
- ...envelopeHeadersShape,
55
- type: z.literal("error"),
56
- payload: errorEnvelopePayloadSchema
57
- }).meta({
58
- id: "ErrorEnvelope",
59
- title: "ErrorEnvelope"
60
- });
61
- const pageviewEnvelopeSchema = z.object({
62
- ...envelopeHeadersShape,
63
- type: z.literal("pageview"),
64
- payload: pageviewPayloadSchema
65
- }).meta({
66
- id: "PageviewEnvelope",
67
- title: "PageviewEnvelope"
68
- });
69
- const pageleaveEnvelopeSchema = z.object({
70
- ...envelopeHeadersShape,
71
- type: z.literal("pageleave"),
72
- payload: pageleavePayloadSchema
73
- }).meta({
74
- id: "PageleaveEnvelope",
75
- title: "PageleaveEnvelope"
76
- });
77
- const uiEventEnvelopeSchema = z.object({
78
- ...envelopeHeadersShape,
79
- type: z.literal("ui_event"),
80
- payload: uiEventPayloadSchema
81
- }).meta({
82
- id: "UiEventEnvelope",
83
- title: "UiEventEnvelope"
84
- });
85
- const replayChunkEnvelopeSchema = z.object({
86
- ...envelopeHeadersShape,
87
- type: z.literal("replay_chunk"),
88
- payload: replayChunkPayloadSchema
89
- }).meta({
90
- id: "ReplayChunkEnvelope",
91
- title: "ReplayChunkEnvelope"
92
- });
93
- const rageClickEnvelopeSchema = z.object({
94
- ...envelopeHeadersShape,
95
- type: z.literal("rage_click"),
96
- payload: rageClickPayloadSchema
97
- }).meta({
98
- id: "RageClickEnvelope",
99
- title: "RageClickEnvelope"
100
- });
101
- const envelopeSchema = z.discriminatedUnion("type", [
102
- errorEnvelopeSchema,
103
- pageviewEnvelopeSchema,
104
- pageleaveEnvelopeSchema,
105
- uiEventEnvelopeSchema,
106
- replayChunkEnvelopeSchema,
107
- rageClickEnvelopeSchema
108
- ]).meta({
109
- id: "Envelope",
110
- title: "Envelope",
111
- description: "A single event envelope accepted by the collector."
112
- });
113
- //#endregion
114
- export { envelopeContextSchema, envelopeSchema, errorEnvelopeSchema, pageleaveEnvelopeSchema, pageviewEnvelopeSchema, rageClickEnvelopeSchema, replayChunkEnvelopeSchema, sessionSourceSchema, uiEventEnvelopeSchema };
1
+ import{z}from"zod";import{sessionIdSchema}from"#data/session";import{browserContextSchema}from"#sdk/plugins/context/browser";import{edgeContextSchema}from"#sdk/plugins/context/edge";import{nextjsContextSchema}from"#sdk/plugins/context/next";import{nodeContextSchema}from"#sdk/plugins/context/node";import{errorEnvelopePayloadSchema}from"#sdk/plugins/payload/errors";import{pageleavePayloadSchema,pageviewPayloadSchema,uiEventPayloadSchema}from"#sdk/plugins/payload/page-events";import{rageClickPayloadSchema}from"#sdk/plugins/payload/rage-click";import{replayChunkPayloadSchema}from"#sdk/plugins/payload/replay";import{envSchema,runtimeSchema}from"#sdk/runtime";const sessionSourceSchema=z.enum([`header`,`async_context`,`fallback`,`client`]).optional().meta({id:`SessionSource`,title:`SessionSource`,description:`How the server resolved the sessionId for this envelope.`}),envelopeContextSchema=z.discriminatedUnion(`runtime`,[browserContextSchema,nextjsContextSchema,edgeContextSchema,nodeContextSchema]).meta({id:`EnvelopeContext`,title:`EnvelopeContext`,description:`Runtime-specific request context attached to every envelope.`}),envelopeHeadersShape={buildId:z.string(),clientTs:z.int(),context:envelopeContextSchema.optional(),environment:envSchema,producerVersion:z.string().optional(),releaseId:z.string().nullable(),runtime:runtimeSchema,sdkStack:z.array(z.string()).optional(),sessionId:sessionIdSchema.nullable(),sessionSource:sessionSourceSchema,uuid:z.uuidv7(),v:z.literal(0)},errorEnvelopeSchema=z.object({...envelopeHeadersShape,type:z.literal(`error`),payload:errorEnvelopePayloadSchema}).meta({id:`ErrorEnvelope`,title:`ErrorEnvelope`}),pageviewEnvelopeSchema=z.object({...envelopeHeadersShape,type:z.literal(`pageview`),payload:pageviewPayloadSchema}).meta({id:`PageviewEnvelope`,title:`PageviewEnvelope`}),pageleaveEnvelopeSchema=z.object({...envelopeHeadersShape,type:z.literal(`pageleave`),payload:pageleavePayloadSchema}).meta({id:`PageleaveEnvelope`,title:`PageleaveEnvelope`}),uiEventEnvelopeSchema=z.object({...envelopeHeadersShape,type:z.literal(`ui_event`),payload:uiEventPayloadSchema}).meta({id:`UiEventEnvelope`,title:`UiEventEnvelope`}),replayChunkEnvelopeSchema=z.object({...envelopeHeadersShape,type:z.literal(`replay_chunk`),payload:replayChunkPayloadSchema}).meta({id:`ReplayChunkEnvelope`,title:`ReplayChunkEnvelope`}),rageClickEnvelopeSchema=z.object({...envelopeHeadersShape,type:z.literal(`rage_click`),payload:rageClickPayloadSchema}).meta({id:`RageClickEnvelope`,title:`RageClickEnvelope`}),envelopeSchema=z.discriminatedUnion(`type`,[errorEnvelopeSchema,pageviewEnvelopeSchema,pageleaveEnvelopeSchema,uiEventEnvelopeSchema,replayChunkEnvelopeSchema,rageClickEnvelopeSchema]).meta({id:`Envelope`,title:`Envelope`,description:`A single event envelope accepted by the collector.`});export{envelopeContextSchema,envelopeSchema,errorEnvelopeSchema,pageleaveEnvelopeSchema,pageviewEnvelopeSchema,rageClickEnvelopeSchema,replayChunkEnvelopeSchema,sessionSourceSchema,uiEventEnvelopeSchema};
2
+ //# sourceMappingURL=envelope.mjs.map
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const MECHANISM_TYPE={browser:{onerror:`auto.browser.global_handlers.onerror`,onunhandledrejection:`auto.browser.global_handlers.onunhandledrejection`,consoleError:`auto.browser.console.error`},react:{errorBoundary:`auto.function.react.error_boundary`,captureBoundary:`auto.function.react.capture_boundary`,caughtError:`auto.function.react.caught_error`,uncaughtError:`auto.function.react.uncaught_error`,recoverableError:`auto.function.react.recoverable_error`},nextjs:{onRequestError:`auto.function.nextjs.on_request_error`,captureError:`auto.function.nextjs.capture_error`},node:{captureError:`auto.function.node.capture_error`,uncaughtException:`auto.node.global_handlers.uncaught_exception`,unhandledRejection:`auto.node.global_handlers.unhandled_rejection`},manual:{capture:`manual.api.capture`}},EXTENSION_URL_RE=/\b(?:chrome|moz|safari-web|safari|ms-browser|webkit-masked)-(?:extension|url):\/\//;function shouldDropBrowserExtensionNoise(stacks){return stacks.some(stack=>EXTENSION_URL_RE.test(stack))}const HAS_SOURCE_LOCATION_RE=/(?:https?|file|blob|webpack-internal):\/\/|\sat\s+[\w$.<>]+\s+\([^)]+:\d/;function shouldDropUnresolvableStack(stacks){if(stacks.length===0)return!1;for(let stack of stacks)if(HAS_SOURCE_LOCATION_RE.test(stack))return!1;return!0}const COMPONENT_STACK_RE=/^(?:in|at)\s+([^\s(]+)(?:\s+\(([^\s:)]+):(\d+)(?::(\d+))?\))?/;function parseReactComponentStack(componentStack){let frames=[];for(let rawLine of componentStack.split(`
2
+ `)){let line=rawLine.trim();if(!line)continue;let match=COMPONENT_STACK_RE.exec(line);if(!match)continue;let[,name,fileName,lineStr,colStr]=match;if(!name)continue;let frame={id:`react-${frames.length}`,fn:name};fileName&&(frame.file=fileName),lineStr&&(frame.line=Number(lineStr)),colStr&&(frame.column=Number(colStr)),frames.push(frame)}return frames}function toError(error){return error instanceof Error?error:typeof error==`string`?Error(error):typeof error==`object`&&error?tryUnwrapNestedError(error)||tagAsNonError(safeJson(error)??String(error)):tagAsNonError(String(error))}function tryUnwrapNestedError(record){if(record.cause instanceof Error)return record.cause;for(let value of Object.values(record))if(value instanceof Error)return value}function tagAsNonError(message){let e=Error(message);return e.name=`NonError`,e}function safeJson(value){try{return JSON.stringify(value)}catch{return null}}function classify(value){if(value===null)return`null`;let t=typeof value;if(t!==`object`)return t;let tag=Object.prototype.toString.call(value).slice(8,-1);return tag===`Object`?`PlainObject`:tag}function describe(value){if(value==null)return`Non-Error captured: ${String(value)}`;if(typeof value==`object`){let keys=Object.keys(value).sort();return keys.length===0?`Non-Error captured: empty object`:`Non-Error captured with keys: ${keys.join(`, `)}`}return`Non-Error captured: ${String(value)}`}function serializeBoundedDepth(value,maxDepth){let seen=new WeakSet,walk=(current,depth)=>{if(current===null)return null;let t=typeof current;if(t===`string`||t===`number`||t===`boolean`)return current;if(t===`undefined`)return;if(t===`function`||t===`symbol`||t===`bigint`)return String(current);if(depth>maxDepth)return`[depth-limit]`;if(seen.has(current))return`[circular]`;if(seen.add(current),Array.isArray(current))return current.map(item=>walk(item,depth+1));let out={};for(let[k,v]of Object.entries(current))out[k]=walk(v,depth+1);return out};return walk(value,0)}function toException(value){if(value instanceof Error)return value;if(typeof value==`string`)return Error(value);if(typeof value==`object`&&value){let nested=tryUnwrapNestedError(value);if(nested)return nested}return{kind:`non-error`,type:classify(value),value:describe(value),serialized:serializeBoundedDepth(value,4)}}function isNonErrorException(value){return typeof value==`object`&&!!value&&value.kind===`non-error`}function toExceptions(value,mechanism){if(isNonErrorException(value))return[{kind:`non-error`,type:value.type,value:value.value,mechanism,serialized:value.serialized}];let exceptions=[],current=value;for(let depth=0;current&&depth<5;depth+=1)exceptions.push({kind:`error`,type:current.name,value:current.message,mechanism:depth===0?mechanism:void 0,stack:current.stack??``}),current=current.cause instanceof Error?current.cause:void 0;return exceptions}exports.MECHANISM_TYPE=MECHANISM_TYPE,exports.isNonErrorException=isNonErrorException,exports.parseReactComponentStack=parseReactComponentStack,exports.shouldDropBrowserExtensionNoise=shouldDropBrowserExtensionNoise,exports.shouldDropUnresolvableStack=shouldDropUnresolvableStack,exports.toError=toError,exports.toException=toException,exports.toExceptions=toExceptions;
@@ -0,0 +1,154 @@
1
+ import { IngestedFrame } from "#data/frame";
2
+ import { ErrorMechanism, ExceptionValue } from "#sdk/plugins/payload/errors";
3
+
4
+ //#region src/sdk/errors.d.ts
5
+ /**
6
+ * Structured taxonomy of capture sources, tagged onto each
7
+ * `ErrorMechanism.type`. Follows the `auto.<surface>.<library>.<method>`
8
+ * convention Sentry also uses, so downstream analytics / classification can
9
+ * group on common prefixes:
10
+ *
11
+ * `auto.browser.*` — captured by SDK global handlers in the browser
12
+ * `auto.function.*` — captured by SDK functions (boundaries, callbacks,
13
+ * server wrappers)
14
+ *
15
+ * Leaves (`.onerror`, `.error_boundary`, `.on_request_error`, …) identify
16
+ * the specific capture site, which lets the agent's skill classifier reason
17
+ * about what "kind" of event this is without string-matching loose names.
18
+ */
19
+ declare const MECHANISM_TYPE: {
20
+ readonly browser: {
21
+ readonly onerror: "auto.browser.global_handlers.onerror";
22
+ readonly onunhandledrejection: "auto.browser.global_handlers.onunhandledrejection";
23
+ readonly consoleError: "auto.browser.console.error";
24
+ };
25
+ readonly react: {
26
+ readonly errorBoundary: "auto.function.react.error_boundary";
27
+ readonly captureBoundary: "auto.function.react.capture_boundary";
28
+ readonly caughtError: "auto.function.react.caught_error";
29
+ readonly uncaughtError: "auto.function.react.uncaught_error";
30
+ readonly recoverableError: "auto.function.react.recoverable_error";
31
+ };
32
+ readonly nextjs: {
33
+ readonly onRequestError: "auto.function.nextjs.on_request_error";
34
+ readonly captureError: "auto.function.nextjs.capture_error";
35
+ };
36
+ readonly node: {
37
+ readonly captureError: "auto.function.node.capture_error";
38
+ readonly uncaughtException: "auto.node.global_handlers.uncaught_exception";
39
+ readonly unhandledRejection: "auto.node.global_handlers.unhandled_rejection";
40
+ };
41
+ readonly manual: {
42
+ /** Customer called `capture(error)` from `@interfere/react/api`. */readonly capture: "manual.api.capture";
43
+ };
44
+ };
45
+ /**
46
+ * True when the raw stack mentions any browser-extension URL scheme
47
+ * anywhere. Catches extension-only stacks, extension interceptors
48
+ * (extension frames above app), and app errors whose stack still
49
+ * includes extension code (e.g. extension hydration). Cause-chain
50
+ * variants are caught by passing the chain entries' stacks to this
51
+ * check separately.
52
+ *
53
+ * Server-side parsing has full structured fidelity, but the noise
54
+ * filter runs at capture time before a parsed stack exists — regex
55
+ * over the raw string is sufficient and avoids pulling a parser into
56
+ * the customer bundle.
57
+ */
58
+ declare function shouldDropBrowserExtensionNoise(stacks: readonly string[]): boolean;
59
+ /**
60
+ * True when **none** of the supplied stacks (head + cause chain entries)
61
+ * carries any source-location anchor. Non-Error rejections (no stack at
62
+ * all) are exempt at the call site — they ship structured payloads the
63
+ * agent can reason over without frames.
64
+ */
65
+ declare function shouldDropUnresolvableStack(stacks: readonly string[]): boolean;
66
+ /**
67
+ * Parses a React `errorInfo.componentStack` string into synthetic frames.
68
+ * Server-side stack parsing handles JS frames; component-stack frames are
69
+ * supplementary context React emits separately and have a different shape,
70
+ * so they're parsed at capture time and shipped via `appendFrames`.
71
+ *
72
+ * React produces different formats across versions:
73
+ * - React 16–18 legacy: ` in ComponentName`
74
+ * ` in ComponentName (created by Parent)`
75
+ * - React 19 owner stacks: ` at ComponentName`
76
+ * ` at ComponentName (file.tsx:10:5)`
77
+ */
78
+ declare function parseReactComponentStack(componentStack: string): IngestedFrame[];
79
+ /**
80
+ * Coerces any thrown value into an `Error` instance, preferring a nested
81
+ * `Error` inside a plain-object rejection over a stringified fallback.
82
+ *
83
+ * Motivated by the common `Promise.reject({ error: realErr })` pattern
84
+ * (tRPC, GraphQL clients, some fetch wrappers). Without this, the captured
85
+ * exception would be `new Error("[object Object]")` and the nested Error's
86
+ * stack/message would be lost entirely.
87
+ *
88
+ * When multiple candidate Error values exist on the object, the first one
89
+ * found (in declaration order) wins. `cause` is preferred if present, since
90
+ * it's the documented ES2022 convention.
91
+ */
92
+ declare function toError(error: unknown): Error;
93
+ /**
94
+ * Capture-side variant for thrown values that aren't Errors and don't
95
+ * carry a nested Error (e.g. `Promise.reject({ code: 401, body: "..." })`,
96
+ * `Promise.reject(42)`). The structured payload rides on `serialized`
97
+ * so downstream consumers can render the original shape instead of
98
+ * parsing JSON back out of an Error's message string.
99
+ *
100
+ * Strings are *not* represented here — `Promise.reject("boom")` maps
101
+ * cleanly to `new Error("boom")` without lying about the shape, so it
102
+ * goes through `toException`'s Error branch.
103
+ */
104
+ interface NonErrorException {
105
+ readonly kind: "non-error";
106
+ /**
107
+ * Original payload, depth-bounded and circular-safe. Anything beyond
108
+ * `MAX_NON_ERROR_DEPTH` is collapsed to `"[depth-limit]"`; circular
109
+ * back-edges become `"[circular]"`. Primitives pass through unchanged.
110
+ */
111
+ readonly serialized: unknown;
112
+ /**
113
+ * Stable label for grouping. `"PlainObject"` / `"Array"` / `"number"`
114
+ * etc. — derived from the value's structural class, not its content,
115
+ * so two `Promise.reject({ code: 401 })` calls land in the same group
116
+ * regardless of which keys the object carries.
117
+ */
118
+ readonly type: string;
119
+ /**
120
+ * Best-effort one-liner. For objects: a sorted list of keys. For
121
+ * primitives: `String(value)`. The dashboard shows this; the
122
+ * `serialized` field carries the actual payload.
123
+ */
124
+ readonly value: string;
125
+ }
126
+ /**
127
+ * Coerces any thrown value into either an `Error` (when one is
128
+ * recoverable — direct Error, or nested Error inside an object via
129
+ * `cause` / first-Error-valued property — or a string, which maps
130
+ * cleanly to `new Error(str)`) or a structured `NonErrorException`
131
+ * carrying the original payload.
132
+ *
133
+ * Replaces `toError` for capture sites that handle both branches
134
+ * (today: `unhandledrejection`). `toError` is kept for callers that
135
+ * specifically need an `Error` (`<ErrorBoundary>` interop, browser
136
+ * APIs that take Error-typed args).
137
+ */
138
+ declare function toException(value: unknown): Error | NonErrorException;
139
+ declare function isNonErrorException(value: unknown): value is NonErrorException;
140
+ /**
141
+ * Walks `Error.cause` to flatten the chain into the wire shape the
142
+ * collector expects. Each entry carries `type` / `value` / `mechanism?`
143
+ * plus the raw `stack` string — the SDK ships **no parsed frames**.
144
+ * Server-side ingest parses `stack` into structured `IngestedFrame[]`
145
+ * via the collector's stack parser (see
146
+ * `src/services/collector/src/lib/stack-parser.ts`).
147
+ *
148
+ * Non-Error rejections short-circuit to a single `kind: "non-error"`
149
+ * entry with the structured payload on `serialized`.
150
+ */
151
+ declare function toExceptions(value: Error | NonErrorException, mechanism: ErrorMechanism): ExceptionValue[];
152
+ //#endregion
153
+ export { MECHANISM_TYPE, NonErrorException, isNonErrorException, parseReactComponentStack, shouldDropBrowserExtensionNoise, shouldDropUnresolvableStack, toError, toException, toExceptions };
154
+ //# sourceMappingURL=errors.d.cts.map
@@ -33,47 +33,47 @@ declare const MECHANISM_TYPE: {
33
33
  readonly onRequestError: "auto.function.nextjs.on_request_error";
34
34
  readonly captureError: "auto.function.nextjs.capture_error";
35
35
  };
36
+ readonly node: {
37
+ readonly captureError: "auto.function.node.capture_error";
38
+ readonly uncaughtException: "auto.node.global_handlers.uncaught_exception";
39
+ readonly unhandledRejection: "auto.node.global_handlers.unhandled_rejection";
40
+ };
41
+ readonly manual: {
42
+ /** Customer called `capture(error)` from `@interfere/react/api`. */readonly capture: "manual.api.capture";
43
+ };
36
44
  };
37
45
  /**
38
- * True when any exception in the cause chain has at least one stack frame
39
- * whose `fileName` is a browser-extension script URL. Covers extension-only
40
- * stacks, extension interceptors (extension frames above app), app errors
41
- * whose stack still includes extension code (e.g. hydration), and errors
42
- * whose outer throw is app code but whose inner `.cause` originated in an
43
- * extension. Stacks with no filenames are unchanged (returns false).
44
- */
45
- declare function shouldDropBrowserExtensionNoise(exceptions: readonly ExceptionValue[]): boolean;
46
- /**
47
- * True when no frame across the full cause chain carries any `fileName`.
46
+ * True when the raw stack mentions any browser-extension URL scheme
47
+ * anywhere. Catches extension-only stacks, extension interceptors
48
+ * (extension frames above app), and app errors whose stack still
49
+ * includes extension code (e.g. extension hydration). Cause-chain
50
+ * variants are caught by passing the chain entries' stacks to this
51
+ * check separately.
48
52
  *
49
- * Such stacks are structurally uninvestigatable: they come from inline
50
- * `<script>` blocks (`at <anonymous>:N:M`), `eval()` / `new Function()`,
51
- * CORS-masked cross-origin scripts (`"Script error."`), or browser-internal
52
- * code with no URL. No source map can resolve them, no repo lookup can find
53
- * them, and the agent has nothing to reason over. Dropping at capture time
54
- * prevents them from dominating ingest volume.
53
+ * Server-side parsing has full structured fidelity, but the noise
54
+ * filter runs at capture time before a parsed stack exists — regex
55
+ * over the raw string is sufficient and avoids pulling a parser into
56
+ * the customer bundle.
55
57
  */
56
- declare function shouldDropUnresolvableStack(exceptions: readonly ExceptionValue[]): boolean;
58
+ declare function shouldDropBrowserExtensionNoise(stacks: readonly string[]): boolean;
57
59
  /**
58
- * Normalizes an `Error.stack` string before feeding it to the stack parser.
59
- *
60
- * - Truncates each line to {@link MAX_STACK_LINE_LENGTH} to prevent ReDoS on
61
- * pathological inputs (a single frame with a 100 KiB URL can stall the
62
- * main thread for seconds in a regex-based parser).
63
- * - Strips the trailing `(error: *)` suffix some webpack builds emit.
60
+ * True when **none** of the supplied stacks (head + cause chain entries)
61
+ * carries any source-location anchor. Non-Error rejections (no stack at
62
+ * all) are exempt at the call site they ship structured payloads the
63
+ * agent can reason over without frames.
64
64
  */
65
- declare function preprocessStack(stack: string): string;
65
+ declare function shouldDropUnresolvableStack(stacks: readonly string[]): boolean;
66
66
  /**
67
67
  * Parses a React `errorInfo.componentStack` string into synthetic frames.
68
+ * Server-side stack parsing handles JS frames; component-stack frames are
69
+ * supplementary context React emits separately and have a different shape,
70
+ * so they're parsed at capture time and shipped via `appendFrames`.
68
71
  *
69
72
  * React produces different formats across versions:
70
73
  * - React 16–18 legacy: ` in ComponentName`
71
74
  * ` in ComponentName (created by Parent)`
72
75
  * - React 19 owner stacks: ` at ComponentName`
73
76
  * ` at ComponentName (file.tsx:10:5)`
74
- *
75
- * Each line becomes one frame with the component as `functionName`. When file
76
- * positions are present (React 19), they're preserved.
77
77
  */
78
78
  declare function parseReactComponentStack(componentStack: string): IngestedFrame[];
79
79
  /**
@@ -90,7 +90,65 @@ declare function parseReactComponentStack(componentStack: string): IngestedFrame
90
90
  * it's the documented ES2022 convention.
91
91
  */
92
92
  declare function toError(error: unknown): Error;
93
- declare function toExceptions(error: Error, mechanism: ErrorMechanism): ExceptionValue[];
94
- declare function extractFilenameFromStack(stack: string): string | null;
93
+ /**
94
+ * Capture-side variant for thrown values that aren't Errors and don't
95
+ * carry a nested Error (e.g. `Promise.reject({ code: 401, body: "..." })`,
96
+ * `Promise.reject(42)`). The structured payload rides on `serialized`
97
+ * so downstream consumers can render the original shape instead of
98
+ * parsing JSON back out of an Error's message string.
99
+ *
100
+ * Strings are *not* represented here — `Promise.reject("boom")` maps
101
+ * cleanly to `new Error("boom")` without lying about the shape, so it
102
+ * goes through `toException`'s Error branch.
103
+ */
104
+ interface NonErrorException {
105
+ readonly kind: "non-error";
106
+ /**
107
+ * Original payload, depth-bounded and circular-safe. Anything beyond
108
+ * `MAX_NON_ERROR_DEPTH` is collapsed to `"[depth-limit]"`; circular
109
+ * back-edges become `"[circular]"`. Primitives pass through unchanged.
110
+ */
111
+ readonly serialized: unknown;
112
+ /**
113
+ * Stable label for grouping. `"PlainObject"` / `"Array"` / `"number"`
114
+ * etc. — derived from the value's structural class, not its content,
115
+ * so two `Promise.reject({ code: 401 })` calls land in the same group
116
+ * regardless of which keys the object carries.
117
+ */
118
+ readonly type: string;
119
+ /**
120
+ * Best-effort one-liner. For objects: a sorted list of keys. For
121
+ * primitives: `String(value)`. The dashboard shows this; the
122
+ * `serialized` field carries the actual payload.
123
+ */
124
+ readonly value: string;
125
+ }
126
+ /**
127
+ * Coerces any thrown value into either an `Error` (when one is
128
+ * recoverable — direct Error, or nested Error inside an object via
129
+ * `cause` / first-Error-valued property — or a string, which maps
130
+ * cleanly to `new Error(str)`) or a structured `NonErrorException`
131
+ * carrying the original payload.
132
+ *
133
+ * Replaces `toError` for capture sites that handle both branches
134
+ * (today: `unhandledrejection`). `toError` is kept for callers that
135
+ * specifically need an `Error` (`<ErrorBoundary>` interop, browser
136
+ * APIs that take Error-typed args).
137
+ */
138
+ declare function toException(value: unknown): Error | NonErrorException;
139
+ declare function isNonErrorException(value: unknown): value is NonErrorException;
140
+ /**
141
+ * Walks `Error.cause` to flatten the chain into the wire shape the
142
+ * collector expects. Each entry carries `type` / `value` / `mechanism?`
143
+ * plus the raw `stack` string — the SDK ships **no parsed frames**.
144
+ * Server-side ingest parses `stack` into structured `IngestedFrame[]`
145
+ * via the collector's stack parser (see
146
+ * `src/services/collector/src/lib/stack-parser.ts`).
147
+ *
148
+ * Non-Error rejections short-circuit to a single `kind: "non-error"`
149
+ * entry with the structured payload on `serialized`.
150
+ */
151
+ declare function toExceptions(value: Error | NonErrorException, mechanism: ErrorMechanism): ExceptionValue[];
95
152
  //#endregion
96
- export { MECHANISM_TYPE, extractFilenameFromStack, parseReactComponentStack, preprocessStack, shouldDropBrowserExtensionNoise, shouldDropUnresolvableStack, toError, toExceptions };
153
+ export { MECHANISM_TYPE, NonErrorException, isNonErrorException, parseReactComponentStack, shouldDropBrowserExtensionNoise, shouldDropUnresolvableStack, toError, toException, toExceptions };
154
+ //# sourceMappingURL=errors.d.mts.map