@sentry/elysia 10.67.0 → 10.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/withElysia.js +13 -5
- package/build/cjs/withElysia.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/withElysia.js +14 -6
- package/build/esm/withElysia.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/withElysia.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +1 -1
- package/package.json +4 -3
package/build/cjs/index.js
CHANGED
|
@@ -85,6 +85,7 @@ exports.instrumentGoogleGenAIClient = bun.instrumentGoogleGenAIClient;
|
|
|
85
85
|
exports.instrumentLangChainEmbeddings = bun.instrumentLangChainEmbeddings;
|
|
86
86
|
exports.instrumentLangGraph = bun.instrumentLangGraph;
|
|
87
87
|
exports.instrumentOpenAiClient = bun.instrumentOpenAiClient;
|
|
88
|
+
exports.instrumentStateGraph = bun.instrumentStateGraph;
|
|
88
89
|
exports.instrumentStateGraphCompile = bun.instrumentStateGraphCompile;
|
|
89
90
|
exports.instrumentSupabaseClient = bun.instrumentSupabaseClient;
|
|
90
91
|
exports.isEnabled = bun.isEnabled;
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/cjs/withElysia.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
+
const attributes = require('@sentry/conventions/attributes');
|
|
3
4
|
const core = require('@sentry/core');
|
|
4
5
|
|
|
5
6
|
const ELYSIA_ORIGIN = "auto.http.elysia";
|
|
@@ -21,16 +22,21 @@ const rootSpanForRequest = /* @__PURE__ */ new WeakMap();
|
|
|
21
22
|
const instrumentedApps = /* @__PURE__ */ new WeakSet();
|
|
22
23
|
function updateRouteTransactionName(request, method, route) {
|
|
23
24
|
const transactionName = `${method} ${route}`;
|
|
25
|
+
function applyRouteToSpan(span) {
|
|
26
|
+
core.updateSpanName(span, transactionName);
|
|
27
|
+
span.setAttributes({
|
|
28
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "route",
|
|
29
|
+
[attributes.HTTP_ROUTE]: route
|
|
30
|
+
});
|
|
31
|
+
}
|
|
24
32
|
const rootSpan = rootSpanForRequest.get(request);
|
|
25
33
|
if (rootSpan) {
|
|
26
|
-
|
|
27
|
-
rootSpan.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, "route");
|
|
34
|
+
applyRouteToSpan(rootSpan);
|
|
28
35
|
} else {
|
|
29
36
|
const activeSpan = core.getActiveSpan();
|
|
30
37
|
if (activeSpan) {
|
|
31
38
|
const root = core.getRootSpan(activeSpan);
|
|
32
|
-
|
|
33
|
-
root.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, "route");
|
|
39
|
+
applyRouteToSpan(root);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
core.getIsolationScope().setTransactionName(transactionName);
|
|
@@ -102,7 +108,9 @@ function withElysia(app, options = {}) {
|
|
|
102
108
|
name: `${request.method} ${new URL(request.url).pathname}`,
|
|
103
109
|
attributes: {
|
|
104
110
|
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,
|
|
105
|
-
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "url"
|
|
111
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "url",
|
|
112
|
+
[attributes.URL_FULL]: request.url,
|
|
113
|
+
[attributes.URL_PATH]: new URL(request.url).pathname
|
|
106
114
|
}
|
|
107
115
|
},
|
|
108
116
|
(rootSpan) => {
|
|
@@ -1 +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 { AnyElysia, 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 */\n// Using the AnyElysia type here to allow users to pass in the full set of Elysia\n// options without type errors. The `T extends Elysia` type is too narrow to allow\n// users to pass in dynamic options like `prefix` without breaking the type system.\n// See Elysia type definition and its usage of `const in out` which forces the string\n// template literals to be fully consistent for e.g. `prefix`.\nexport function withElysia<T extends AnyElysia>(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 // Cast from AnyElysia to Elysia so that onAfterHandle/onError callback\n // parameters resolve to typed contexts (e.g. ErrorContext for shouldHandleError).\n // `AnyElysia` is needed on the user-facing `app` type to accept user instances with\n // arbitrary generic args.\n // The cast is safe because AnyElysia IS Elysia<any, any, ...>.\n const elysiaApp = app as unknown as Elysia;\n\n elysiaApp.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 elysiaApp.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":["updateSpanName","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","getActiveSpan","getRootSpan","getIsolationScope","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","withIsolationScope","continueTrace","startSpanManual","winterCGRequestToRequestData","getTraceData","setHttpStatus","captureException"],"mappings":";;;;AAwBA,MAAM,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js","sources":["../../src/withElysia.ts"],"sourcesContent":["import { HTTP_ROUTE, URL_FULL, URL_PATH } from '@sentry/conventions/attributes';\nimport 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 { AnyElysia, 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 function applyRouteToSpan(span: Span): void {\n updateSpanName(span, transactionName);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [HTTP_ROUTE]: route,\n });\n }\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 applyRouteToSpan(rootSpan);\n } else {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const root = getRootSpan(activeSpan);\n applyRouteToSpan(root);\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 */\n// Using the AnyElysia type here to allow users to pass in the full set of Elysia\n// options without type errors. The `T extends Elysia` type is too narrow to allow\n// users to pass in dynamic options like `prefix` without breaking the type system.\n// See Elysia type definition and its usage of `const in out` which forces the string\n// template literals to be fully consistent for e.g. `prefix`.\nexport function withElysia<T extends AnyElysia>(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 [URL_FULL]: request.url,\n [URL_PATH]: new URL(request.url).pathname,\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 // Cast from AnyElysia to Elysia so that onAfterHandle/onError callback\n // parameters resolve to typed contexts (e.g. ErrorContext for shouldHandleError).\n // `AnyElysia` is needed on the user-facing `app` type to accept user instances with\n // arbitrary generic args.\n // The cast is safe because AnyElysia IS Elysia<any, any, ...>.\n const elysiaApp = app as unknown as Elysia;\n\n elysiaApp.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 elysiaApp.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":["updateSpanName","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","HTTP_ROUTE","getActiveSpan","getRootSpan","getIsolationScope","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","withIsolationScope","continueTrace","startSpanManual","URL_FULL","URL_PATH","winterCGRequestToRequestData","getTraceData","setHttpStatus","captureException"],"mappings":";;;;;AAyBA,MAAM,aAAA,GAAgB,kBAAA;AAKtB,MAAM,uBAAA,GAAkD;AAAA,EACtD,OAAA,EAAS,mBAAA;AAAA,EACT,KAAA,EAAO,mBAAA;AAAA,EACP,SAAA,EAAW,mBAAA;AAAA,EACX,YAAA,EAAc,mBA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AA;AAED,EAAA,OAAO,GAAA;AACT;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { NodeClient, OpenFeatureIntegrationHook, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, anthropicAIIntegration, bindScopeToEmitter, buildLaunchDarklyFlagUsedHandler, bunServerIntegration, captureCheckIn, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, connectIntegration, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createGetModuleFromFilename, createLangChainCallbackHandler, createSentryWinstonTransport, createTransport, cron, dataloaderIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eventFiltersIntegration, expressErrorHandler, expressIntegration, fastifyIntegration, featureFlagsIntegration, firebaseIntegration, flush, fsIntegration, functionToStringIntegration, generateInstrumentOnce, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, googleGenAIIntegration, graphqlIntegration, growthbookIntegration, hapiIntegration, honoIntegration, httpHeadersToSpanAttributes, httpIntegration, httpServerIntegration, httpServerSpansIntegration, inboundFiltersIntegration, initOpenTelemetry, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentLangGraph, instrumentOpenAiClient, instrumentStateGraphCompile, instrumentSupabaseClient, isEnabled, isInitialized, kafkaIntegration, knexIntegration, koaIntegration, langChainIntegration, langGraphIntegration, lastEventId, launchDarklyIntegration, linkedErrorsIntegration, localVariablesIntegration, logger, lruMemoizerIntegration, makeFetchTransport, makeNodeTransport, metrics, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, nodeContextIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, openAIIntegration, openFeatureIntegration, parameterize, postgresIntegration, postgresJsIntegration, prismaIntegration, processSessionIntegration, profiler, redisIntegration, requestDataIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupConnectErrorHandler, setupExpressErrorHandler, setupFastifyErrorHandler, setupHapiErrorHandler, setupHonoErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, statsigIntegration, supabaseIntegration, suppressTracing, tediousIntegration, trpcMiddleware, unleashIntegration, updateSpanName, vercelAIIntegration, winterCGHeadersToDict, withActiveSpan, withIsolationScope, withMonitor, withScope, withStreamedSpan, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/bun';
|
|
1
|
+
export { NodeClient, OpenFeatureIntegrationHook, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, anthropicAIIntegration, bindScopeToEmitter, buildLaunchDarklyFlagUsedHandler, bunServerIntegration, captureCheckIn, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, connectIntegration, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createGetModuleFromFilename, createLangChainCallbackHandler, createSentryWinstonTransport, createTransport, cron, dataloaderIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eventFiltersIntegration, expressErrorHandler, expressIntegration, fastifyIntegration, featureFlagsIntegration, firebaseIntegration, flush, fsIntegration, functionToStringIntegration, generateInstrumentOnce, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, googleGenAIIntegration, graphqlIntegration, growthbookIntegration, hapiIntegration, honoIntegration, httpHeadersToSpanAttributes, httpIntegration, httpServerIntegration, httpServerSpansIntegration, inboundFiltersIntegration, initOpenTelemetry, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentLangGraph, instrumentOpenAiClient, instrumentStateGraph, instrumentStateGraphCompile, instrumentSupabaseClient, isEnabled, isInitialized, kafkaIntegration, knexIntegration, koaIntegration, langChainIntegration, langGraphIntegration, lastEventId, launchDarklyIntegration, linkedErrorsIntegration, localVariablesIntegration, logger, lruMemoizerIntegration, makeFetchTransport, makeNodeTransport, metrics, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, nodeContextIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, openAIIntegration, openFeatureIntegration, parameterize, postgresIntegration, postgresJsIntegration, prismaIntegration, processSessionIntegration, profiler, redisIntegration, requestDataIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupConnectErrorHandler, setupExpressErrorHandler, setupFastifyErrorHandler, setupHapiErrorHandler, setupHonoErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, statsigIntegration, supabaseIntegration, suppressTracing, tediousIntegration, trpcMiddleware, unleashIntegration, updateSpanName, vercelAIIntegration, winterCGHeadersToDict, withActiveSpan, withIsolationScope, withMonitor, withScope, withStreamedSpan, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/bun';
|
|
2
2
|
export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration } from '@sentry/core';
|
|
3
3
|
export { withElysia } from './withElysia.js';
|
|
4
4
|
export { getDefaultIntegrations, init } from './sdk.js';
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.69.0","sideEffects":false}
|
package/build/esm/withElysia.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URL_PATH, URL_FULL, HTTP_ROUTE } from '@sentry/conventions/attributes';
|
|
2
|
+
import { withIsolationScope, continueTrace, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan, getRootSpan, getIsolationScope, winterCGRequestToRequestData, getTraceData, setHttpStatus, captureException, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, updateSpanName } from '@sentry/core';
|
|
2
3
|
|
|
3
4
|
const ELYSIA_ORIGIN = "auto.http.elysia";
|
|
4
5
|
const ELYSIA_LIFECYCLE_OP_MAP = {
|
|
@@ -19,16 +20,21 @@ const rootSpanForRequest = /* @__PURE__ */ new WeakMap();
|
|
|
19
20
|
const instrumentedApps = /* @__PURE__ */ new WeakSet();
|
|
20
21
|
function updateRouteTransactionName(request, method, route) {
|
|
21
22
|
const transactionName = `${method} ${route}`;
|
|
23
|
+
function applyRouteToSpan(span) {
|
|
24
|
+
updateSpanName(span, transactionName);
|
|
25
|
+
span.setAttributes({
|
|
26
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "route",
|
|
27
|
+
[HTTP_ROUTE]: route
|
|
28
|
+
});
|
|
29
|
+
}
|
|
22
30
|
const rootSpan = rootSpanForRequest.get(request);
|
|
23
31
|
if (rootSpan) {
|
|
24
|
-
|
|
25
|
-
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, "route");
|
|
32
|
+
applyRouteToSpan(rootSpan);
|
|
26
33
|
} else {
|
|
27
34
|
const activeSpan = getActiveSpan();
|
|
28
35
|
if (activeSpan) {
|
|
29
36
|
const root = getRootSpan(activeSpan);
|
|
30
|
-
|
|
31
|
-
root.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, "route");
|
|
37
|
+
applyRouteToSpan(root);
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
getIsolationScope().setTransactionName(transactionName);
|
|
@@ -100,7 +106,9 @@ function withElysia(app, options = {}) {
|
|
|
100
106
|
name: `${request.method} ${new URL(request.url).pathname}`,
|
|
101
107
|
attributes: {
|
|
102
108
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ELYSIA_ORIGIN,
|
|
103
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "url"
|
|
109
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "url",
|
|
110
|
+
[URL_FULL]: request.url,
|
|
111
|
+
[URL_PATH]: new URL(request.url).pathname
|
|
104
112
|
}
|
|
105
113
|
},
|
|
106
114
|
(rootSpan) => {
|
|
@@ -1 +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 { AnyElysia, 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 */\n// Using the AnyElysia type here to allow users to pass in the full set of Elysia\n// options without type errors. The `T extends Elysia` type is too narrow to allow\n// users to pass in dynamic options like `prefix` without breaking the type system.\n// See Elysia type definition and its usage of `const in out` which forces the string\n// template literals to be fully consistent for e.g. `prefix`.\nexport function withElysia<T extends AnyElysia>(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 // Cast from AnyElysia to Elysia so that onAfterHandle/onError callback\n // parameters resolve to typed contexts (e.g. ErrorContext for shouldHandleError).\n // `AnyElysia` is needed on the user-facing `app` type to accept user instances with\n // arbitrary generic args.\n // The cast is safe because AnyElysia IS Elysia<any, any, ...>.\n const elysiaApp = app as unknown as Elysia;\n\n elysiaApp.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 elysiaApp.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,kBAAA;AAKtB,MAAM,uBAAA,GAAkD;AAAA,EACtD,OAAA,EAAS,mBAAA;AAAA,EACT,KAAA,EAAO,mBAAA;AAAA,EACP,SAAA,EAAW,mBAAA;AAAA,EACX,YAAA,EAAc,mBAAA;AAAA,EACd,MAAA,EAAQ,wBAAA;AAAA,EACR,WAAA,EAAa,mBAAA;AAAA,EACb,WAAA,EAAa,mBAAA;AAAA,EACb,aAAA,EAAe,mBAAA;AAAA,EACf,KAAA,EAAO;AACT,CAAA;AAEA,SAAS,KAAA,GAAiB;AACxB,EAAA,OAAO,OAAO,GAAA,KAAQ,WAAA;AACxB;AAQA,MAAM,kBAAA,uBAAyB,OAAA,EAAuB;AAEtD,MAAM,gBAAA,uBAAuB,OAAA,EAAgB;AAK7C,SAAS,0BAAA,CAA2B,OAAA,EAAkB,MAAA,EAAgB,KAAA,EAAqB;AACzF,EAAA,MAAM,eAAA,GAAkB,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAI1C,EAAA,MAAM,QAAA,GAAW,kBAAA,CAAmB,GAAA,CAAI,OAAO,CAAA;AAC/C,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,cAAA,CAAe,UAAU,eAAe,CAAA;AACxC,IAAA,QAAA,CAAS,YAAA,CAAa,kCAAkC,OAAO,CAAA;AAAA,EACjE,CAAA,MAAO;AACL,IAAA,MAAM,aAAa,aAAA,EAAc;AACjC,IAAA,IAAI,UAAA,EAAY;AACd,MAAA,MAAM,IAAA,GAAO,YAAY,U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MAAA,gBAAA,CAAiB,QAAQ,KAAA,EAAO;AAAA,QAC9B,SAAA,EAAW;AAAA,UACT,IAAA,EAAM,2BAAA;AAAA,UACN,OAAA,EAAS;AAAA;AACX,OACD,CAAA;AAAA,IACH;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,GAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"withElysia.js","sources":["../../src/withElysia.ts"],"sourcesContent":["import { HTTP_ROUTE, URL_FULL, URL_PATH } from '@sentry/conventions/attributes';\nimport 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 { AnyElysia, 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 function applyRouteToSpan(span: Span): void {\n updateSpanName(span, transactionName);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [HTTP_ROUTE]: route,\n });\n }\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 applyRouteToSpan(rootSpan);\n } else {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const root = getRootSpan(activeSpan);\n applyRouteToSpan(root);\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 */\n// Using the AnyElysia type here to allow users to pass in the full set of Elysia\n// options without type errors. The `T extends Elysia` type is too narrow to allow\n// users to pass in dynamic options like `prefix` without breaking the type system.\n// See Elysia type definition and its usage of `const in out` which forces the string\n// template literals to be fully consistent for e.g. `prefix`.\nexport function withElysia<T extends AnyElysia>(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 [URL_FULL]: request.url,\n [URL_PATH]: new URL(request.url).pathname,\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 // Cast from AnyElysia to Elysia so that onAfterHandle/onError callback\n // parameters resolve to typed contexts (e.g. ErrorContext for shouldHandleError).\n // `AnyElysia` is needed on the user-facing `app` type to accept user instances with\n // arbitrary generic args.\n // The cast is safe because AnyElysia IS Elysia<any, any, ...>.\n const elysiaApp = app as unknown as Elysia;\n\n elysiaApp.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 elysiaApp.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":";;;AAyBA,MAAM,aAAA,GAAgB,kBAAA;AAKtB,MAAM,uBAAA,GAAkD;AAAA,EACtD,OAAA,EAAS,mBAAA;AAAA,EACT,KAAA,EAAO,mBAAA;AAAA,EACP,SAAA,EAAW,mBAAA;AAAA,EACX,YAAA,EAAc,mBAAA;AAAA,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/build/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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, setAttribute, setAttributes, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, instrumentLangChainEmbeddings, 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, bindScopeToEmitter, 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, spanStreamingIntegration, withStreamedSpan, bunServerIntegration, makeFetchTransport, } from '@sentry/bun';
|
|
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, setAttribute, setAttributes, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, instrumentLangChainEmbeddings, 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, bindScopeToEmitter, 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, instrumentStateGraph, instrumentLangGraph, instrumentStateGraphCompile, zodErrorsIntegration, profiler, amqplibIntegration, anthropicAIIntegration, googleGenAIIntegration, vercelAIIntegration, logger, consoleLoggingIntegration, createConsolaReporter, createSentryWinstonTransport, wrapMcpServerWithSentry, featureFlagsIntegration, launchDarklyIntegration, growthbookIntegration, buildLaunchDarklyFlagUsedHandler, openFeatureIntegration, OpenFeatureIntegrationHook, statsigIntegration, unleashIntegration, metrics, spanStreamingIntegration, withStreamedSpan, bunServerIntegration, makeFetchTransport, } from '@sentry/bun';
|
|
2
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
3
|
export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, } from '@sentry/core';
|
|
4
4
|
export type { ElysiaOptions } from './types';
|
|
@@ -1 +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,YAAY,EACZ,aAAa,EACb,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,6BAA6B,EAC7B,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,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P,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,uBAAuB,EACvB,MAAM,EACN,kCAAkC,EAClC,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,cAAc,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"}
|
|
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,YAAY,EACZ,aAAa,EACb,OAAO,EACP,yBAAyB,EACzB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,2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BAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,gCAAgC,EAChC,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,uBAAuB,EACvB,MAAM,EACN,kCAAkC,EAClC,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,cAAc,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withElysia.d.ts","sourceRoot":"","sources":["../../src/withElysia.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withElysia.d.ts","sourceRoot":"","sources":["../../src/withElysia.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAU,YAAY,EAA+B,MAAM,QAAQ,CAAC;AAE3F,UAAU,oBAAoB;IAC5B,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC;CACxD;AA+HD;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,wBAAgB,UAAU,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,GAAE,oBAAyB,GAAG,CAAC,CAiK7F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
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, setAttribute, setAttributes, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, instrumentLangChainEmbeddings, 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, bindScopeToEmitter, 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, spanStreamingIntegration, withStreamedSpan, bunServerIntegration, makeFetchTransport, } from '@sentry/bun';
|
|
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, setAttribute, setAttributes, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, instrumentLangChainEmbeddings, 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, bindScopeToEmitter, 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, instrumentStateGraph, instrumentLangGraph, instrumentStateGraphCompile, zodErrorsIntegration, profiler, amqplibIntegration, anthropicAIIntegration, googleGenAIIntegration, vercelAIIntegration, logger, consoleLoggingIntegration, createConsolaReporter, createSentryWinstonTransport, wrapMcpServerWithSentry, featureFlagsIntegration, launchDarklyIntegration, growthbookIntegration, buildLaunchDarklyFlagUsedHandler, openFeatureIntegration, OpenFeatureIntegrationHook, statsigIntegration, unleashIntegration, metrics, spanStreamingIntegration, withStreamedSpan, bunServerIntegration, makeFetchTransport, } from '@sentry/bun';
|
|
2
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
3
|
export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, } from '@sentry/core';
|
|
4
4
|
export { ElysiaOptions } from './types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/elysia",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.69.0",
|
|
4
4
|
"description": "Official Sentry SDK for Elysia",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/elysia",
|
|
@@ -39,8 +39,9 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sentry/bun": "10.
|
|
43
|
-
"@sentry/core": "10.
|
|
42
|
+
"@sentry/bun": "10.69.0",
|
|
43
|
+
"@sentry/core": "10.69.0",
|
|
44
|
+
"@sentry/conventions": "^0.16.0"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"elysia": "^1.4.0"
|