@honeybadger-io/nextjs 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capture-router-transition-start.test.d.ts +2 -0
- package/dist/honeybadger-nextjs-client.cjs.js +5 -1
- package/dist/honeybadger-nextjs-client.cjs.js.map +1 -1
- package/dist/honeybadger-nextjs-client.esm.js +5 -1
- package/dist/honeybadger-nextjs-client.esm.js.map +1 -1
- package/dist/honeybadger-nextjs-edge.cjs.js +15 -1
- package/dist/honeybadger-nextjs-edge.cjs.js.map +1 -1
- package/dist/honeybadger-nextjs-edge.esm.js +15 -1
- package/dist/honeybadger-nextjs-edge.esm.js.map +1 -1
- package/dist/honeybadger-nextjs.cjs.js +20 -2
- package/dist/honeybadger-nextjs.cjs.js.map +1 -1
- package/dist/honeybadger-nextjs.esm.js +20 -2
- package/dist/honeybadger-nextjs.esm.js.map +1 -1
- package/dist/query-filters.test.d.ts +2 -0
- package/package.json +3 -3
- package/src/capture-request-error.test.ts +17 -1
- package/src/capture-request-error.ts +16 -1
- package/src/capture-router-transition-start.test.ts +44 -0
- package/src/capture-router-transition-start.ts +5 -1
- package/src/query-filters.test.ts +67 -0
|
@@ -25,7 +25,11 @@ var Honeybadger__default = /*#__PURE__*/_interopDefaultLegacy(Honeybadger);
|
|
|
25
25
|
* reject.
|
|
26
26
|
*/
|
|
27
27
|
function captureRouterTransitionStart(url, navigationType) {
|
|
28
|
-
|
|
28
|
+
// The message carries the path alone and the full URL goes in the metadata, where the
|
|
29
|
+
// configured `filters` are applied to its query string when the payload is built. This is
|
|
30
|
+
// the same split the browser integration already uses for its XHR and fetch breadcrumbs,
|
|
31
|
+
// whose messages are built from `localURLPathname`.
|
|
32
|
+
Honeybadger__default["default"].addBreadcrumb(`Navigated to ${url.split('?')[0]}`, {
|
|
29
33
|
category: 'navigation',
|
|
30
34
|
metadata: { url, navigationType },
|
|
31
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeybadger-nextjs-client.cjs.js","sources":["../../build/capture-router-transition-start.js"],"sourcesContent":["// Deliberately @honeybadger-io/js, not @honeybadger-io/react. The react package re-exports\n// this exact singleton, but reaching it through there also pulls in the error-boundary class\n// component — and this module sits in the main barrel that `instrumentation.ts` imports on\n// the server, where React Server Components reject a class component outright under\n// Turbopack.\nimport Honeybadger from '@honeybadger-io/js';\n/**\n * Records App Router navigations as breadcrumbs, so a fault carries the trail of routes\n * the user visited before it.\n *\n * Wire it up in `instrumentation-client.ts`:\n *\n * ```ts\n * export const onRouterTransitionStart = captureRouterTransitionStart\n * ```\n *\n * Exported as a ready-made handler rather than left as a function for the template to\n * declare, so the generated file works unchanged as both `.js` and `.ts` — an assignment\n * has no parameters to annotate, so there is no implicit `any` for `noImplicitAny` to\n * reject.\n */\nexport function captureRouterTransitionStart(url, navigationType) {\n Honeybadger.addBreadcrumb(`Navigated to ${url}`, {\n category: 'navigation',\n metadata: { url, navigationType },\n });\n}\n//# sourceMappingURL=capture-router-transition-start.js.map"],"names":["Honeybadger"],"mappings":";;;;;;;;;;AAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,GAAG,EAAE,cAAc,EAAE;AAClE,IAAIA,+BAAW,CAAC,aAAa,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"honeybadger-nextjs-client.cjs.js","sources":["../../build/capture-router-transition-start.js"],"sourcesContent":["// Deliberately @honeybadger-io/js, not @honeybadger-io/react. The react package re-exports\n// this exact singleton, but reaching it through there also pulls in the error-boundary class\n// component — and this module sits in the main barrel that `instrumentation.ts` imports on\n// the server, where React Server Components reject a class component outright under\n// Turbopack.\nimport Honeybadger from '@honeybadger-io/js';\n/**\n * Records App Router navigations as breadcrumbs, so a fault carries the trail of routes\n * the user visited before it.\n *\n * Wire it up in `instrumentation-client.ts`:\n *\n * ```ts\n * export const onRouterTransitionStart = captureRouterTransitionStart\n * ```\n *\n * Exported as a ready-made handler rather than left as a function for the template to\n * declare, so the generated file works unchanged as both `.js` and `.ts` — an assignment\n * has no parameters to annotate, so there is no implicit `any` for `noImplicitAny` to\n * reject.\n */\nexport function captureRouterTransitionStart(url, navigationType) {\n // The message carries the path alone and the full URL goes in the metadata, where the\n // configured `filters` are applied to its query string when the payload is built. This is\n // the same split the browser integration already uses for its XHR and fetch breadcrumbs,\n // whose messages are built from `localURLPathname`.\n Honeybadger.addBreadcrumb(`Navigated to ${url.split('?')[0]}`, {\n category: 'navigation',\n metadata: { url, navigationType },\n });\n}\n//# sourceMappingURL=capture-router-transition-start.js.map"],"names":["Honeybadger"],"mappings":";;;;;;;;;;AAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,GAAG,EAAE,cAAc,EAAE;AAClE;AACA;AACA;AACA;AACA,IAAIA,+BAAW,CAAC,aAAa,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACnE,QAAQ,QAAQ,EAAE,YAAY;AAC9B,QAAQ,QAAQ,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE;AACzC,KAAK,CAAC,CAAC;AACP;;;;"}
|
|
@@ -17,7 +17,11 @@ import Honeybadger from '@honeybadger-io/js';
|
|
|
17
17
|
* reject.
|
|
18
18
|
*/
|
|
19
19
|
function captureRouterTransitionStart(url, navigationType) {
|
|
20
|
-
|
|
20
|
+
// The message carries the path alone and the full URL goes in the metadata, where the
|
|
21
|
+
// configured `filters` are applied to its query string when the payload is built. This is
|
|
22
|
+
// the same split the browser integration already uses for its XHR and fetch breadcrumbs,
|
|
23
|
+
// whose messages are built from `localURLPathname`.
|
|
24
|
+
Honeybadger.addBreadcrumb(`Navigated to ${url.split('?')[0]}`, {
|
|
21
25
|
category: 'navigation',
|
|
22
26
|
metadata: { url, navigationType },
|
|
23
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeybadger-nextjs-client.esm.js","sources":["../../build/capture-router-transition-start.js"],"sourcesContent":["// Deliberately @honeybadger-io/js, not @honeybadger-io/react. The react package re-exports\n// this exact singleton, but reaching it through there also pulls in the error-boundary class\n// component — and this module sits in the main barrel that `instrumentation.ts` imports on\n// the server, where React Server Components reject a class component outright under\n// Turbopack.\nimport Honeybadger from '@honeybadger-io/js';\n/**\n * Records App Router navigations as breadcrumbs, so a fault carries the trail of routes\n * the user visited before it.\n *\n * Wire it up in `instrumentation-client.ts`:\n *\n * ```ts\n * export const onRouterTransitionStart = captureRouterTransitionStart\n * ```\n *\n * Exported as a ready-made handler rather than left as a function for the template to\n * declare, so the generated file works unchanged as both `.js` and `.ts` — an assignment\n * has no parameters to annotate, so there is no implicit `any` for `noImplicitAny` to\n * reject.\n */\nexport function captureRouterTransitionStart(url, navigationType) {\n Honeybadger.addBreadcrumb(`Navigated to ${url}`, {\n category: 'navigation',\n metadata: { url, navigationType },\n });\n}\n//# sourceMappingURL=capture-router-transition-start.js.map"],"names":[],"mappings":";;AAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,GAAG,EAAE,cAAc,EAAE;AAClE,IAAI,WAAW,CAAC,aAAa,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"honeybadger-nextjs-client.esm.js","sources":["../../build/capture-router-transition-start.js"],"sourcesContent":["// Deliberately @honeybadger-io/js, not @honeybadger-io/react. The react package re-exports\n// this exact singleton, but reaching it through there also pulls in the error-boundary class\n// component — and this module sits in the main barrel that `instrumentation.ts` imports on\n// the server, where React Server Components reject a class component outright under\n// Turbopack.\nimport Honeybadger from '@honeybadger-io/js';\n/**\n * Records App Router navigations as breadcrumbs, so a fault carries the trail of routes\n * the user visited before it.\n *\n * Wire it up in `instrumentation-client.ts`:\n *\n * ```ts\n * export const onRouterTransitionStart = captureRouterTransitionStart\n * ```\n *\n * Exported as a ready-made handler rather than left as a function for the template to\n * declare, so the generated file works unchanged as both `.js` and `.ts` — an assignment\n * has no parameters to annotate, so there is no implicit `any` for `noImplicitAny` to\n * reject.\n */\nexport function captureRouterTransitionStart(url, navigationType) {\n // The message carries the path alone and the full URL goes in the metadata, where the\n // configured `filters` are applied to its query string when the payload is built. This is\n // the same split the browser integration already uses for its XHR and fetch breadcrumbs,\n // whose messages are built from `localURLPathname`.\n Honeybadger.addBreadcrumb(`Navigated to ${url.split('?')[0]}`, {\n category: 'navigation',\n metadata: { url, navigationType },\n });\n}\n//# sourceMappingURL=capture-router-transition-start.js.map"],"names":[],"mappings":";;AAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,GAAG,EAAE,cAAc,EAAE;AAClE;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,aAAa,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACnE,QAAQ,QAAQ,EAAE,YAAY;AAC9B,QAAQ,QAAQ,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE;AACzC,KAAK,CAAC,CAAC;AACP;;;;"}
|
|
@@ -240,6 +240,15 @@ function isNextControlFlowError(error) {
|
|
|
240
240
|
const digest = error === null || error === void 0 ? void 0 : error.digest;
|
|
241
241
|
return typeof digest === 'string' && digest.startsWith('NEXT_');
|
|
242
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* The path with any query string removed.
|
|
245
|
+
*
|
|
246
|
+
* Next.js reports `path` with the query attached (`/blog?name=foo`), and this value is
|
|
247
|
+
* written to the user's context, which `filters` never touch.
|
|
248
|
+
*/
|
|
249
|
+
function requestPath(path) {
|
|
250
|
+
return typeof path === 'string' ? path.split('?')[0] : path;
|
|
251
|
+
}
|
|
243
252
|
/**
|
|
244
253
|
* Reports errors passed to Next.js's `onRequestError` instrumentation hook.
|
|
245
254
|
*
|
|
@@ -268,9 +277,14 @@ async function captureRequestError(error, request, context) {
|
|
|
268
277
|
// failed, so it is too late to decorate that request's own events anyway.
|
|
269
278
|
const ids = seedNodeRequestEventContext(request.headers, await activeSpanIds());
|
|
270
279
|
await Honeybadger__default["default"].notifyAsync(error, {
|
|
280
|
+
// The full path, query string included, goes on `url` so the configured `filters` are
|
|
281
|
+
// applied to it -- `filterUrl` runs over this field when the payload is built. Context
|
|
282
|
+
// is deliberately never filtered, since it is the user's own bag, so the copy below is
|
|
283
|
+
// reduced to the bare path rather than repeating an unfiltered query string there.
|
|
284
|
+
url: request.path,
|
|
271
285
|
context: {
|
|
272
286
|
...ids,
|
|
273
|
-
path: request.path,
|
|
287
|
+
path: requestPath(request.path),
|
|
274
288
|
method: request.method,
|
|
275
289
|
router_kind: context.routerKind,
|
|
276
290
|
route_path: context.routePath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeybadger-nextjs-edge.cjs.js","sources":["../../build/flush.js","../../build/insights-instrumentation.js","../../build/capture-request-error.js","../../build/insights.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js';\nimport * as nextServer from 'next/server';\n/**\n * The `waitUntil` primitive the hosting platform injects per request. Next.js\n * resolves `after()` through this same accessor, and it is the only channel\n * available in Pages Router API routes, which are invoked as `(req, res)` with\n * no context argument to read it from.\n */\nexport function requestContextWaitUntil() {\n var _a, _b;\n const context = globalThis[Symbol.for('@next/request-context')];\n const waitUntil = (_b = (_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context)) === null || _b === void 0 ? void 0 : _b.waitUntil;\n return typeof waitUntil === 'function' ? waitUntil : undefined;\n}\n/**\n * Ensure events are delivered before a serverless runtime freezes, without\n * delaying the response where the runtime lets us avoid it.\n *\n * In order of preference: Next.js `after()` (App Router only — it needs App Router\n * request context, so Pages Router must not call it), then a `waitUntil` from the\n * platform request context, then a blocking `flushAsync()` when the runtime offers\n * neither.\n *\n * Delivery failures are logged by the events worker and must not break the handler.\n */\nexport function scheduleFlush(options = {}) {\n var _a;\n const flush = () => Honeybadger.flushAsync().catch(() => { });\n if (options.useAfter) {\n const after = nextServer.after;\n if (typeof after === 'function') {\n // Exported but still refusable: `after()` throws outside a supported\n // context. Fall through to the remaining strategies rather than failing\n // the request.\n try {\n after(flush);\n return;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // try waitUntil / blocking flush below\n }\n }\n }\n const waitUntil = (_a = options.waitUntil) !== null && _a !== void 0 ? _a : requestContextWaitUntil();\n if (waitUntil) {\n waitUntil(flush());\n return;\n }\n return flush();\n}\n//# sourceMappingURL=flush.js.map","import Honeybadger from '@honeybadger-io/js';\n/**\n * Edge-safe equivalents of the inbound instrumentation helpers in\n * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are\n * duplicated here because this module must load in every runtime where\n * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep\n * the header names and the `request_id` / `correlation_id` contract in sync\n * with that file.\n *\n * Both request shapes Next.js uses are supported: the `*RequestEventContext` /\n * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router\n * route handlers and middleware) and a Node-bag variant (Pages Router API\n * routes, which only ever run on the Node runtime).\n */\nfunction generateId() {\n const webCrypto = globalThis.crypto;\n if (webCrypto && typeof webCrypto.randomUUID === 'function') {\n try {\n return webCrypto.randomUUID();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // fall through to manual generation\n }\n }\n // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,\n // not a security token.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nfunction readHeader(headers, name) {\n const value = headers.get(name);\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\nfunction readNodeHeader(headers, name) {\n if (!headers) {\n return undefined;\n }\n const lower = name.toLowerCase();\n let value = headers[lower];\n if (value === undefined) {\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === lower) {\n value = headers[key];\n break;\n }\n }\n }\n if (Array.isArray(value)) {\n value = value[0];\n }\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\n/**\n * Shared id precedence. Kept in one place (rather than once per request shape)\n * so the header-name contract documented above is only spelled out once.\n *\n * The span ids do double duty. They are emitted as `trace_id` / `span_id`, and they also\n * back-fill `request_id` / `correlation_id` when no header supplied them — a trace id\n * already has exactly the semantics we want for a correlation id, since W3C trace context\n * reuses an inbound `traceparent` and mints a new one when there is none.\n *\n * That double duty is what makes a fault joinable to its request's events: both paths seed\n * from the same span, so with no id headers present a fault and its `request.handled` event\n * carry identical values for all four.\n */\nfunction seedIds(read, span = {}) {\n var _a, _b, _c, _d, _e, _f;\n const requestId = (_c = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : span.spanId) !== null && _c !== void 0 ? _c : generateId();\n const correlationId = (_f = (_e = (_d = read('x-correlation-id')) !== null && _d !== void 0 ? _d : read('x-amzn-trace-id')) !== null && _e !== void 0 ? _e : span.traceId) !== null && _f !== void 0 ? _f : requestId;\n const ids = { request_id: requestId, correlation_id: correlationId };\n if (span.traceId) {\n ids.trace_id = span.traceId;\n }\n if (span.spanId) {\n ids.span_id = span.spanId;\n }\n return ids;\n}\n/**\n * The active span's ids, or an empty object when OpenTelemetry is not in play.\n *\n * `@opentelemetry/api` is an optional peer dependency, and this module is reachable from\n * every runtime entry point, so it is loaded on demand and any failure to resolve it is\n * treated as \"no tracing configured\" rather than an error.\n */\nexport async function activeSpanIds() {\n var _a;\n try {\n const { trace } = await import('@opentelemetry/api');\n const spanContext = (_a = trace.getActiveSpan()) === null || _a === void 0 ? void 0 : _a.spanContext();\n if (!spanContext) {\n return {};\n }\n return { traceId: spanContext.traceId, spanId: spanContext.spanId };\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n return {};\n }\n}\n// App Router / middleware: headers are a web `Headers` instance.\nexport function seedRequestEventContext(headers, span = {}) {\n return seedIds((name) => readHeader(headers, name), span);\n}\n// Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).\nexport function seedNodeRequestEventContext(headers, span = {}) {\n return seedIds((name) => readNodeHeader(headers, name), span);\n}\nexport function now() {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n// Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and\n// the per-source flag must both be on.\nexport function insightsHttpEnabled() {\n const insights = Honeybadger.config.insights;\n return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;\n}\n// The ids are embedded directly in the payload (instead of relying on the\n// store's eventContext merge) so the event carries them even where the\n// runtime, where there is no per-request store isolation. On the Node.js\n// runtime they match the seeded event context, so embedding is a no-op.\nfunction emitHandledEvent(method, path, status, start, ids) {\n const payload = {\n method,\n duration: Math.round(now() - start),\n ...ids,\n };\n if (typeof path === 'string') {\n payload.path = path;\n }\n if (typeof status === 'number') {\n payload.status = status;\n }\n Honeybadger.event('request.handled', payload);\n}\n// App Router / middleware: `req.url` is absolute, so parse out the pathname.\nexport function emitRequestEvent(req, status, start, ids) {\n let path;\n try {\n path = new URL(req.url).pathname;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // relative or malformed URL — leave path unset\n }\n emitHandledEvent(req.method, path, status, start, ids);\n}\n// Pages Router: `req.url` is a relative path that may carry a query string.\nexport function emitNodeRequestEvent(req, status, start, ids) {\n const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;\n emitHandledEvent(req.method, path, status, start, ids);\n}\n/**\n * OpenTelemetry path. Header values are not on the span by default; they arrive as\n * `http.request.header.*` attributes when the HTTP instrumentation is configured with\n * `headersToSpanAttributes`. Hyphens become underscores under the older semantic\n * conventions and are preserved under the stable ones, so both spellings are read.\n *\n * When no header is present the span and trace ids are used, so the ids stay\n * meaningful — and joinable to a trace — on platforms where the HTTP layer is not\n * visible, such as serverless platforms.\n */\nexport function seedSpanEventContext(attributes, spanContext) {\n const read = (name) => {\n const lower = name.toLowerCase();\n for (const key of [\n `http.request.header.${lower}`,\n `http.request.header.${lower.replace(/-/g, '_')}`,\n ]) {\n const value = attributes[key];\n const first = Array.isArray(value) ? value[0] : value;\n if (typeof first === 'string' && first.trim().length) {\n return first.trim();\n }\n }\n return undefined;\n };\n return seedIds(read, {\n traceId: spanContext.traceId || undefined,\n spanId: spanContext.spanId || undefined,\n });\n}\n//# sourceMappingURL=insights-instrumentation.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { scheduleFlush } from './flush';\nimport { activeSpanIds, seedNodeRequestEventContext } from './insights-instrumentation';\n/**\n * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,\n * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`\n * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).\n * These are not real failures — the framework catches them upstream to produce\n * the redirect/404/etc. — so we must let them pass without reporting, otherwise\n * every redirect shows up as an error in Honeybadger.\n *\n * We match on the `NEXT_` prefix rather than an exhaustive list so that any\n * present or future framework control-flow digest is covered. This is safe:\n * genuine errors that React tags with a `digest` use an opaque hash, and other\n * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,\n * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.\n */\nfunction isNextControlFlowError(error) {\n const digest = error === null || error === void 0 ? void 0 : error.digest;\n return typeof digest === 'string' && digest.startsWith('NEXT_');\n}\n/**\n * Reports errors passed to Next.js's `onRequestError` instrumentation hook.\n *\n * Wire it up in `instrumentation.ts`:\n *\n * ```ts\n * export const onRequestError = captureRequestError\n * ```\n *\n * Reaches Server Components, Route Handlers, Server Actions and middleware, and receives\n * the real error rather than the generic message Next.js hands to an error component.\n */\nexport async function captureRequestError(error, request, context) {\n if (isNextControlFlowError(error)) {\n return;\n }\n // Same header precedence *and* the same span as the Insights path, so a fault and the\n // events from the request it failed in carry matching ids. Next.js still has the request\n // span active when it calls this hook, and it is the very span the Insights processor\n // maps to `request.handled` — so with no id headers present all four ids are identical on\n // both, and the fault joins its request's events and trace.\n //\n // Deliberately not written to the event context: outside a `Honeybadger.run()` that\n // lands on a store shared by the whole process or isolate, so the ids would leak into\n // later requests' events. `onRequestError` also fires after the request has already\n // failed, so it is too late to decorate that request's own events anyway.\n const ids = seedNodeRequestEventContext(request.headers, await activeSpanIds());\n await Honeybadger.notifyAsync(error, {\n context: {\n ...ids,\n path: request.path,\n method: request.method,\n router_kind: context.routerKind,\n route_path: context.routePath,\n route_type: context.routeType,\n },\n });\n await scheduleFlush({ useAfter: true });\n}\n//# sourceMappingURL=capture-request-error.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { insightsHttpEnabled, seedSpanEventContext } from './insights-instrumentation';\nimport { scheduleFlush } from './flush';\n/**\n * Next.js instruments itself with OpenTelemetry and emits one root span per request,\n * `[http.method] [next.route]`, tagged `next.span_type: BaseServer.handleRequest`. Its\n * attributes carry the method, route, target and status, so mapping that span to a\n * `request.handled` event reports every request without wrapping any handler.\n *\n * Next instruments but does not export: spans only reach us once a tracer provider with\n * this processor is registered. See `registerHoneybadgerInsights`.\n */\nconst NEXT_REQUEST_SPAN_TYPE = 'BaseServer.handleRequest';\n/**\n * Request headers to copy onto the root span, so `request_id` and `correlation_id` can be\n * reused from an inbound request instead of falling back to the span and trace ids.\n *\n * Header values are not span attributes by default. `@vercel/otel` applies this map when\n * it creates the root span, which is the span this processor reads — and, unlike Node's\n * HTTP instrumentation, it works on serverless platforms too.\n *\n * Spread it into your own `registerOTel` call if you register OpenTelemetry yourself:\n *\n * ```ts\n * registerOTel({\n * attributesFromHeaders: { ...HONEYBADGER_HEADER_ATTRIBUTES },\n * spanProcessors: [honeybadgerSpanProcessor()],\n * })\n * ```\n *\n * Keep the header names in sync with `seedIds` in ./insights-instrumentation.\n */\nexport const HONEYBADGER_HEADER_ATTRIBUTES = {\n 'http.request.header.x-request-id': 'x-request-id',\n 'http.request.header.request-id': 'request-id',\n 'http.request.header.x-correlation-id': 'x-correlation-id',\n 'http.request.header.x-amzn-trace-id': 'x-amzn-trace-id',\n};\nfunction readString(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'string' && value.length) {\n return value;\n }\n }\n return undefined;\n}\nfunction readNumber(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'number') {\n return value;\n }\n if (typeof value === 'string' && value.trim().length && Number.isFinite(Number(value))) {\n return Number(value);\n }\n }\n return undefined;\n}\nfunction durationMs(duration) {\n if (!Array.isArray(duration) || duration.length !== 2) {\n return 0;\n }\n const [seconds, nanos] = duration;\n return Math.round(seconds * 1000 + nanos / 1e6);\n}\n/**\n * Path without the query string. `http.target` includes the query under the older\n * semantic conventions; `url.path` is already bare under the stable ones.\n */\nfunction readPath(attributes) {\n const target = readString(attributes, 'url.path', 'http.target');\n return typeof target === 'string' ? target.split('?')[0] : undefined;\n}\n/**\n * Maps Next.js's per-request span to a Honeybadger `request.handled` Insights event.\n *\n * Pass it to whatever registers OpenTelemetry in your `instrumentation.ts`:\n *\n * ```ts\n * import { registerOTel } from '@vercel/otel'\n * import { honeybadgerSpanProcessor } from '@honeybadger-io/nextjs'\n *\n * export function register() {\n * registerOTel({ serviceName: 'my-app', spanProcessors: [honeybadgerSpanProcessor()] })\n * }\n * ```\n *\n * `registerHoneybadgerInsights()` is the one-line equivalent when you have no other\n * OpenTelemetry setup of your own.\n */\nexport function honeybadgerSpanProcessor() {\n return {\n onStart() {\n // Nothing to do: the event is emitted once the request span is complete, which is\n // when the status and duration are known.\n },\n onEnd(span) {\n var _a;\n const attributes = (_a = span.attributes) !== null && _a !== void 0 ? _a : {};\n if (attributes['next.span_type'] !== NEXT_REQUEST_SPAN_TYPE) {\n return;\n }\n // Checked per event rather than at registration: configuration is loaded by\n // `register()` importing the honeybadger config files, which may happen after the\n // processor is constructed.\n if (!insightsHttpEnabled()) {\n return;\n }\n const spanContext = typeof span.spanContext === 'function' ? span.spanContext() : {};\n const ids = seedSpanEventContext(attributes, spanContext !== null && spanContext !== void 0 ? spanContext : {});\n const payload = {\n method: readString(attributes, 'http.request.method', 'http.method'),\n duration: durationMs(span.duration),\n ...ids,\n };\n const path = readPath(attributes);\n if (path) {\n payload.path = path;\n }\n const status = readNumber(attributes, 'http.response.status_code', 'http.status_code');\n if (typeof status === 'number') {\n payload.status = status;\n }\n // Emitted alongside the ids rather than replacing them, so an event can be joined\n // to a trace in another tool without changing what existing consumers read.\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.traceId) {\n payload.trace_id = spanContext.traceId;\n }\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.spanId) {\n payload.span_id = spanContext.spanId;\n }\n Honeybadger.event('request.handled', payload);\n // A span processor batches on its own lifecycle, which is not enough on a platform\n // that can freeze the invocation as soon as the response is sent.\n scheduleFlush({ useAfter: true });\n },\n async forceFlush() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n async shutdown() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n };\n}\n/**\n * Registers OpenTelemetry with only Honeybadger's span processor attached, for apps that\n * have no OpenTelemetry setup of their own. Call it from `register()` in\n * `instrumentation.ts`.\n *\n * `@vercel/otel` is an optional peer dependency: it is only needed for Insights, and it\n * loads where the full Node SDK cannot, such as serverless platforms. If you\n * already call `registerOTel` yourself, add `honeybadgerSpanProcessor()` to your\n * `spanProcessors` instead of calling this — registering twice would compete for the\n * global provider.\n */\nexport async function registerHoneybadgerInsights(options = {}) {\n var _a, _b;\n let registerOTel;\n try {\n ({ registerOTel } = await import('@vercel/otel'));\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n Honeybadger.logger.error('[Honeybadger] Insights request events need @vercel/otel. Install it, or drop the ' +\n 'registerHoneybadgerInsights() call — error reporting works without it.');\n return;\n }\n registerOTel({\n serviceName: (_b = (_a = options.serviceName) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_HONEYBADGER_SERVICE_NAME) !== null && _b !== void 0 ? _b : 'nextjs-app',\n // Without this the id headers never reach the span, so request_id and\n // correlation_id would always fall back to the span and trace ids.\n attributesFromHeaders: {\n ...HONEYBADGER_HEADER_ATTRIBUTES,\n ...options.attributesFromHeaders,\n },\n spanProcessors: [honeybadgerSpanProcessor()],\n });\n}\n//# sourceMappingURL=insights.js.map"],"names":["Honeybadger","nextServer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,GAAG;AAC1C,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC;AACpE,IAAI,MAAM,SAAS,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;AAC1M,IA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MAAM,QAAQ,GAAG;AACzB,YAAY,MAAMA,+BAAW,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAC5D,SAAS;AACT,KAAK,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,2BAA2B,CAAC,OAAO,GAAG,EAAE,EAAE;AAChE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,IAAI,YAAY,CAAC;AACrB,IAAI,IAAI;AACR,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,MAAM,mFAAO,cAAc,MAAC,EAAE;AAC1D,KAAK;AACL;AACA,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQA,+BAAW,CAAC,MAAM,CAAC,KAAK,CAAC,mFAAmF;AACpH,YAAY,wEAAwE,CAAC,CAAC;AACtF,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,YAAY,CAAC;AACjB,QAAQ,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,WAAW,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,YAAY;AACtL;AACA;AACA,QAAQ,qBAAqB,EAAE;AAC/B,YAAY,GAAG,6BAA6B;AAC5C,YAAY,GAAG,OAAO,CAAC,qBAAqB;AAC5C,SAAS;AACT,QAAQ,cAAc,EAAE,CAAC,wBAAwB,EAAE,CAAC;AACpD,KAAK,CAAC,CAAC;AACP;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"honeybadger-nextjs-edge.cjs.js","sources":["../../build/flush.js","../../build/insights-instrumentation.js","../../build/capture-request-error.js","../../build/insights.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js';\nimport * as nextServer from 'next/server';\n/**\n * The `waitUntil` primitive the hosting platform injects per request. Next.js\n * resolves `after()` through this same accessor, and it is the only channel\n * available in Pages Router API routes, which are invoked as `(req, res)` with\n * no context argument to read it from.\n */\nexport function requestContextWaitUntil() {\n var _a, _b;\n const context = globalThis[Symbol.for('@next/request-context')];\n const waitUntil = (_b = (_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context)) === null || _b === void 0 ? void 0 : _b.waitUntil;\n return typeof waitUntil === 'function' ? waitUntil : undefined;\n}\n/**\n * Ensure events are delivered before a serverless runtime freezes, without\n * delaying the response where the runtime lets us avoid it.\n *\n * In order of preference: Next.js `after()` (App Router only — it needs App Router\n * request context, so Pages Router must not call it), then a `waitUntil` from the\n * platform request context, then a blocking `flushAsync()` when the runtime offers\n * neither.\n *\n * Delivery failures are logged by the events worker and must not break the handler.\n */\nexport function scheduleFlush(options = {}) {\n var _a;\n const flush = () => Honeybadger.flushAsync().catch(() => { });\n if (options.useAfter) {\n const after = nextServer.after;\n if (typeof after === 'function') {\n // Exported but still refusable: `after()` throws outside a supported\n // context. Fall through to the remaining strategies rather than failing\n // the request.\n try {\n after(flush);\n return;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // try waitUntil / blocking flush below\n }\n }\n }\n const waitUntil = (_a = options.waitUntil) !== null && _a !== void 0 ? _a : requestContextWaitUntil();\n if (waitUntil) {\n waitUntil(flush());\n return;\n }\n return flush();\n}\n//# sourceMappingURL=flush.js.map","import Honeybadger from '@honeybadger-io/js';\n/**\n * Edge-safe equivalents of the inbound instrumentation helpers in\n * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are\n * duplicated here because this module must load in every runtime where\n * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep\n * the header names and the `request_id` / `correlation_id` contract in sync\n * with that file.\n *\n * Both request shapes Next.js uses are supported: the `*RequestEventContext` /\n * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router\n * route handlers and middleware) and a Node-bag variant (Pages Router API\n * routes, which only ever run on the Node runtime).\n */\nfunction generateId() {\n const webCrypto = globalThis.crypto;\n if (webCrypto && typeof webCrypto.randomUUID === 'function') {\n try {\n return webCrypto.randomUUID();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // fall through to manual generation\n }\n }\n // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,\n // not a security token.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nfunction readHeader(headers, name) {\n const value = headers.get(name);\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\nfunction readNodeHeader(headers, name) {\n if (!headers) {\n return undefined;\n }\n const lower = name.toLowerCase();\n let value = headers[lower];\n if (value === undefined) {\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === lower) {\n value = headers[key];\n break;\n }\n }\n }\n if (Array.isArray(value)) {\n value = value[0];\n }\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\n/**\n * Shared id precedence. Kept in one place (rather than once per request shape)\n * so the header-name contract documented above is only spelled out once.\n *\n * The span ids do double duty. They are emitted as `trace_id` / `span_id`, and they also\n * back-fill `request_id` / `correlation_id` when no header supplied them — a trace id\n * already has exactly the semantics we want for a correlation id, since W3C trace context\n * reuses an inbound `traceparent` and mints a new one when there is none.\n *\n * That double duty is what makes a fault joinable to its request's events: both paths seed\n * from the same span, so with no id headers present a fault and its `request.handled` event\n * carry identical values for all four.\n */\nfunction seedIds(read, span = {}) {\n var _a, _b, _c, _d, _e, _f;\n const requestId = (_c = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : span.spanId) !== null && _c !== void 0 ? _c : generateId();\n const correlationId = (_f = (_e = (_d = read('x-correlation-id')) !== null && _d !== void 0 ? _d : read('x-amzn-trace-id')) !== null && _e !== void 0 ? _e : span.traceId) !== null && _f !== void 0 ? _f : requestId;\n const ids = { request_id: requestId, correlation_id: correlationId };\n if (span.traceId) {\n ids.trace_id = span.traceId;\n }\n if (span.spanId) {\n ids.span_id = span.spanId;\n }\n return ids;\n}\n/**\n * The active span's ids, or an empty object when OpenTelemetry is not in play.\n *\n * `@opentelemetry/api` is an optional peer dependency, and this module is reachable from\n * every runtime entry point, so it is loaded on demand and any failure to resolve it is\n * treated as \"no tracing configured\" rather than an error.\n */\nexport async function activeSpanIds() {\n var _a;\n try {\n const { trace } = await import('@opentelemetry/api');\n const spanContext = (_a = trace.getActiveSpan()) === null || _a === void 0 ? void 0 : _a.spanContext();\n if (!spanContext) {\n return {};\n }\n return { traceId: spanContext.traceId, spanId: spanContext.spanId };\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n return {};\n }\n}\n// App Router / middleware: headers are a web `Headers` instance.\nexport function seedRequestEventContext(headers, span = {}) {\n return seedIds((name) => readHeader(headers, name), span);\n}\n// Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).\nexport function seedNodeRequestEventContext(headers, span = {}) {\n return seedIds((name) => readNodeHeader(headers, name), span);\n}\nexport function now() {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n// Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and\n// the per-source flag must both be on.\nexport function insightsHttpEnabled() {\n const insights = Honeybadger.config.insights;\n return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;\n}\n// The ids are embedded directly in the payload (instead of relying on the\n// store's eventContext merge) so the event carries them even where the\n// runtime, where there is no per-request store isolation. On the Node.js\n// runtime they match the seeded event context, so embedding is a no-op.\nfunction emitHandledEvent(method, path, status, start, ids) {\n const payload = {\n method,\n duration: Math.round(now() - start),\n ...ids,\n };\n if (typeof path === 'string') {\n payload.path = path;\n }\n if (typeof status === 'number') {\n payload.status = status;\n }\n Honeybadger.event('request.handled', payload);\n}\n// App Router / middleware: `req.url` is absolute, so parse out the pathname.\nexport function emitRequestEvent(req, status, start, ids) {\n let path;\n try {\n path = new URL(req.url).pathname;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // relative or malformed URL — leave path unset\n }\n emitHandledEvent(req.method, path, status, start, ids);\n}\n// Pages Router: `req.url` is a relative path that may carry a query string.\nexport function emitNodeRequestEvent(req, status, start, ids) {\n const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;\n emitHandledEvent(req.method, path, status, start, ids);\n}\n/**\n * OpenTelemetry path. Header values are not on the span by default; they arrive as\n * `http.request.header.*` attributes when the HTTP instrumentation is configured with\n * `headersToSpanAttributes`. Hyphens become underscores under the older semantic\n * conventions and are preserved under the stable ones, so both spellings are read.\n *\n * When no header is present the span and trace ids are used, so the ids stay\n * meaningful — and joinable to a trace — on platforms where the HTTP layer is not\n * visible, such as serverless platforms.\n */\nexport function seedSpanEventContext(attributes, spanContext) {\n const read = (name) => {\n const lower = name.toLowerCase();\n for (const key of [\n `http.request.header.${lower}`,\n `http.request.header.${lower.replace(/-/g, '_')}`,\n ]) {\n const value = attributes[key];\n const first = Array.isArray(value) ? value[0] : value;\n if (typeof first === 'string' && first.trim().length) {\n return first.trim();\n }\n }\n return undefined;\n };\n return seedIds(read, {\n traceId: spanContext.traceId || undefined,\n spanId: spanContext.spanId || undefined,\n });\n}\n//# sourceMappingURL=insights-instrumentation.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { scheduleFlush } from './flush';\nimport { activeSpanIds, seedNodeRequestEventContext } from './insights-instrumentation';\n/**\n * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,\n * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`\n * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).\n * These are not real failures — the framework catches them upstream to produce\n * the redirect/404/etc. — so we must let them pass without reporting, otherwise\n * every redirect shows up as an error in Honeybadger.\n *\n * We match on the `NEXT_` prefix rather than an exhaustive list so that any\n * present or future framework control-flow digest is covered. This is safe:\n * genuine errors that React tags with a `digest` use an opaque hash, and other\n * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,\n * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.\n */\nfunction isNextControlFlowError(error) {\n const digest = error === null || error === void 0 ? void 0 : error.digest;\n return typeof digest === 'string' && digest.startsWith('NEXT_');\n}\n/**\n * The path with any query string removed.\n *\n * Next.js reports `path` with the query attached (`/blog?name=foo`), and this value is\n * written to the user's context, which `filters` never touch.\n */\nfunction requestPath(path) {\n return typeof path === 'string' ? path.split('?')[0] : path;\n}\n/**\n * Reports errors passed to Next.js's `onRequestError` instrumentation hook.\n *\n * Wire it up in `instrumentation.ts`:\n *\n * ```ts\n * export const onRequestError = captureRequestError\n * ```\n *\n * Reaches Server Components, Route Handlers, Server Actions and middleware, and receives\n * the real error rather than the generic message Next.js hands to an error component.\n */\nexport async function captureRequestError(error, request, context) {\n if (isNextControlFlowError(error)) {\n return;\n }\n // Same header precedence *and* the same span as the Insights path, so a fault and the\n // events from the request it failed in carry matching ids. Next.js still has the request\n // span active when it calls this hook, and it is the very span the Insights processor\n // maps to `request.handled` — so with no id headers present all four ids are identical on\n // both, and the fault joins its request's events and trace.\n //\n // Deliberately not written to the event context: outside a `Honeybadger.run()` that\n // lands on a store shared by the whole process or isolate, so the ids would leak into\n // later requests' events. `onRequestError` also fires after the request has already\n // failed, so it is too late to decorate that request's own events anyway.\n const ids = seedNodeRequestEventContext(request.headers, await activeSpanIds());\n await Honeybadger.notifyAsync(error, {\n // The full path, query string included, goes on `url` so the configured `filters` are\n // applied to it -- `filterUrl` runs over this field when the payload is built. Context\n // is deliberately never filtered, since it is the user's own bag, so the copy below is\n // reduced to the bare path rather than repeating an unfiltered query string there.\n url: request.path,\n context: {\n ...ids,\n path: requestPath(request.path),\n method: request.method,\n router_kind: context.routerKind,\n route_path: context.routePath,\n route_type: context.routeType,\n },\n });\n await scheduleFlush({ useAfter: true });\n}\n//# sourceMappingURL=capture-request-error.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { insightsHttpEnabled, seedSpanEventContext } from './insights-instrumentation';\nimport { scheduleFlush } from './flush';\n/**\n * Next.js instruments itself with OpenTelemetry and emits one root span per request,\n * `[http.method] [next.route]`, tagged `next.span_type: BaseServer.handleRequest`. Its\n * attributes carry the method, route, target and status, so mapping that span to a\n * `request.handled` event reports every request without wrapping any handler.\n *\n * Next instruments but does not export: spans only reach us once a tracer provider with\n * this processor is registered. See `registerHoneybadgerInsights`.\n */\nconst NEXT_REQUEST_SPAN_TYPE = 'BaseServer.handleRequest';\n/**\n * Request headers to copy onto the root span, so `request_id` and `correlation_id` can be\n * reused from an inbound request instead of falling back to the span and trace ids.\n *\n * Header values are not span attributes by default. `@vercel/otel` applies this map when\n * it creates the root span, which is the span this processor reads — and, unlike Node's\n * HTTP instrumentation, it works on serverless platforms too.\n *\n * Spread it into your own `registerOTel` call if you register OpenTelemetry yourself:\n *\n * ```ts\n * registerOTel({\n * attributesFromHeaders: { ...HONEYBADGER_HEADER_ATTRIBUTES },\n * spanProcessors: [honeybadgerSpanProcessor()],\n * })\n * ```\n *\n * Keep the header names in sync with `seedIds` in ./insights-instrumentation.\n */\nexport const HONEYBADGER_HEADER_ATTRIBUTES = {\n 'http.request.header.x-request-id': 'x-request-id',\n 'http.request.header.request-id': 'request-id',\n 'http.request.header.x-correlation-id': 'x-correlation-id',\n 'http.request.header.x-amzn-trace-id': 'x-amzn-trace-id',\n};\nfunction readString(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'string' && value.length) {\n return value;\n }\n }\n return undefined;\n}\nfunction readNumber(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'number') {\n return value;\n }\n if (typeof value === 'string' && value.trim().length && Number.isFinite(Number(value))) {\n return Number(value);\n }\n }\n return undefined;\n}\nfunction durationMs(duration) {\n if (!Array.isArray(duration) || duration.length !== 2) {\n return 0;\n }\n const [seconds, nanos] = duration;\n return Math.round(seconds * 1000 + nanos / 1e6);\n}\n/**\n * Path without the query string. `http.target` includes the query under the older\n * semantic conventions; `url.path` is already bare under the stable ones.\n */\nfunction readPath(attributes) {\n const target = readString(attributes, 'url.path', 'http.target');\n return typeof target === 'string' ? target.split('?')[0] : undefined;\n}\n/**\n * Maps Next.js's per-request span to a Honeybadger `request.handled` Insights event.\n *\n * Pass it to whatever registers OpenTelemetry in your `instrumentation.ts`:\n *\n * ```ts\n * import { registerOTel } from '@vercel/otel'\n * import { honeybadgerSpanProcessor } from '@honeybadger-io/nextjs'\n *\n * export function register() {\n * registerOTel({ serviceName: 'my-app', spanProcessors: [honeybadgerSpanProcessor()] })\n * }\n * ```\n *\n * `registerHoneybadgerInsights()` is the one-line equivalent when you have no other\n * OpenTelemetry setup of your own.\n */\nexport function honeybadgerSpanProcessor() {\n return {\n onStart() {\n // Nothing to do: the event is emitted once the request span is complete, which is\n // when the status and duration are known.\n },\n onEnd(span) {\n var _a;\n const attributes = (_a = span.attributes) !== null && _a !== void 0 ? _a : {};\n if (attributes['next.span_type'] !== NEXT_REQUEST_SPAN_TYPE) {\n return;\n }\n // Checked per event rather than at registration: configuration is loaded by\n // `register()` importing the honeybadger config files, which may happen after the\n // processor is constructed.\n if (!insightsHttpEnabled()) {\n return;\n }\n const spanContext = typeof span.spanContext === 'function' ? span.spanContext() : {};\n const ids = seedSpanEventContext(attributes, spanContext !== null && spanContext !== void 0 ? spanContext : {});\n const payload = {\n method: readString(attributes, 'http.request.method', 'http.method'),\n duration: durationMs(span.duration),\n ...ids,\n };\n const path = readPath(attributes);\n if (path) {\n payload.path = path;\n }\n const status = readNumber(attributes, 'http.response.status_code', 'http.status_code');\n if (typeof status === 'number') {\n payload.status = status;\n }\n // Emitted alongside the ids rather than replacing them, so an event can be joined\n // to a trace in another tool without changing what existing consumers read.\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.traceId) {\n payload.trace_id = spanContext.traceId;\n }\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.spanId) {\n payload.span_id = spanContext.spanId;\n }\n Honeybadger.event('request.handled', payload);\n // A span processor batches on its own lifecycle, which is not enough on a platform\n // that can freeze the invocation as soon as the response is sent.\n scheduleFlush({ useAfter: true });\n },\n async forceFlush() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n async shutdown() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n };\n}\n/**\n * Registers OpenTelemetry with only Honeybadger's span processor attached, for apps that\n * have no OpenTelemetry setup of their own. Call it from `register()` in\n * `instrumentation.ts`.\n *\n * `@vercel/otel` is an optional peer dependency: it is only needed for Insights, and it\n * loads where the full Node SDK cannot, such as serverless platforms. If you\n * already call `registerOTel` yourself, add `honeybadgerSpanProcessor()` to your\n * `spanProcessors` instead of calling this — registering twice would compete for the\n * global provider.\n */\nexport async function registerHoneybadgerInsights(options = {}) {\n var _a, _b;\n let registerOTel;\n try {\n ({ registerOTel } = await import('@vercel/otel'));\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n Honeybadger.logger.error('[Honeybadger] Insights request events need @vercel/otel. Install it, or drop the ' +\n 'registerHoneybadgerInsights() call — error reporting works without it.');\n return;\n }\n registerOTel({\n serviceName: (_b = (_a = options.serviceName) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_HONEYBADGER_SERVICE_NAME) !== null && _b !== void 0 ? _b : 'nextjs-app',\n // Without this the id headers never reach the span, so request_id and\n // correlation_id would always fall back to the span and trace ids.\n attributesFromHeaders: {\n ...HONEYBADGER_HEADER_ATTRIBUTES,\n ...options.attributesFromHeaders,\n },\n spanProcessors: [honeybadgerSpanProcessor()],\n });\n}\n//# sourceMappingURL=insights.js.map"],"names":["Honeybadger","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,EAAE,YAAY,EAAE,GAAG,MAAM,mFAAO,cAAc,MAAC,EAAE;AAC1D,KAAK;AACL;AACA,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQA,+BAAW,CAAC,MAAM,CAAC,KAAK,CAAC,mFAAmF;AACpH,YAAY,wEAAwE,CAAC,CAAC;AACtF,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,YAAY,CAAC;AACjB,QAAQ,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,WAAW,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,YAAY;AACtL;AACA;AACA,QAAQ,qBAAqB,EAAE;AAC/B,YAAY,GAAG,6BAA6B;AAC5C,YAAY,GAAG,OAAO,CAAC,qBAAqB;AAC5C,SAAS;AACT,QAAQ,cAAc,EAAE,CAAC,wBAAwB,EAAE,CAAC;AACpD,KAAK,CAAC,CAAC;AACP;;;;;;;"}
|
|
@@ -213,6 +213,15 @@ function isNextControlFlowError(error) {
|
|
|
213
213
|
const digest = error === null || error === void 0 ? void 0 : error.digest;
|
|
214
214
|
return typeof digest === 'string' && digest.startsWith('NEXT_');
|
|
215
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* The path with any query string removed.
|
|
218
|
+
*
|
|
219
|
+
* Next.js reports `path` with the query attached (`/blog?name=foo`), and this value is
|
|
220
|
+
* written to the user's context, which `filters` never touch.
|
|
221
|
+
*/
|
|
222
|
+
function requestPath(path) {
|
|
223
|
+
return typeof path === 'string' ? path.split('?')[0] : path;
|
|
224
|
+
}
|
|
216
225
|
/**
|
|
217
226
|
* Reports errors passed to Next.js's `onRequestError` instrumentation hook.
|
|
218
227
|
*
|
|
@@ -241,9 +250,14 @@ async function captureRequestError(error, request, context) {
|
|
|
241
250
|
// failed, so it is too late to decorate that request's own events anyway.
|
|
242
251
|
const ids = seedNodeRequestEventContext(request.headers, await activeSpanIds());
|
|
243
252
|
await Honeybadger.notifyAsync(error, {
|
|
253
|
+
// The full path, query string included, goes on `url` so the configured `filters` are
|
|
254
|
+
// applied to it -- `filterUrl` runs over this field when the payload is built. Context
|
|
255
|
+
// is deliberately never filtered, since it is the user's own bag, so the copy below is
|
|
256
|
+
// reduced to the bare path rather than repeating an unfiltered query string there.
|
|
257
|
+
url: request.path,
|
|
244
258
|
context: {
|
|
245
259
|
...ids,
|
|
246
|
-
path: request.path,
|
|
260
|
+
path: requestPath(request.path),
|
|
247
261
|
method: request.method,
|
|
248
262
|
router_kind: context.routerKind,
|
|
249
263
|
route_path: context.routePath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeybadger-nextjs-edge.esm.js","sources":["../../build/flush.js","../../build/insights-instrumentation.js","../../build/capture-request-error.js","../../build/insights.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js';\nimport * as nextServer from 'next/server';\n/**\n * The `waitUntil` primitive the hosting platform injects per request. Next.js\n * resolves `after()` through this same accessor, and it is the only channel\n * available in Pages Router API routes, which are invoked as `(req, res)` with\n * no context argument to read it from.\n */\nexport function requestContextWaitUntil() {\n var _a, _b;\n const context = globalThis[Symbol.for('@next/request-context')];\n const waitUntil = (_b = (_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context)) === null || _b === void 0 ? void 0 : _b.waitUntil;\n return typeof waitUntil === 'function' ? waitUntil : undefined;\n}\n/**\n * Ensure events are delivered before a serverless runtime freezes, without\n * delaying the response where the runtime lets us avoid it.\n *\n * In order of preference: Next.js `after()` (App Router only — it needs App Router\n * request context, so Pages Router must not call it), then a `waitUntil` from the\n * platform request context, then a blocking `flushAsync()` when the runtime offers\n * neither.\n *\n * Delivery failures are logged by the events worker and must not break the handler.\n */\nexport function scheduleFlush(options = {}) {\n var _a;\n const flush = () => Honeybadger.flushAsync().catch(() => { });\n if (options.useAfter) {\n const after = nextServer.after;\n if (typeof after === 'function') {\n // Exported but still refusable: `after()` throws outside a supported\n // context. Fall through to the remaining strategies rather than failing\n // the request.\n try {\n after(flush);\n return;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // try waitUntil / blocking flush below\n }\n }\n }\n const waitUntil = (_a = options.waitUntil) !== null && _a !== void 0 ? _a : requestContextWaitUntil();\n if (waitUntil) {\n waitUntil(flush());\n return;\n }\n return flush();\n}\n//# sourceMappingURL=flush.js.map","import Honeybadger from '@honeybadger-io/js';\n/**\n * Edge-safe equivalents of the inbound instrumentation helpers in\n * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are\n * duplicated here because this module must load in every runtime where\n * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep\n * the header names and the `request_id` / `correlation_id` contract in sync\n * with that file.\n *\n * Both request shapes Next.js uses are supported: the `*RequestEventContext` /\n * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router\n * route handlers and middleware) and a Node-bag variant (Pages Router API\n * routes, which only ever run on the Node runtime).\n */\nfunction generateId() {\n const webCrypto = globalThis.crypto;\n if (webCrypto && typeof webCrypto.randomUUID === 'function') {\n try {\n return webCrypto.randomUUID();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // fall through to manual generation\n }\n }\n // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,\n // not a security token.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nfunction readHeader(headers, name) {\n const value = headers.get(name);\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\nfunction readNodeHeader(headers, name) {\n if (!headers) {\n return undefined;\n }\n const lower = name.toLowerCase();\n let value = headers[lower];\n if (value === undefined) {\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === lower) {\n value = headers[key];\n break;\n }\n }\n }\n if (Array.isArray(value)) {\n value = value[0];\n }\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\n/**\n * Shared id precedence. Kept in one place (rather than once per request shape)\n * so the header-name contract documented above is only spelled out once.\n *\n * The span ids do double duty. They are emitted as `trace_id` / `span_id`, and they also\n * back-fill `request_id` / `correlation_id` when no header supplied them — a trace id\n * already has exactly the semantics we want for a correlation id, since W3C trace context\n * reuses an inbound `traceparent` and mints a new one when there is none.\n *\n * That double duty is what makes a fault joinable to its request's events: both paths seed\n * from the same span, so with no id headers present a fault and its `request.handled` event\n * carry identical values for all four.\n */\nfunction seedIds(read, span = {}) {\n var _a, _b, _c, _d, _e, _f;\n const requestId = (_c = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : span.spanId) !== null && _c !== void 0 ? _c : generateId();\n const correlationId = (_f = (_e = (_d = read('x-correlation-id')) !== null && _d !== void 0 ? _d : read('x-amzn-trace-id')) !== null && _e !== void 0 ? _e : span.traceId) !== null && _f !== void 0 ? _f : requestId;\n const ids = { request_id: requestId, correlation_id: correlationId };\n if (span.traceId) {\n ids.trace_id = span.traceId;\n }\n if (span.spanId) {\n ids.span_id = span.spanId;\n }\n return ids;\n}\n/**\n * The active span's ids, or an empty object when OpenTelemetry is not in play.\n *\n * `@opentelemetry/api` is an optional peer dependency, and this module is reachable from\n * every runtime entry point, so it is loaded on demand and any failure to resolve it is\n * treated as \"no tracing configured\" rather than an error.\n */\nexport async function activeSpanIds() {\n var _a;\n try {\n const { trace } = await import('@opentelemetry/api');\n const spanContext = (_a = trace.getActiveSpan()) === null || _a === void 0 ? void 0 : _a.spanContext();\n if (!spanContext) {\n return {};\n }\n return { traceId: spanContext.traceId, spanId: spanContext.spanId };\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n return {};\n }\n}\n// App Router / middleware: headers are a web `Headers` instance.\nexport function seedRequestEventContext(headers, span = {}) {\n return seedIds((name) => readHeader(headers, name), span);\n}\n// Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).\nexport function seedNodeRequestEventContext(headers, span = {}) {\n return seedIds((name) => readNodeHeader(headers, name), span);\n}\nexport function now() {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n// Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and\n// the per-source flag must both be on.\nexport function insightsHttpEnabled() {\n const insights = Honeybadger.config.insights;\n return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;\n}\n// The ids are embedded directly in the payload (instead of relying on the\n// store's eventContext merge) so the event carries them even where the\n// runtime, where there is no per-request store isolation. On the Node.js\n// runtime they match the seeded event context, so embedding is a no-op.\nfunction emitHandledEvent(method, path, status, start, ids) {\n const payload = {\n method,\n duration: Math.round(now() - start),\n ...ids,\n };\n if (typeof path === 'string') {\n payload.path = path;\n }\n if (typeof status === 'number') {\n payload.status = status;\n }\n Honeybadger.event('request.handled', payload);\n}\n// App Router / middleware: `req.url` is absolute, so parse out the pathname.\nexport function emitRequestEvent(req, status, start, ids) {\n let path;\n try {\n path = new URL(req.url).pathname;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // relative or malformed URL — leave path unset\n }\n emitHandledEvent(req.method, path, status, start, ids);\n}\n// Pages Router: `req.url` is a relative path that may carry a query string.\nexport function emitNodeRequestEvent(req, status, start, ids) {\n const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;\n emitHandledEvent(req.method, path, status, start, ids);\n}\n/**\n * OpenTelemetry path. Header values are not on the span by default; they arrive as\n * `http.request.header.*` attributes when the HTTP instrumentation is configured with\n * `headersToSpanAttributes`. Hyphens become underscores under the older semantic\n * conventions and are preserved under the stable ones, so both spellings are read.\n *\n * When no header is present the span and trace ids are used, so the ids stay\n * meaningful — and joinable to a trace — on platforms where the HTTP layer is not\n * visible, such as serverless platforms.\n */\nexport function seedSpanEventContext(attributes, spanContext) {\n const read = (name) => {\n const lower = name.toLowerCase();\n for (const key of [\n `http.request.header.${lower}`,\n `http.request.header.${lower.replace(/-/g, '_')}`,\n ]) {\n const value = attributes[key];\n const first = Array.isArray(value) ? value[0] : value;\n if (typeof first === 'string' && first.trim().length) {\n return first.trim();\n }\n }\n return undefined;\n };\n return seedIds(read, {\n traceId: spanContext.traceId || undefined,\n spanId: spanContext.spanId || undefined,\n });\n}\n//# sourceMappingURL=insights-instrumentation.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { scheduleFlush } from './flush';\nimport { activeSpanIds, seedNodeRequestEventContext } from './insights-instrumentation';\n/**\n * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,\n * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`\n * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).\n * These are not real failures — the framework catches them upstream to produce\n * the redirect/404/etc. — so we must let them pass without reporting, otherwise\n * every redirect shows up as an error in Honeybadger.\n *\n * We match on the `NEXT_` prefix rather than an exhaustive list so that any\n * present or future framework control-flow digest is covered. This is safe:\n * genuine errors that React tags with a `digest` use an opaque hash, and other\n * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,\n * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.\n */\nfunction isNextControlFlowError(error) {\n const digest = error === null || error === void 0 ? void 0 : error.digest;\n return typeof digest === 'string' && digest.startsWith('NEXT_');\n}\n/**\n * Reports errors passed to Next.js's `onRequestError` instrumentation hook.\n *\n * Wire it up in `instrumentation.ts`:\n *\n * ```ts\n * export const onRequestError = captureRequestError\n * ```\n *\n * Reaches Server Components, Route Handlers, Server Actions and middleware, and receives\n * the real error rather than the generic message Next.js hands to an error component.\n */\nexport async function captureRequestError(error, request, context) {\n if (isNextControlFlowError(error)) {\n return;\n }\n // Same header precedence *and* the same span as the Insights path, so a fault and the\n // events from the request it failed in carry matching ids. Next.js still has the request\n // span active when it calls this hook, and it is the very span the Insights processor\n // maps to `request.handled` — so with no id headers present all four ids are identical on\n // both, and the fault joins its request's events and trace.\n //\n // Deliberately not written to the event context: outside a `Honeybadger.run()` that\n // lands on a store shared by the whole process or isolate, so the ids would leak into\n // later requests' events. `onRequestError` also fires after the request has already\n // failed, so it is too late to decorate that request's own events anyway.\n const ids = seedNodeRequestEventContext(request.headers, await activeSpanIds());\n await Honeybadger.notifyAsync(error, {\n context: {\n ...ids,\n path: request.path,\n method: request.method,\n router_kind: context.routerKind,\n route_path: context.routePath,\n route_type: context.routeType,\n },\n });\n await scheduleFlush({ useAfter: true });\n}\n//# sourceMappingURL=capture-request-error.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { insightsHttpEnabled, seedSpanEventContext } from './insights-instrumentation';\nimport { scheduleFlush } from './flush';\n/**\n * Next.js instruments itself with OpenTelemetry and emits one root span per request,\n * `[http.method] [next.route]`, tagged `next.span_type: BaseServer.handleRequest`. Its\n * attributes carry the method, route, target and status, so mapping that span to a\n * `request.handled` event reports every request without wrapping any handler.\n *\n * Next instruments but does not export: spans only reach us once a tracer provider with\n * this processor is registered. See `registerHoneybadgerInsights`.\n */\nconst NEXT_REQUEST_SPAN_TYPE = 'BaseServer.handleRequest';\n/**\n * Request headers to copy onto the root span, so `request_id` and `correlation_id` can be\n * reused from an inbound request instead of falling back to the span and trace ids.\n *\n * Header values are not span attributes by default. `@vercel/otel` applies this map when\n * it creates the root span, which is the span this processor reads — and, unlike Node's\n * HTTP instrumentation, it works on serverless platforms too.\n *\n * Spread it into your own `registerOTel` call if you register OpenTelemetry yourself:\n *\n * ```ts\n * registerOTel({\n * attributesFromHeaders: { ...HONEYBADGER_HEADER_ATTRIBUTES },\n * spanProcessors: [honeybadgerSpanProcessor()],\n * })\n * ```\n *\n * Keep the header names in sync with `seedIds` in ./insights-instrumentation.\n */\nexport const HONEYBADGER_HEADER_ATTRIBUTES = {\n 'http.request.header.x-request-id': 'x-request-id',\n 'http.request.header.request-id': 'request-id',\n 'http.request.header.x-correlation-id': 'x-correlation-id',\n 'http.request.header.x-amzn-trace-id': 'x-amzn-trace-id',\n};\nfunction readString(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'string' && value.length) {\n return value;\n }\n }\n return undefined;\n}\nfunction readNumber(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'number') {\n return value;\n }\n if (typeof value === 'string' && value.trim().length && Number.isFinite(Number(value))) {\n return Number(value);\n }\n }\n return undefined;\n}\nfunction durationMs(duration) {\n if (!Array.isArray(duration) || duration.length !== 2) {\n return 0;\n }\n const [seconds, nanos] = duration;\n return Math.round(seconds * 1000 + nanos / 1e6);\n}\n/**\n * Path without the query string. `http.target` includes the query under the older\n * semantic conventions; `url.path` is already bare under the stable ones.\n */\nfunction readPath(attributes) {\n const target = readString(attributes, 'url.path', 'http.target');\n return typeof target === 'string' ? target.split('?')[0] : undefined;\n}\n/**\n * Maps Next.js's per-request span to a Honeybadger `request.handled` Insights event.\n *\n * Pass it to whatever registers OpenTelemetry in your `instrumentation.ts`:\n *\n * ```ts\n * import { registerOTel } from '@vercel/otel'\n * import { honeybadgerSpanProcessor } from '@honeybadger-io/nextjs'\n *\n * export function register() {\n * registerOTel({ serviceName: 'my-app', spanProcessors: [honeybadgerSpanProcessor()] })\n * }\n * ```\n *\n * `registerHoneybadgerInsights()` is the one-line equivalent when you have no other\n * OpenTelemetry setup of your own.\n */\nexport function honeybadgerSpanProcessor() {\n return {\n onStart() {\n // Nothing to do: the event is emitted once the request span is complete, which is\n // when the status and duration are known.\n },\n onEnd(span) {\n var _a;\n const attributes = (_a = span.attributes) !== null && _a !== void 0 ? _a : {};\n if (attributes['next.span_type'] !== NEXT_REQUEST_SPAN_TYPE) {\n return;\n }\n // Checked per event rather than at registration: configuration is loaded by\n // `register()` importing the honeybadger config files, which may happen after the\n // processor is constructed.\n if (!insightsHttpEnabled()) {\n return;\n }\n const spanContext = typeof span.spanContext === 'function' ? span.spanContext() : {};\n const ids = seedSpanEventContext(attributes, spanContext !== null && spanContext !== void 0 ? spanContext : {});\n const payload = {\n method: readString(attributes, 'http.request.method', 'http.method'),\n duration: durationMs(span.duration),\n ...ids,\n };\n const path = readPath(attributes);\n if (path) {\n payload.path = path;\n }\n const status = readNumber(attributes, 'http.response.status_code', 'http.status_code');\n if (typeof status === 'number') {\n payload.status = status;\n }\n // Emitted alongside the ids rather than replacing them, so an event can be joined\n // to a trace in another tool without changing what existing consumers read.\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.traceId) {\n payload.trace_id = spanContext.traceId;\n }\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.spanId) {\n payload.span_id = spanContext.spanId;\n }\n Honeybadger.event('request.handled', payload);\n // A span processor batches on its own lifecycle, which is not enough on a platform\n // that can freeze the invocation as soon as the response is sent.\n scheduleFlush({ useAfter: true });\n },\n async forceFlush() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n async shutdown() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n };\n}\n/**\n * Registers OpenTelemetry with only Honeybadger's span processor attached, for apps that\n * have no OpenTelemetry setup of their own. Call it from `register()` in\n * `instrumentation.ts`.\n *\n * `@vercel/otel` is an optional peer dependency: it is only needed for Insights, and it\n * loads where the full Node SDK cannot, such as serverless platforms. If you\n * already call `registerOTel` yourself, add `honeybadgerSpanProcessor()` to your\n * `spanProcessors` instead of calling this — registering twice would compete for the\n * global provider.\n */\nexport async function registerHoneybadgerInsights(options = {}) {\n var _a, _b;\n let registerOTel;\n try {\n ({ registerOTel } = await import('@vercel/otel'));\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n Honeybadger.logger.error('[Honeybadger] Insights request events need @vercel/otel. Install it, or drop the ' +\n 'registerHoneybadgerInsights() call — error reporting works without it.');\n return;\n }\n registerOTel({\n serviceName: (_b = (_a = options.serviceName) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_HONEYBADGER_SERVICE_NAME) !== null && _b !== void 0 ? _b : 'nextjs-app',\n // Without this the id headers never reach the span, so request_id and\n // correlation_id would always fall back to the span and trace ids.\n attributesFromHeaders: {\n ...HONEYBADGER_HEADER_ATTRIBUTES,\n ...options.attributesFromHeaders,\n },\n spanProcessors: [honeybadgerSpanProcessor()],\n });\n}\n//# sourceMappingURL=insights.js.map"],"names":[],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,GAAG;AAC1C,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC;AACpE,IAAI,MAAM,SAAS,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;AAC1M,IAAI,OAAO,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AACnE,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,OAAO,GAAG,EAAE,EAAE;AAC5C,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAClE,IAA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I;AACR,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,MAAM,OAAO,cAAc,CAAC,EAAE;AAC1D,KAAK;AACL;AACA,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,mFAAmF;AACpH,YAAY,wEAAwE,CAAC,CAAC;AACtF,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,YAAY,CAAC;AACjB,QAAQ,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,WAAW,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,YAAY;AACtL;AACA;AACA,QAAQ,qBAAqB,EAAE;AAC/B,YAAY,GAAG,6BAA6B;AAC5C,YAAY,GAAG,OAAO,CAAC,qBAAqB;AAC5C,SAAS;AACT,QAAQ,cAAc,EAAE,CAAC,wBAAwB,EAAE,CAAC;AACpD,KAAK,CAAC,CAAC;AACP;;;;"}
|
|
1
|
+
{"version":3,"file":"honeybadger-nextjs-edge.esm.js","sources":["../../build/flush.js","../../build/insights-instrumentation.js","../../build/capture-request-error.js","../../build/insights.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js';\nimport * as nextServer from 'next/server';\n/**\n * The `waitUntil` primitive the hosting platform injects per request. Next.js\n * resolves `after()` through this same accessor, and it is the only channel\n * available in Pages Router API routes, which are invoked as `(req, res)` with\n * no context argument to read it from.\n */\nexport function requestContextWaitUntil() {\n var _a, _b;\n const context = globalThis[Symbol.for('@next/request-context')];\n const waitUntil = (_b = (_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context)) === null || _b === void 0 ? void 0 : _b.waitUntil;\n return typeof waitUntil === 'function' ? waitUntil : undefined;\n}\n/**\n * Ensure events are delivered before a serverless runtime freezes, without\n * delaying the response where the runtime lets us avoid it.\n *\n * In order of preference: Next.js `after()` (App Router only — it needs App Router\n * request context, so Pages Router must not call it), then a `waitUntil` from the\n * platform request context, then a blocking `flushAsync()` when the runtime offers\n * neither.\n *\n * Delivery failures are logged by the events worker and must not break the handler.\n */\nexport function scheduleFlush(options = {}) {\n var _a;\n const flush = () => Honeybadger.flushAsync().catch(() => { });\n if (options.useAfter) {\n const after = nextServer.after;\n if (typeof after === 'function') {\n // Exported but still refusable: `after()` throws outside a supported\n // context. Fall through to the remaining strategies rather than failing\n // the request.\n try {\n after(flush);\n return;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // try waitUntil / blocking flush below\n }\n }\n }\n const waitUntil = (_a = options.waitUntil) !== null && _a !== void 0 ? _a : requestContextWaitUntil();\n if (waitUntil) {\n waitUntil(flush());\n return;\n }\n return flush();\n}\n//# sourceMappingURL=flush.js.map","import Honeybadger from '@honeybadger-io/js';\n/**\n * Edge-safe equivalents of the inbound instrumentation helpers in\n * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are\n * duplicated here because this module must load in every runtime where\n * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep\n * the header names and the `request_id` / `correlation_id` contract in sync\n * with that file.\n *\n * Both request shapes Next.js uses are supported: the `*RequestEventContext` /\n * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router\n * route handlers and middleware) and a Node-bag variant (Pages Router API\n * routes, which only ever run on the Node runtime).\n */\nfunction generateId() {\n const webCrypto = globalThis.crypto;\n if (webCrypto && typeof webCrypto.randomUUID === 'function') {\n try {\n return webCrypto.randomUUID();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // fall through to manual generation\n }\n }\n // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,\n // not a security token.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nfunction readHeader(headers, name) {\n const value = headers.get(name);\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\nfunction readNodeHeader(headers, name) {\n if (!headers) {\n return undefined;\n }\n const lower = name.toLowerCase();\n let value = headers[lower];\n if (value === undefined) {\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === lower) {\n value = headers[key];\n break;\n }\n }\n }\n if (Array.isArray(value)) {\n value = value[0];\n }\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\n/**\n * Shared id precedence. Kept in one place (rather than once per request shape)\n * so the header-name contract documented above is only spelled out once.\n *\n * The span ids do double duty. They are emitted as `trace_id` / `span_id`, and they also\n * back-fill `request_id` / `correlation_id` when no header supplied them — a trace id\n * already has exactly the semantics we want for a correlation id, since W3C trace context\n * reuses an inbound `traceparent` and mints a new one when there is none.\n *\n * That double duty is what makes a fault joinable to its request's events: both paths seed\n * from the same span, so with no id headers present a fault and its `request.handled` event\n * carry identical values for all four.\n */\nfunction seedIds(read, span = {}) {\n var _a, _b, _c, _d, _e, _f;\n const requestId = (_c = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : span.spanId) !== null && _c !== void 0 ? _c : generateId();\n const correlationId = (_f = (_e = (_d = read('x-correlation-id')) !== null && _d !== void 0 ? _d : read('x-amzn-trace-id')) !== null && _e !== void 0 ? _e : span.traceId) !== null && _f !== void 0 ? _f : requestId;\n const ids = { request_id: requestId, correlation_id: correlationId };\n if (span.traceId) {\n ids.trace_id = span.traceId;\n }\n if (span.spanId) {\n ids.span_id = span.spanId;\n }\n return ids;\n}\n/**\n * The active span's ids, or an empty object when OpenTelemetry is not in play.\n *\n * `@opentelemetry/api` is an optional peer dependency, and this module is reachable from\n * every runtime entry point, so it is loaded on demand and any failure to resolve it is\n * treated as \"no tracing configured\" rather than an error.\n */\nexport async function activeSpanIds() {\n var _a;\n try {\n const { trace } = await import('@opentelemetry/api');\n const spanContext = (_a = trace.getActiveSpan()) === null || _a === void 0 ? void 0 : _a.spanContext();\n if (!spanContext) {\n return {};\n }\n return { traceId: spanContext.traceId, spanId: spanContext.spanId };\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n return {};\n }\n}\n// App Router / middleware: headers are a web `Headers` instance.\nexport function seedRequestEventContext(headers, span = {}) {\n return seedIds((name) => readHeader(headers, name), span);\n}\n// Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).\nexport function seedNodeRequestEventContext(headers, span = {}) {\n return seedIds((name) => readNodeHeader(headers, name), span);\n}\nexport function now() {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n// Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and\n// the per-source flag must both be on.\nexport function insightsHttpEnabled() {\n const insights = Honeybadger.config.insights;\n return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;\n}\n// The ids are embedded directly in the payload (instead of relying on the\n// store's eventContext merge) so the event carries them even where the\n// runtime, where there is no per-request store isolation. On the Node.js\n// runtime they match the seeded event context, so embedding is a no-op.\nfunction emitHandledEvent(method, path, status, start, ids) {\n const payload = {\n method,\n duration: Math.round(now() - start),\n ...ids,\n };\n if (typeof path === 'string') {\n payload.path = path;\n }\n if (typeof status === 'number') {\n payload.status = status;\n }\n Honeybadger.event('request.handled', payload);\n}\n// App Router / middleware: `req.url` is absolute, so parse out the pathname.\nexport function emitRequestEvent(req, status, start, ids) {\n let path;\n try {\n path = new URL(req.url).pathname;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // relative or malformed URL — leave path unset\n }\n emitHandledEvent(req.method, path, status, start, ids);\n}\n// Pages Router: `req.url` is a relative path that may carry a query string.\nexport function emitNodeRequestEvent(req, status, start, ids) {\n const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;\n emitHandledEvent(req.method, path, status, start, ids);\n}\n/**\n * OpenTelemetry path. Header values are not on the span by default; they arrive as\n * `http.request.header.*` attributes when the HTTP instrumentation is configured with\n * `headersToSpanAttributes`. Hyphens become underscores under the older semantic\n * conventions and are preserved under the stable ones, so both spellings are read.\n *\n * When no header is present the span and trace ids are used, so the ids stay\n * meaningful — and joinable to a trace — on platforms where the HTTP layer is not\n * visible, such as serverless platforms.\n */\nexport function seedSpanEventContext(attributes, spanContext) {\n const read = (name) => {\n const lower = name.toLowerCase();\n for (const key of [\n `http.request.header.${lower}`,\n `http.request.header.${lower.replace(/-/g, '_')}`,\n ]) {\n const value = attributes[key];\n const first = Array.isArray(value) ? value[0] : value;\n if (typeof first === 'string' && first.trim().length) {\n return first.trim();\n }\n }\n return undefined;\n };\n return seedIds(read, {\n traceId: spanContext.traceId || undefined,\n spanId: spanContext.spanId || undefined,\n });\n}\n//# sourceMappingURL=insights-instrumentation.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { scheduleFlush } from './flush';\nimport { activeSpanIds, seedNodeRequestEventContext } from './insights-instrumentation';\n/**\n * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,\n * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`\n * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).\n * These are not real failures — the framework catches them upstream to produce\n * the redirect/404/etc. — so we must let them pass without reporting, otherwise\n * every redirect shows up as an error in Honeybadger.\n *\n * We match on the `NEXT_` prefix rather than an exhaustive list so that any\n * present or future framework control-flow digest is covered. This is safe:\n * genuine errors that React tags with a `digest` use an opaque hash, and other\n * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,\n * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.\n */\nfunction isNextControlFlowError(error) {\n const digest = error === null || error === void 0 ? void 0 : error.digest;\n return typeof digest === 'string' && digest.startsWith('NEXT_');\n}\n/**\n * The path with any query string removed.\n *\n * Next.js reports `path` with the query attached (`/blog?name=foo`), and this value is\n * written to the user's context, which `filters` never touch.\n */\nfunction requestPath(path) {\n return typeof path === 'string' ? path.split('?')[0] : path;\n}\n/**\n * Reports errors passed to Next.js's `onRequestError` instrumentation hook.\n *\n * Wire it up in `instrumentation.ts`:\n *\n * ```ts\n * export const onRequestError = captureRequestError\n * ```\n *\n * Reaches Server Components, Route Handlers, Server Actions and middleware, and receives\n * the real error rather than the generic message Next.js hands to an error component.\n */\nexport async function captureRequestError(error, request, context) {\n if (isNextControlFlowError(error)) {\n return;\n }\n // Same header precedence *and* the same span as the Insights path, so a fault and the\n // events from the request it failed in carry matching ids. Next.js still has the request\n // span active when it calls this hook, and it is the very span the Insights processor\n // maps to `request.handled` — so with no id headers present all four ids are identical on\n // both, and the fault joins its request's events and trace.\n //\n // Deliberately not written to the event context: outside a `Honeybadger.run()` that\n // lands on a store shared by the whole process or isolate, so the ids would leak into\n // later requests' events. `onRequestError` also fires after the request has already\n // failed, so it is too late to decorate that request's own events anyway.\n const ids = seedNodeRequestEventContext(request.headers, await activeSpanIds());\n await Honeybadger.notifyAsync(error, {\n // The full path, query string included, goes on `url` so the configured `filters` are\n // applied to it -- `filterUrl` runs over this field when the payload is built. Context\n // is deliberately never filtered, since it is the user's own bag, so the copy below is\n // reduced to the bare path rather than repeating an unfiltered query string there.\n url: request.path,\n context: {\n ...ids,\n path: requestPath(request.path),\n method: request.method,\n router_kind: context.routerKind,\n route_path: context.routePath,\n route_type: context.routeType,\n },\n });\n await scheduleFlush({ useAfter: true });\n}\n//# sourceMappingURL=capture-request-error.js.map","import Honeybadger from '@honeybadger-io/js';\nimport { insightsHttpEnabled, seedSpanEventContext } from './insights-instrumentation';\nimport { scheduleFlush } from './flush';\n/**\n * Next.js instruments itself with OpenTelemetry and emits one root span per request,\n * `[http.method] [next.route]`, tagged `next.span_type: BaseServer.handleRequest`. Its\n * attributes carry the method, route, target and status, so mapping that span to a\n * `request.handled` event reports every request without wrapping any handler.\n *\n * Next instruments but does not export: spans only reach us once a tracer provider with\n * this processor is registered. See `registerHoneybadgerInsights`.\n */\nconst NEXT_REQUEST_SPAN_TYPE = 'BaseServer.handleRequest';\n/**\n * Request headers to copy onto the root span, so `request_id` and `correlation_id` can be\n * reused from an inbound request instead of falling back to the span and trace ids.\n *\n * Header values are not span attributes by default. `@vercel/otel` applies this map when\n * it creates the root span, which is the span this processor reads — and, unlike Node's\n * HTTP instrumentation, it works on serverless platforms too.\n *\n * Spread it into your own `registerOTel` call if you register OpenTelemetry yourself:\n *\n * ```ts\n * registerOTel({\n * attributesFromHeaders: { ...HONEYBADGER_HEADER_ATTRIBUTES },\n * spanProcessors: [honeybadgerSpanProcessor()],\n * })\n * ```\n *\n * Keep the header names in sync with `seedIds` in ./insights-instrumentation.\n */\nexport const HONEYBADGER_HEADER_ATTRIBUTES = {\n 'http.request.header.x-request-id': 'x-request-id',\n 'http.request.header.request-id': 'request-id',\n 'http.request.header.x-correlation-id': 'x-correlation-id',\n 'http.request.header.x-amzn-trace-id': 'x-amzn-trace-id',\n};\nfunction readString(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'string' && value.length) {\n return value;\n }\n }\n return undefined;\n}\nfunction readNumber(attributes, ...names) {\n for (const name of names) {\n const value = attributes[name];\n if (typeof value === 'number') {\n return value;\n }\n if (typeof value === 'string' && value.trim().length && Number.isFinite(Number(value))) {\n return Number(value);\n }\n }\n return undefined;\n}\nfunction durationMs(duration) {\n if (!Array.isArray(duration) || duration.length !== 2) {\n return 0;\n }\n const [seconds, nanos] = duration;\n return Math.round(seconds * 1000 + nanos / 1e6);\n}\n/**\n * Path without the query string. `http.target` includes the query under the older\n * semantic conventions; `url.path` is already bare under the stable ones.\n */\nfunction readPath(attributes) {\n const target = readString(attributes, 'url.path', 'http.target');\n return typeof target === 'string' ? target.split('?')[0] : undefined;\n}\n/**\n * Maps Next.js's per-request span to a Honeybadger `request.handled` Insights event.\n *\n * Pass it to whatever registers OpenTelemetry in your `instrumentation.ts`:\n *\n * ```ts\n * import { registerOTel } from '@vercel/otel'\n * import { honeybadgerSpanProcessor } from '@honeybadger-io/nextjs'\n *\n * export function register() {\n * registerOTel({ serviceName: 'my-app', spanProcessors: [honeybadgerSpanProcessor()] })\n * }\n * ```\n *\n * `registerHoneybadgerInsights()` is the one-line equivalent when you have no other\n * OpenTelemetry setup of your own.\n */\nexport function honeybadgerSpanProcessor() {\n return {\n onStart() {\n // Nothing to do: the event is emitted once the request span is complete, which is\n // when the status and duration are known.\n },\n onEnd(span) {\n var _a;\n const attributes = (_a = span.attributes) !== null && _a !== void 0 ? _a : {};\n if (attributes['next.span_type'] !== NEXT_REQUEST_SPAN_TYPE) {\n return;\n }\n // Checked per event rather than at registration: configuration is loaded by\n // `register()` importing the honeybadger config files, which may happen after the\n // processor is constructed.\n if (!insightsHttpEnabled()) {\n return;\n }\n const spanContext = typeof span.spanContext === 'function' ? span.spanContext() : {};\n const ids = seedSpanEventContext(attributes, spanContext !== null && spanContext !== void 0 ? spanContext : {});\n const payload = {\n method: readString(attributes, 'http.request.method', 'http.method'),\n duration: durationMs(span.duration),\n ...ids,\n };\n const path = readPath(attributes);\n if (path) {\n payload.path = path;\n }\n const status = readNumber(attributes, 'http.response.status_code', 'http.status_code');\n if (typeof status === 'number') {\n payload.status = status;\n }\n // Emitted alongside the ids rather than replacing them, so an event can be joined\n // to a trace in another tool without changing what existing consumers read.\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.traceId) {\n payload.trace_id = spanContext.traceId;\n }\n if (spanContext === null || spanContext === void 0 ? void 0 : spanContext.spanId) {\n payload.span_id = spanContext.spanId;\n }\n Honeybadger.event('request.handled', payload);\n // A span processor batches on its own lifecycle, which is not enough on a platform\n // that can freeze the invocation as soon as the response is sent.\n scheduleFlush({ useAfter: true });\n },\n async forceFlush() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n async shutdown() {\n await Honeybadger.flushAsync().catch(() => { });\n },\n };\n}\n/**\n * Registers OpenTelemetry with only Honeybadger's span processor attached, for apps that\n * have no OpenTelemetry setup of their own. Call it from `register()` in\n * `instrumentation.ts`.\n *\n * `@vercel/otel` is an optional peer dependency: it is only needed for Insights, and it\n * loads where the full Node SDK cannot, such as serverless platforms. If you\n * already call `registerOTel` yourself, add `honeybadgerSpanProcessor()` to your\n * `spanProcessors` instead of calling this — registering twice would compete for the\n * global provider.\n */\nexport async function registerHoneybadgerInsights(options = {}) {\n var _a, _b;\n let registerOTel;\n try {\n ({ registerOTel } = await import('@vercel/otel'));\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n Honeybadger.logger.error('[Honeybadger] Insights request events need @vercel/otel. Install it, or drop the ' +\n 'registerHoneybadgerInsights() call — error reporting works without it.');\n return;\n }\n registerOTel({\n serviceName: (_b = (_a = options.serviceName) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_HONEYBADGER_SERVICE_NAME) !== null && _b !== void 0 ? _b : 'nextjs-app',\n // Without this the id headers never reach the span, so request_id and\n // correlation_id would always fall back to the span and trace ids.\n attributesFromHeaders: {\n ...HONEYBADGER_HEADER_ATTRIBUTES,\n ...options.attributesFromHeaders,\n },\n spanProcessors: [honeybadgerSpanProcessor()],\n });\n}\n//# sourceMappingURL=insights.js.map"],"names":[],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,GAAG;AAC1C,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC;AACpE,IAAI,MAAM,SAAS,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,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,oCAAoC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,YAAY;AACtL;AACA;AACA,QAAQ,qBAAqB,EAAE;AAC/B,YAAY,GAAG,6BAA6B;AAC5C,YAAY,GAAG,OAAO,CAAC,qBAAqB;AAC5C,SAAS;AACT,QAAQ,cAAc,EAAE,CAAC,wBAAwB,EAAE,CAAC;AACpD,KAAK,CAAC,CAAC;AACP;;;;"}
|
|
@@ -781,6 +781,15 @@ function isNextControlFlowError(error) {
|
|
|
781
781
|
const digest = error === null || error === void 0 ? void 0 : error.digest;
|
|
782
782
|
return typeof digest === 'string' && digest.startsWith('NEXT_');
|
|
783
783
|
}
|
|
784
|
+
/**
|
|
785
|
+
* The path with any query string removed.
|
|
786
|
+
*
|
|
787
|
+
* Next.js reports `path` with the query attached (`/blog?name=foo`), and this value is
|
|
788
|
+
* written to the user's context, which `filters` never touch.
|
|
789
|
+
*/
|
|
790
|
+
function requestPath(path) {
|
|
791
|
+
return typeof path === 'string' ? path.split('?')[0] : path;
|
|
792
|
+
}
|
|
784
793
|
/**
|
|
785
794
|
* Reports errors passed to Next.js's `onRequestError` instrumentation hook.
|
|
786
795
|
*
|
|
@@ -809,9 +818,14 @@ async function captureRequestError(error, request, context) {
|
|
|
809
818
|
// failed, so it is too late to decorate that request's own events anyway.
|
|
810
819
|
const ids = seedNodeRequestEventContext(request.headers, await activeSpanIds());
|
|
811
820
|
await Honeybadger__default["default"].notifyAsync(error, {
|
|
821
|
+
// The full path, query string included, goes on `url` so the configured `filters` are
|
|
822
|
+
// applied to it -- `filterUrl` runs over this field when the payload is built. Context
|
|
823
|
+
// is deliberately never filtered, since it is the user's own bag, so the copy below is
|
|
824
|
+
// reduced to the bare path rather than repeating an unfiltered query string there.
|
|
825
|
+
url: request.path,
|
|
812
826
|
context: {
|
|
813
827
|
...ids,
|
|
814
|
-
path: request.path,
|
|
828
|
+
path: requestPath(request.path),
|
|
815
829
|
method: request.method,
|
|
816
830
|
router_kind: context.routerKind,
|
|
817
831
|
route_path: context.routePath,
|
|
@@ -838,7 +852,11 @@ async function captureRequestError(error, request, context) {
|
|
|
838
852
|
* reject.
|
|
839
853
|
*/
|
|
840
854
|
function captureRouterTransitionStart(url, navigationType) {
|
|
841
|
-
|
|
855
|
+
// The message carries the path alone and the full URL goes in the metadata, where the
|
|
856
|
+
// configured `filters` are applied to its query string when the payload is built. This is
|
|
857
|
+
// the same split the browser integration already uses for its XHR and fetch breadcrumbs,
|
|
858
|
+
// whose messages are built from `localURLPathname`.
|
|
859
|
+
Honeybadger__default["default"].addBreadcrumb(`Navigated to ${url.split('?')[0]}`, {
|
|
842
860
|
category: 'navigation',
|
|
843
861
|
metadata: { url, navigationType },
|
|
844
862
|
});
|