@sentry/elysia 10.46.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.
@@ -0,0 +1,56 @@
1
+ import * as os from 'node:os';
2
+ import { getDefaultIntegrations as getDefaultIntegrations$1, bunServerIntegration, makeFetchTransport, init as init$1 } from '@sentry/bun';
3
+ import { applySdkMetadata } from '@sentry/core';
4
+
5
+ /** Get the default integrations for the Elysia SDK. */
6
+ function getDefaultIntegrations(_options) {
7
+ // Filter out bunServerIntegration
8
+ // Elysia already produces an HTTP server span, so we don't need Bun's competing root span.
9
+ return getDefaultIntegrations$1(_options).filter(i => i.name !== bunServerIntegration().name);
10
+ }
11
+
12
+ /**
13
+ * Get the runtime name and version.
14
+ */
15
+ function getRuntime() {
16
+ if (typeof Bun !== 'undefined') {
17
+ return { name: 'bun', version: Bun.version };
18
+ }
19
+
20
+ return { name: 'node', version: process.version };
21
+ }
22
+
23
+ /**
24
+ * Initializes the Sentry Elysia SDK.
25
+ *
26
+ * @example
27
+ * ```javascript
28
+ * import * as Sentry from '@sentry/elysia';
29
+ *
30
+ * Sentry.init({
31
+ * dsn: '__DSN__',
32
+ * tracesSampleRate: 1.0,
33
+ * });
34
+ * ```
35
+ */
36
+ function init(userOptions = {}) {
37
+ const options = {
38
+ ...userOptions,
39
+ platform: 'javascript',
40
+ runtime: getRuntime(),
41
+ serverName: userOptions.serverName || global.process.env.SENTRY_NAME || os.hostname(),
42
+ };
43
+
44
+ applySdkMetadata(userOptions, 'elysia', ['elysia', options.runtime.name]);
45
+
46
+ options.transport = options.transport || makeFetchTransport;
47
+
48
+ if (options.defaultIntegrations === undefined) {
49
+ options.defaultIntegrations = getDefaultIntegrations(options);
50
+ }
51
+
52
+ return init$1(options);
53
+ }
54
+
55
+ export { getDefaultIntegrations, init };
56
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import * as os from 'node:os';\nimport {\n bunServerIntegration,\n getDefaultIntegrations as getBunDefaultIntegrations,\n makeFetchTransport,\n} from '@sentry/bun';\nimport type { Integration, Options } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport { init as initNode, type NodeClient } from '@sentry/bun';\nimport type { ElysiaOptions } from './types';\n\n/** Get the default integrations for the Elysia SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n // Filter out bunServerIntegration\n // Elysia already produces an HTTP server span, so we don't need Bun's competing root span.\n return getBunDefaultIntegrations(_options).filter(i => i.name !== bunServerIntegration().name);\n}\n\n/**\n * Get the runtime name and version.\n */\nfunction getRuntime(): { name: string; version: string } {\n if (typeof Bun !== 'undefined') {\n return { name: 'bun', version: Bun.version };\n }\n\n return { name: 'node', version: process.version };\n}\n\n/**\n * Initializes the Sentry Elysia SDK.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/elysia';\n *\n * Sentry.init({\n * dsn: '__DSN__',\n * tracesSampleRate: 1.0,\n * });\n * ```\n */\nexport function init(userOptions: ElysiaOptions = {}): NodeClient | undefined {\n const options = {\n ...userOptions,\n platform: 'javascript',\n runtime: getRuntime(),\n serverName: userOptions.serverName || global.process.env.SENTRY_NAME || os.hostname(),\n };\n\n applySdkMetadata(userOptions, 'elysia', ['elysia', options.runtime.name]);\n\n options.transport = options.transport || makeFetchTransport;\n\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n return initNode(options);\n}\n"],"names":["getBunDefaultIntegrations","initNode"],"mappings":";;;;AAWA;AACO,SAAS,sBAAsB,CAAC,QAAQ,EAA0B;AACzE;AACA;AACA,EAAE,OAAOA,wBAAyB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA,IAAK,CAAC,CAAC,SAAS,oBAAoB,EAAE,CAAC,IAAI,CAAC;AAChG;;AAEA;AACA;AACA;AACA,SAAS,UAAU,GAAsC;AACzD,EAAE,IAAI,OAAO,GAAA,KAAQ,WAAW,EAAE;AAClC,IAAI,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,OAAA,EAAS;AAChD,EAAE;;AAEF,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAA,EAAS;AACnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,WAAW,GAAkB,EAAE,EAA0B;AAC9E,EAAE,MAAM,UAAU;AAClB,IAAI,GAAG,WAAW;AAClB,IAAI,QAAQ,EAAE,YAAY;AAC1B,IAAI,OAAO,EAAE,UAAU,EAAE;AACzB,IAAI,UAAU,EAAE,WAAW,CAAC,UAAA,IAAc,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAA,IAAe,EAAE,CAAC,QAAQ,EAAE;AACzF,GAAG;;AAEH,EAAE,gBAAgB,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;AAE3E,EAAE,OAAO,CAAC,SAAA,GAAY,OAAO,CAAC,SAAA,IAAa,kBAAkB;;AAE7D,EAAE,IAAI,OAAO,CAAC,mBAAA,KAAwB,SAAS,EAAE;AACjD,IAAI,OAAO,CAAC,mBAAA,GAAsB,sBAAsB,CAAC,OAAO,CAAC;AACjE,EAAE;;AAEF,EAAE,OAAOC,MAAQ,CAAC,OAAO,CAAC;AAC1B;;;;"}
@@ -0,0 +1,297 @@
1
+ import { withIsolationScope, continueTrace, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan, getRootSpan, getIsolationScope, winterCGRequestToRequestData, getTraceData, setHttpStatus, captureException, updateSpanName, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
2
+
3
+ const ELYSIA_ORIGIN = 'auto.http.elysia';
4
+
5
+ /**
6
+ * Map Elysia lifecycle phase names to Sentry span ops.
7
+ */
8
+ const ELYSIA_LIFECYCLE_OP_MAP = {
9
+ Request: 'middleware.elysia',
10
+ Parse: 'middleware.elysia',
11
+ Transform: 'middleware.elysia',
12
+ BeforeHandle: 'middleware.elysia',
13
+ Handle: 'request_handler.elysia',
14
+ AfterHandle: 'middleware.elysia',
15
+ MapResponse: 'middleware.elysia',
16
+ AfterResponse: 'middleware.elysia',
17
+ Error: 'middleware.elysia',
18
+ };
19
+
20
+ function isBun() {
21
+ return typeof Bun !== 'undefined';
22
+ }
23
+
24
+ /**
25
+ * Per-request storage for the root span reference.
26
+ * .wrap() captures the root span and .trace() reads it.
27
+ * This is necessary because Elysia's .trace() callbacks may run in a different
28
+ * async context where getActiveSpan() returns undefined.
29
+ */
30
+ const rootSpanForRequest = new WeakMap();
31
+
32
+ const instrumentedApps = new WeakSet();
33
+
34
+ /**
35
+ * Updates the root span and isolation scope with the parameterized route name.
36
+ */
37
+ function updateRouteTransactionName(request, method, route) {
38
+ const transactionName = `${method} ${route}`;
39
+
40
+ // Try the stored root span first (reliable across async contexts),
41
+ // then fall back to getActiveSpan() for cases where async context is preserved.
42
+ const rootSpan = rootSpanForRequest.get(request);
43
+ if (rootSpan) {
44
+ updateSpanName(rootSpan, transactionName);
45
+ rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
46
+ } else {
47
+ const activeSpan = getActiveSpan();
48
+ if (activeSpan) {
49
+ const root = getRootSpan(activeSpan);
50
+ updateSpanName(root, transactionName);
51
+ root.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
52
+ }
53
+ }
54
+
55
+ getIsolationScope().setTransactionName(transactionName);
56
+ }
57
+
58
+ function defaultShouldHandleError(context) {
59
+ const status = context.set.status;
60
+ if (status === undefined) {
61
+ return true;
62
+ }
63
+ const statusCode = parseInt(String(status), 10);
64
+ if (Number.isNaN(statusCode)) {
65
+ return true;
66
+ }
67
+ // Capture server errors (5xx) and unusual status codes (<= 299 in an error handler).
68
+ // 3xx and 4xx are not captured by default (client errors / redirects).
69
+ return statusCode >= 500 || statusCode <= 299;
70
+ }
71
+
72
+ /**
73
+ * Instruments a single Elysia lifecycle phase by creating a Sentry span for it,
74
+ * and child spans for each individual handler within the phase.
75
+ *
76
+ * @param rootSpan - The root server span to parent lifecycle spans under.
77
+ * Must be passed explicitly because Elysia's .trace() listener callbacks run
78
+ * in a different async context where getActiveSpan() returns undefined.
79
+ */
80
+ function instrumentLifecyclePhase(phaseName, listener, rootSpan) {
81
+ const op = ELYSIA_LIFECYCLE_OP_MAP[phaseName];
82
+ if (!op) {
83
+ return;
84
+ }
85
+
86
+ void listener(process => {
87
+ const phaseSpan = startInactiveSpan({
88
+ name: phaseName,
89
+ parentSpan: rootSpan,
90
+ attributes: {
91
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
92
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,
93
+ },
94
+ });
95
+
96
+ // Create child spans for individual handlers within this phase.
97
+ // Named functions get their name, arrow functions get 'anonymous'.
98
+ if (process.total > 0) {
99
+ void process.onEvent(child => {
100
+ const handlerName = child.name || 'anonymous';
101
+ const childSpan = startInactiveSpan({
102
+ name: handlerName,
103
+ parentSpan: phaseSpan,
104
+ attributes: {
105
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
106
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,
107
+ },
108
+ });
109
+
110
+ void child.onStop(() => {
111
+ childSpan.end();
112
+ });
113
+ });
114
+ }
115
+
116
+ void process.onStop(() => {
117
+ phaseSpan.end();
118
+ });
119
+ });
120
+ }
121
+
122
+ /**
123
+ * Integrate Sentry with an Elysia app for error handling, request context,
124
+ * and tracing. Returns the app instance for chaining.
125
+ *
126
+ * Should be called at the **start** of the chain before defining routes.
127
+ *
128
+ * @param app The Elysia instance
129
+ * @param options Configuration options
130
+ * @returns The same Elysia instance for chaining
131
+ *
132
+ * @example
133
+ * ```javascript
134
+ * import * as Sentry from '@sentry/elysia';
135
+ * import { Elysia } from 'elysia';
136
+ *
137
+ * Sentry.withElysia(new Elysia())
138
+ * .get('/', () => 'Hello World')
139
+ * .listen(3000);
140
+ * ```
141
+ */
142
+ function withElysia(app, options = {}) {
143
+ if (instrumentedApps.has(app)) {
144
+ return app;
145
+ }
146
+ instrumentedApps.add(app);
147
+
148
+ // Use .wrap() to capture or create the root span for each request.
149
+ // This is necessary because Elysia's .trace() callbacks run in a different
150
+ // async context where getActiveSpan() returns undefined. By storing the root
151
+ // span in a WeakMap keyed by the Request object, we can retrieve it in .trace().
152
+ // HigherOrderFunction type is not exported from elysia's main entry point,
153
+ // so we type the callback parameters directly.
154
+ app.wrap((fn, request) => {
155
+ if (isBun()) {
156
+ // On Bun there is no HTTP instrumentation, so we create a root span ourselves.
157
+ // Scope setup must happen inside the returned function so that it's active
158
+ // when Elysia calls the handler (not during .wrap() registration).
159
+ return (...args) => {
160
+ return withIsolationScope(() => {
161
+ return continueTrace(
162
+ {
163
+ sentryTrace: request.headers.get('sentry-trace') || '',
164
+ baggage: request.headers.get('baggage'),
165
+ },
166
+ () => {
167
+ return startSpanManual(
168
+ {
169
+ op: 'http.server',
170
+ name: `${request.method} ${new URL(request.url).pathname}`,
171
+ attributes: {
172
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,
173
+ [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
174
+ },
175
+ },
176
+ rootSpan => {
177
+ rootSpanForRequest.set(request, rootSpan);
178
+ try {
179
+ const result = fn(...args);
180
+ if (result instanceof Promise) {
181
+ return result.then(
182
+ res => {
183
+ rootSpanForRequest.delete(request);
184
+ rootSpan.end();
185
+ return res;
186
+ },
187
+ err => {
188
+ rootSpanForRequest.delete(request);
189
+ rootSpan.end();
190
+ throw err;
191
+ },
192
+ );
193
+ }
194
+ rootSpanForRequest.delete(request);
195
+ rootSpan.end();
196
+ return result;
197
+ } catch (err) {
198
+ rootSpanForRequest.delete(request);
199
+ rootSpan.end();
200
+ throw err;
201
+ }
202
+ },
203
+ );
204
+ },
205
+ );
206
+ });
207
+ };
208
+ }
209
+
210
+ // On Node.js, the HTTP instrumentation already creates a root span.
211
+ // We just capture its reference so .trace() can use it.
212
+ const activeSpan = getActiveSpan();
213
+ if (activeSpan) {
214
+ rootSpanForRequest.set(request, getRootSpan(activeSpan));
215
+ }
216
+ return fn;
217
+ });
218
+
219
+ // Use .trace() ONLY for span creation. The trace API is observational —
220
+ // callbacks fire after phases complete, so they can't reliably mutate
221
+ // response headers or capture errors. All SDK logic stays in real hooks.
222
+ const traceHandler = lifecycle => {
223
+ const rootSpan = rootSpanForRequest.get(lifecycle.context.request);
224
+
225
+ const phases = [
226
+ ['Request', lifecycle.onRequest],
227
+ ['Parse', lifecycle.onParse],
228
+ ['Transform', lifecycle.onTransform],
229
+ ['BeforeHandle', lifecycle.onBeforeHandle],
230
+ ['Handle', lifecycle.onHandle],
231
+ ['AfterHandle', lifecycle.onAfterHandle],
232
+ ['MapResponse', lifecycle.onMapResponse],
233
+ ['AfterResponse', lifecycle.onAfterResponse],
234
+ ['Error', lifecycle.onError],
235
+ ];
236
+
237
+ for (const [phaseName, listener] of phases) {
238
+ if (listener) {
239
+ instrumentLifecyclePhase(phaseName, listener, rootSpan);
240
+ }
241
+ }
242
+ };
243
+
244
+ app.trace({ as: 'global' }, traceHandler);
245
+
246
+ // SDK logic uses real lifecycle hooks — these show up as handler spans
247
+ // in the trace (named sentryOnRequest etc.), but that's the correct
248
+ // tradeoff: the trace API can't reliably mutate state or capture errors.
249
+
250
+ app.onRequest(function sentryOnRequest(context) {
251
+ getIsolationScope().setSDKProcessingMetadata({
252
+ normalizedRequest: winterCGRequestToRequestData(context.request),
253
+ });
254
+ });
255
+
256
+ app.onAfterHandle({ as: 'global' }, function sentryOnAfterHandle(context) {
257
+ if (context.route) {
258
+ updateRouteTransactionName(context.request, context.request.method, context.route);
259
+ }
260
+
261
+ const traceData = getTraceData();
262
+ if (traceData['sentry-trace']) {
263
+ context.set.headers['sentry-trace'] = traceData['sentry-trace'];
264
+ }
265
+ if (traceData.baggage) {
266
+ context.set.headers['baggage'] = traceData.baggage;
267
+ }
268
+ });
269
+
270
+ app.onError({ as: 'global' }, function sentryOnError(context) {
271
+ if (context.route) {
272
+ updateRouteTransactionName(context.request, context.request.method, context.route);
273
+ }
274
+
275
+ // Set error status on root span
276
+ const rootSpan = rootSpanForRequest.get(context.request);
277
+ if (rootSpan) {
278
+ const statusCode = parseInt(String(context.set.status), 10);
279
+ setHttpStatus(rootSpan, Number.isNaN(statusCode) ? 500 : statusCode);
280
+ }
281
+
282
+ const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;
283
+ if (shouldHandleError(context)) {
284
+ captureException(context.error, {
285
+ mechanism: {
286
+ type: 'auto.http.elysia.on_error',
287
+ handled: false,
288
+ },
289
+ });
290
+ }
291
+ });
292
+
293
+ return app;
294
+ }
295
+
296
+ export { withElysia };
297
+ //# sourceMappingURL=withElysia.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withElysia.js","sources":["../../src/withElysia.ts"],"sourcesContent":["import type { Span } from '@sentry/core';\nimport {\n captureException,\n continueTrace,\n getActiveSpan,\n getIsolationScope,\n getRootSpan,\n getTraceData,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n setHttpStatus,\n startInactiveSpan,\n startSpanManual,\n updateSpanName,\n winterCGRequestToRequestData,\n withIsolationScope,\n} from '@sentry/core';\nimport type { Elysia, ErrorContext, TraceHandler, TraceListener } from 'elysia';\n\ninterface ElysiaHandlerOptions {\n shouldHandleError?: (context: ErrorContext) => boolean;\n}\n\nconst ELYSIA_ORIGIN = 'auto.http.elysia';\n\n/**\n * Map Elysia lifecycle phase names to Sentry span ops.\n */\nconst ELYSIA_LIFECYCLE_OP_MAP: Record<string, string> = {\n Request: 'middleware.elysia',\n Parse: 'middleware.elysia',\n Transform: 'middleware.elysia',\n BeforeHandle: 'middleware.elysia',\n Handle: 'request_handler.elysia',\n AfterHandle: 'middleware.elysia',\n MapResponse: 'middleware.elysia',\n AfterResponse: 'middleware.elysia',\n Error: 'middleware.elysia',\n};\n\nfunction isBun(): boolean {\n return typeof Bun !== 'undefined';\n}\n\n/**\n * Per-request storage for the root span reference.\n * .wrap() captures the root span and .trace() reads it.\n * This is necessary because Elysia's .trace() callbacks may run in a different\n * async context where getActiveSpan() returns undefined.\n */\nconst rootSpanForRequest = new WeakMap<Request, Span>();\n\nconst instrumentedApps = new WeakSet<Elysia>();\n\n/**\n * Updates the root span and isolation scope with the parameterized route name.\n */\nfunction updateRouteTransactionName(request: Request, method: string, route: string): void {\n const transactionName = `${method} ${route}`;\n\n // Try the stored root span first (reliable across async contexts),\n // then fall back to getActiveSpan() for cases where async context is preserved.\n const rootSpan = rootSpanForRequest.get(request);\n if (rootSpan) {\n updateSpanName(rootSpan, transactionName);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n } else {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const root = getRootSpan(activeSpan);\n updateSpanName(root, transactionName);\n root.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n }\n }\n\n getIsolationScope().setTransactionName(transactionName);\n}\n\nfunction defaultShouldHandleError(context: ErrorContext): boolean {\n const status = context.set.status;\n if (status === undefined) {\n return true;\n }\n const statusCode = parseInt(String(status), 10);\n if (Number.isNaN(statusCode)) {\n return true;\n }\n // Capture server errors (5xx) and unusual status codes (<= 299 in an error handler).\n // 3xx and 4xx are not captured by default (client errors / redirects).\n return statusCode >= 500 || statusCode <= 299;\n}\n\n/**\n * Instruments a single Elysia lifecycle phase by creating a Sentry span for it,\n * and child spans for each individual handler within the phase.\n *\n * @param rootSpan - The root server span to parent lifecycle spans under.\n * Must be passed explicitly because Elysia's .trace() listener callbacks run\n * in a different async context where getActiveSpan() returns undefined.\n */\nfunction instrumentLifecyclePhase(phaseName: string, listener: TraceListener, rootSpan: Span | undefined): void {\n const op = ELYSIA_LIFECYCLE_OP_MAP[phaseName];\n if (!op) {\n return;\n }\n\n void listener(process => {\n const phaseSpan = startInactiveSpan({\n name: phaseName,\n parentSpan: rootSpan,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,\n },\n });\n\n // Create child spans for individual handlers within this phase.\n // Named functions get their name, arrow functions get 'anonymous'.\n if (process.total > 0) {\n void process.onEvent(child => {\n const handlerName = child.name || 'anonymous';\n const childSpan = startInactiveSpan({\n name: handlerName,\n parentSpan: phaseSpan,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,\n },\n });\n\n void child.onStop(() => {\n childSpan.end();\n });\n });\n }\n\n void process.onStop(() => {\n phaseSpan.end();\n });\n });\n}\n\n/**\n * Integrate Sentry with an Elysia app for error handling, request context,\n * and tracing. Returns the app instance for chaining.\n *\n * Should be called at the **start** of the chain before defining routes.\n *\n * @param app The Elysia instance\n * @param options Configuration options\n * @returns The same Elysia instance for chaining\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/elysia';\n * import { Elysia } from 'elysia';\n *\n * Sentry.withElysia(new Elysia())\n * .get('/', () => 'Hello World')\n * .listen(3000);\n * ```\n */\nexport function withElysia<T extends Elysia>(app: T, options: ElysiaHandlerOptions = {}): T {\n if (instrumentedApps.has(app)) {\n return app;\n }\n instrumentedApps.add(app);\n\n // Use .wrap() to capture or create the root span for each request.\n // This is necessary because Elysia's .trace() callbacks run in a different\n // async context where getActiveSpan() returns undefined. By storing the root\n // span in a WeakMap keyed by the Request object, we can retrieve it in .trace().\n // HigherOrderFunction type is not exported from elysia's main entry point,\n // so we type the callback parameters directly.\n app.wrap((fn: (...args: unknown[]) => unknown, request: Request) => {\n if (isBun()) {\n // On Bun there is no HTTP instrumentation, so we create a root span ourselves.\n // Scope setup must happen inside the returned function so that it's active\n // when Elysia calls the handler (not during .wrap() registration).\n return (...args: unknown[]) => {\n return withIsolationScope(() => {\n return continueTrace(\n {\n sentryTrace: request.headers.get('sentry-trace') || '',\n baggage: request.headers.get('baggage'),\n },\n () => {\n return startSpanManual(\n {\n op: 'http.server',\n name: `${request.method} ${new URL(request.url).pathname}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n },\n },\n rootSpan => {\n rootSpanForRequest.set(request, rootSpan);\n try {\n const result = fn(...args);\n if (result instanceof Promise) {\n return result.then(\n res => {\n rootSpanForRequest.delete(request);\n rootSpan.end();\n return res;\n },\n err => {\n rootSpanForRequest.delete(request);\n rootSpan.end();\n throw err;\n },\n );\n }\n rootSpanForRequest.delete(request);\n rootSpan.end();\n return result;\n } catch (err) {\n rootSpanForRequest.delete(request);\n rootSpan.end();\n throw err;\n }\n },\n );\n },\n );\n });\n };\n }\n\n // On Node.js, the HTTP instrumentation already creates a root span.\n // We just capture its reference so .trace() can use it.\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n rootSpanForRequest.set(request, getRootSpan(activeSpan));\n }\n return fn;\n });\n\n // Use .trace() ONLY for span creation. The trace API is observational —\n // callbacks fire after phases complete, so they can't reliably mutate\n // response headers or capture errors. All SDK logic stays in real hooks.\n const traceHandler: TraceHandler = lifecycle => {\n const rootSpan = rootSpanForRequest.get(lifecycle.context.request);\n\n const phases: [string, TraceListener][] = [\n ['Request', lifecycle.onRequest],\n ['Parse', lifecycle.onParse],\n ['Transform', lifecycle.onTransform],\n ['BeforeHandle', lifecycle.onBeforeHandle],\n ['Handle', lifecycle.onHandle],\n ['AfterHandle', lifecycle.onAfterHandle],\n ['MapResponse', lifecycle.onMapResponse],\n ['AfterResponse', lifecycle.onAfterResponse],\n ['Error', lifecycle.onError],\n ];\n\n for (const [phaseName, listener] of phases) {\n if (listener) {\n instrumentLifecyclePhase(phaseName, listener, rootSpan);\n }\n }\n };\n\n app.trace({ as: 'global' }, traceHandler);\n\n // SDK logic uses real lifecycle hooks — these show up as handler spans\n // in the trace (named sentryOnRequest etc.), but that's the correct\n // tradeoff: the trace API can't reliably mutate state or capture errors.\n\n app.onRequest(function sentryOnRequest(context) {\n getIsolationScope().setSDKProcessingMetadata({\n normalizedRequest: winterCGRequestToRequestData(context.request),\n });\n });\n\n app.onAfterHandle({ as: 'global' }, function sentryOnAfterHandle(context) {\n if (context.route) {\n updateRouteTransactionName(context.request, context.request.method, context.route);\n }\n\n const traceData = getTraceData();\n if (traceData['sentry-trace']) {\n context.set.headers['sentry-trace'] = traceData['sentry-trace'];\n }\n if (traceData.baggage) {\n context.set.headers['baggage'] = traceData.baggage;\n }\n });\n\n app.onError({ as: 'global' }, function sentryOnError(context) {\n if (context.route) {\n updateRouteTransactionName(context.request, context.request.method, context.route);\n }\n\n // Set error status on root span\n const rootSpan = rootSpanForRequest.get(context.request);\n if (rootSpan) {\n const statusCode = parseInt(String(context.set.status), 10);\n setHttpStatus(rootSpan, Number.isNaN(statusCode) ? 500 : statusCode);\n }\n\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n if (shouldHandleError(context)) {\n captureException(context.error, {\n mechanism: {\n type: 'auto.http.elysia.on_error',\n handled: false,\n },\n });\n }\n });\n\n return app;\n}\n"],"names":[],"mappings":";;AAwBA,MAAM,aAAA,GAAgB,kBAAkB;;AAExC;AACA;AACA;AACA,MAAM,uBAAuB,GAA2B;AACxD,EAAE,OAAO,EAAE,mBAAmB;AAC9B,EAAE,KAAK,EAAE,mBAAmB;AAC5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BAAA,IAAA,wBAAA;AACA,IAAA,IAAA,iBAAA,CAAA,OAAA,CAAA,EAAA;AACA,MAAA,gBAAA,CAAA,OAAA,CAAA,KAAA,EAAA;AACA,QAAA,SAAA,EAAA;AACA,UAAA,IAAA,EAAA,2BAAA;AACA,UAAA,OAAA,EAAA,KAAA;AACA,SAAA;AACA,OAAA,CAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA;;AAEA,EAAA,OAAA,GAAA;AACA;;;;"}
@@ -0,0 +1,7 @@
1
+ export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport, getClient, isInitialized, isEnabled, generateInstrumentOnce, getCurrentScope, getGlobalScope, getIsolationScope, getTraceData, getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, setContext, setConversationId, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, httpHeadersToSpanAttributes, winterCGHeadersToDict, anrIntegration, disableAnrDetectionForCallback, consoleIntegration, httpIntegration, httpServerIntegration, httpServerSpansIntegration, nativeNodeFetchIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, openAIIntegration, langChainIntegration, langGraphIntegration, modulesIntegration, contextLinesIntegration, nodeContextIntegration, localVariablesIntegration, requestDataIntegration, fsIntegration, functionToStringIntegration, inboundFiltersIntegration, eventFiltersIntegration, linkedErrorsIntegration, setMeasurement, getActiveSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, suppressTracing, withActiveSpan, getRootSpan, getSpanDescendants, continueTrace, getAutoPerformanceIntegrations, cron, parameterize, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dataloaderIntegration, expressIntegration, expressErrorHandler, setupExpressErrorHandler, fastifyIntegration, setupFastifyErrorHandler, firebaseIntegration, koaIntegration, setupKoaErrorHandler, connectIntegration, setupConnectErrorHandler, genericPoolIntegration, graphqlIntegration, knexIntegration, kafkaIntegration, lruMemoizerIntegration, mongoIntegration, mongooseIntegration, mysqlIntegration, mysql2Integration, redisIntegration, tediousIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, processSessionIntegration, hapiIntegration, setupHapiErrorHandler, honoIntegration, setupHonoErrorHandler, spotlightIntegration, initOpenTelemetry, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, supabaseIntegration, instrumentSupabaseClient, instrumentOpenAiClient, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangGraph, instrumentStateGraphCompile, zodErrorsIntegration, profiler, amqplibIntegration, anthropicAIIntegration, googleGenAIIntegration, vercelAIIntegration, logger, consoleLoggingIntegration, createConsolaReporter, createSentryWinstonTransport, wrapMcpServerWithSentry, featureFlagsIntegration, launchDarklyIntegration, growthbookIntegration, buildLaunchDarklyFlagUsedHandler, openFeatureIntegration, OpenFeatureIntegrationHook, statsigIntegration, unleashIntegration, metrics, bunServerIntegration, makeFetchTransport, } from '@sentry/bun';
2
+ export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, RequestEventData, SdkInfo, Event, EventHint, ErrorEvent, Exception, Session, SeverityLevel, Span, StackFrame, Stacktrace, Thread, User, FeatureFlagsIntegration, Metric, ExclusiveEventHintOrCaptureContext, CaptureContext, } from '@sentry/core';
3
+ export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, } from '@sentry/core';
4
+ export type { ElysiaOptions } from './types';
5
+ export { withElysia } from './withElysia';
6
+ export { getDefaultIntegrations, init } from './sdk';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,SAAS,EACT,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,yBAAyB,EACzB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EAErB,cAAc,EAEd,8BAA8B,EAC9B,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,8BAA8B,EAC9B,+BAA+B,EAC/B,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,2BAA2B,EAE3B,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,8BAA8B,EAC9B,IAAI,EACJ,YAAY,EACZ,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,kBAAk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c,CAAC;AAEtB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Integration, Options } from '@sentry/core';
2
+ import { type NodeClient } from '@sentry/bun';
3
+ import type { ElysiaOptions } from './types';
4
+ /** Get the default integrations for the Elysia SDK. */
5
+ export declare function getDefaultIntegrations(_options: Options): Integration[];
6
+ /**
7
+ * Initializes the Sentry Elysia SDK.
8
+ *
9
+ * @example
10
+ * ```javascript
11
+ * import * as Sentry from '@sentry/elysia';
12
+ *
13
+ * Sentry.init({
14
+ * dsn: '__DSN__',
15
+ * tracesSampleRate: 1.0,
16
+ * });
17
+ * ```
18
+ */
19
+ export declare function init(userOptions?: ElysiaOptions): NodeClient | undefined;
20
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,uDAAuD;AACvD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,OAAO,GAAG,WAAW,EAAE,CAIvE;AAaD;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,WAAW,GAAE,aAAkB,GAAG,UAAU,GAAG,SAAS,CAiB5E"}
@@ -0,0 +1,6 @@
1
+ import type { BunOptions } from '@sentry/bun';
2
+ /**
3
+ * Configuration options for the Sentry Elysia SDK.
4
+ */
5
+ export type ElysiaOptions = BunOptions;
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Elysia, ErrorContext } from 'elysia';
2
+ interface ElysiaHandlerOptions {
3
+ shouldHandleError?: (context: ErrorContext) => boolean;
4
+ }
5
+ /**
6
+ * Integrate Sentry with an Elysia app for error handling, request context,
7
+ * and tracing. Returns the app instance for chaining.
8
+ *
9
+ * Should be called at the **start** of the chain before defining routes.
10
+ *
11
+ * @param app The Elysia instance
12
+ * @param options Configuration options
13
+ * @returns The same Elysia instance for chaining
14
+ *
15
+ * @example
16
+ * ```javascript
17
+ * import * as Sentry from '@sentry/elysia';
18
+ * import { Elysia } from 'elysia';
19
+ *
20
+ * Sentry.withElysia(new Elysia())
21
+ * .get('/', () => 'Hello World')
22
+ * .listen(3000);
23
+ * ```
24
+ */
25
+ export declare function withElysia<T extends Elysia>(app: T, options?: ElysiaHandlerOptions): T;
26
+ export {};
27
+ //# sourceMappingURL=withElysia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withElysia.d.ts","sourceRoot":"","sources":["../../src/withElysia.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAA+B,MAAM,QAAQ,CAAC;AAEhF,UAAU,oBAAoB;IAC5B,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC;CACxD;AAyHD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,GAAE,oBAAyB,GAAG,CAAC,CAwJ1F"}
@@ -0,0 +1,7 @@
1
+ export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport, getClient, isInitialized, isEnabled, generateInstrumentOnce, getCurrentScope, getGlobalScope, getIsolationScope, getTraceData, getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, setContext, setConversationId, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, httpHeadersToSpanAttributes, winterCGHeadersToDict, anrIntegration, disableAnrDetectionForCallback, consoleIntegration, httpIntegration, httpServerIntegration, httpServerSpansIntegration, nativeNodeFetchIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, openAIIntegration, langChainIntegration, langGraphIntegration, modulesIntegration, contextLinesIntegration, nodeContextIntegration, localVariablesIntegration, requestDataIntegration, fsIntegration, functionToStringIntegration, inboundFiltersIntegration, eventFiltersIntegration, linkedErrorsIntegration, setMeasurement, getActiveSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, suppressTracing, withActiveSpan, getRootSpan, getSpanDescendants, continueTrace, getAutoPerformanceIntegrations, cron, parameterize, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dataloaderIntegration, expressIntegration, expressErrorHandler, setupExpressErrorHandler, fastifyIntegration, setupFastifyErrorHandler, firebaseIntegration, koaIntegration, setupKoaErrorHandler, connectIntegration, setupConnectErrorHandler, genericPoolIntegration, graphqlIntegration, knexIntegration, kafkaIntegration, lruMemoizerIntegration, mongoIntegration, mongooseIntegration, mysqlIntegration, mysql2Integration, redisIntegration, tediousIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, processSessionIntegration, hapiIntegration, setupHapiErrorHandler, honoIntegration, setupHonoErrorHandler, spotlightIntegration, initOpenTelemetry, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, supabaseIntegration, instrumentSupabaseClient, instrumentOpenAiClient, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangGraph, instrumentStateGraphCompile, zodErrorsIntegration, profiler, amqplibIntegration, anthropicAIIntegration, googleGenAIIntegration, vercelAIIntegration, logger, consoleLoggingIntegration, createConsolaReporter, createSentryWinstonTransport, wrapMcpServerWithSentry, featureFlagsIntegration, launchDarklyIntegration, growthbookIntegration, buildLaunchDarklyFlagUsedHandler, openFeatureIntegration, OpenFeatureIntegrationHook, statsigIntegration, unleashIntegration, metrics, bunServerIntegration, makeFetchTransport, } from '@sentry/bun';
2
+ export { Breadcrumb, BreadcrumbHint, PolymorphicRequest, RequestEventData, SdkInfo, Event, EventHint, ErrorEvent, Exception, Session, SeverityLevel, Span, StackFrame, Stacktrace, Thread, User, FeatureFlagsIntegration, Metric, ExclusiveEventHintOrCaptureContext, CaptureContext, } from '@sentry/core';
3
+ export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, } from '@sentry/core';
4
+ export { ElysiaOptions } from './types';
5
+ export { withElysia } from './withElysia';
6
+ export { getDefaultIntegrations, init } from './sdk';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { Integration, Options } from '@sentry/core';
2
+ import { NodeClient } from '@sentry/bun';
3
+ import { ElysiaOptions } from './types';
4
+ /** Get the default integrations for the Elysia SDK. */
5
+ export declare function getDefaultIntegrations(_options: Options): Integration[];
6
+ /**
7
+ * Initializes the Sentry Elysia SDK.
8
+ *
9
+ * @example
10
+ * ```javascript
11
+ * import * as Sentry from '@sentry/elysia';
12
+ *
13
+ * Sentry.init({
14
+ * dsn: '__DSN__',
15
+ * tracesSampleRate: 1.0,
16
+ * });
17
+ * ```
18
+ */
19
+ export declare function init(userOptions?: ElysiaOptions): NodeClient | undefined;
20
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { BunOptions } from '@sentry/bun';
2
+ /**
3
+ * Configuration options for the Sentry Elysia SDK.
4
+ */
5
+ export type ElysiaOptions = BunOptions;
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { Elysia, ErrorContext } from 'elysia';
2
+ interface ElysiaHandlerOptions {
3
+ shouldHandleError?: (context: ErrorContext) => boolean;
4
+ }
5
+ /**
6
+ * Integrate Sentry with an Elysia app for error handling, request context,
7
+ * and tracing. Returns the app instance for chaining.
8
+ *
9
+ * Should be called at the **start** of the chain before defining routes.
10
+ *
11
+ * @param app The Elysia instance
12
+ * @param options Configuration options
13
+ * @returns The same Elysia instance for chaining
14
+ *
15
+ * @example
16
+ * ```javascript
17
+ * import * as Sentry from '@sentry/elysia';
18
+ * import { Elysia } from 'elysia';
19
+ *
20
+ * Sentry.withElysia(new Elysia())
21
+ * .get('/', () => 'Hello World')
22
+ * .listen(3000);
23
+ * ```
24
+ */
25
+ export declare function withElysia<T extends Elysia>(app: T, options?: ElysiaHandlerOptions): T;
26
+ export {};
27
+ //# sourceMappingURL=withElysia.d.ts.map
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@sentry/elysia",
3
+ "version": "10.46.0",
4
+ "description": "Official Sentry SDK for Elysia",
5
+ "repository": "git://github.com/getsentry/sentry-javascript.git",
6
+ "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/elysia",
7
+ "author": "Sentry",
8
+ "license": "MIT",
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
12
+ "files": [
13
+ "/build"
14
+ ],
15
+ "main": "build/cjs/index.js",
16
+ "module": "build/esm/index.js",
17
+ "types": "build/types/index.d.ts",
18
+ "exports": {
19
+ "./package.json": "./package.json",
20
+ ".": {
21
+ "import": {
22
+ "types": "./build/types/index.d.ts",
23
+ "default": "./build/esm/index.js"
24
+ },
25
+ "require": {
26
+ "types": "./build/types/index.d.ts",
27
+ "default": "./build/cjs/index.js"
28
+ }
29
+ }
30
+ },
31
+ "typesVersions": {
32
+ "<5.0": {
33
+ "build/types/index.d.ts": [
34
+ "build/types-ts3.8/index.d.ts"
35
+ ]
36
+ }
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "dependencies": {
42
+ "@sentry/bun": "10.46.0",
43
+ "@sentry/core": "10.46.0"
44
+ },
45
+ "peerDependencies": {
46
+ "elysia": "^1.4.0"
47
+ },
48
+ "devDependencies": {
49
+ "bun-types": "^1.2.9",
50
+ "elysia": "^1.4.0"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "elysia": {
54
+ "optional": false
55
+ }
56
+ },
57
+ "scripts": {
58
+ "build": "run-p build:transpile build:types",
59
+ "build:dev": "yarn build",
60
+ "build:transpile": "rollup -c rollup.npm.config.mjs",
61
+ "build:types": "run-s build:types:core build:types:downlevel",
62
+ "build:types:core": "tsc -p tsconfig.types.json",
63
+ "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
64
+ "build:watch": "run-p build:transpile:watch",
65
+ "build:dev:watch": "yarn build:watch",
66
+ "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch",
67
+ "build:tarball": "npm pack",
68
+ "circularDepCheck": "madge --circular src/index.ts",
69
+ "clean": "rimraf build coverage sentry-elysia-*.tgz",
70
+ "lint": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --type-aware",
71
+ "lint:fix": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --fix --type-aware",
72
+ "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module",
73
+ "test": "vitest run",
74
+ "test:watch": "vitest --watch",
75
+ "yalc:publish": "yalc publish --push --sig"
76
+ },
77
+ "volta": {
78
+ "extends": "../../package.json"
79
+ },
80
+ "sideEffects": false
81
+ }