@honeybadger-io/nextjs 5.10.13 → 5.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack';
4
4
  import Honeybadger from '@honeybadger-io/js';
5
+ import * as nextServer from 'next/server';
5
6
 
6
7
  const URL_DOCS_SOURCE_MAPS_UPLOAD = 'https://docs.honeybadger.io/lib/javascript/integration/nextjs/#source-map-upload-and-tracking-deploys';
7
8
  let _silent = true;
@@ -194,7 +195,191 @@ function setupHoneybadger(config, honeybadgerNextJsConfig) {
194
195
  };
195
196
  }
196
197
 
197
- function configure() {
198
+ /**
199
+ * Edge-safe equivalents of the inbound instrumentation helpers in
200
+ * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are
201
+ * duplicated here because this module must also load on the edge runtime where
202
+ * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep
203
+ * the header names and the `request_id` / `correlation_id` contract in sync
204
+ * with that file.
205
+ *
206
+ * Both request shapes Next.js uses are supported: the `*RequestEventContext` /
207
+ * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router
208
+ * route handlers and middleware) and a Node-bag variant (Pages Router API
209
+ * routes, which only ever run on the Node runtime).
210
+ */
211
+ function generateId() {
212
+ const webCrypto = globalThis.crypto;
213
+ if (webCrypto && typeof webCrypto.randomUUID === 'function') {
214
+ try {
215
+ return webCrypto.randomUUID();
216
+ }
217
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
218
+ catch (error) {
219
+ // fall through to manual generation
220
+ }
221
+ }
222
+ // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,
223
+ // not a security token.
224
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {
225
+ const r = (Math.random() * 16) | 0;
226
+ const v = ch === 'x' ? r : (r & 0x3) | 0x8;
227
+ return v.toString(16);
228
+ });
229
+ }
230
+ function readHeader(headers, name) {
231
+ const value = headers.get(name);
232
+ if (typeof value !== 'string') {
233
+ return undefined;
234
+ }
235
+ const trimmed = value.trim();
236
+ return trimmed.length ? trimmed : undefined;
237
+ }
238
+ function readNodeHeader(headers, name) {
239
+ if (!headers) {
240
+ return undefined;
241
+ }
242
+ const lower = name.toLowerCase();
243
+ let value = headers[lower];
244
+ if (value === undefined) {
245
+ for (const key of Object.keys(headers)) {
246
+ if (key.toLowerCase() === lower) {
247
+ value = headers[key];
248
+ break;
249
+ }
250
+ }
251
+ }
252
+ if (Array.isArray(value)) {
253
+ value = value[0];
254
+ }
255
+ if (typeof value !== 'string') {
256
+ return undefined;
257
+ }
258
+ const trimmed = value.trim();
259
+ return trimmed.length ? trimmed : undefined;
260
+ }
261
+ // Shared id precedence. Kept in one place (rather than once per request shape)
262
+ // so the header-name contract documented above is only spelled out once.
263
+ function seedIds(read) {
264
+ var _a, _b, _c, _d;
265
+ const requestId = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : generateId();
266
+ const correlationId = (_d = (_c = read('x-correlation-id')) !== null && _c !== void 0 ? _c : read('x-amzn-trace-id')) !== null && _d !== void 0 ? _d : requestId;
267
+ return { request_id: requestId, correlation_id: correlationId };
268
+ }
269
+ // App Router / middleware: headers are a web `Headers` instance.
270
+ function seedRequestEventContext(headers) {
271
+ return seedIds((name) => readHeader(headers, name));
272
+ }
273
+ // Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).
274
+ function seedNodeRequestEventContext(headers) {
275
+ return seedIds((name) => readNodeHeader(headers, name));
276
+ }
277
+ function now() {
278
+ return typeof performance !== 'undefined' ? performance.now() : Date.now();
279
+ }
280
+ // Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and
281
+ // the per-source flag must both be on.
282
+ function insightsHttpEnabled() {
283
+ const insights = Honeybadger.config.insights;
284
+ return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;
285
+ }
286
+ // The ids are embedded directly in the payload (instead of relying on the
287
+ // store's eventContext merge) so the event carries them even on the edge
288
+ // runtime, where there is no per-request store isolation. On the Node.js
289
+ // runtime they match the seeded event context, so embedding is a no-op.
290
+ function emitHandledEvent(method, path, status, start, ids) {
291
+ const payload = {
292
+ method,
293
+ duration: Math.round(now() - start),
294
+ ...ids,
295
+ };
296
+ if (typeof path === 'string') {
297
+ payload.path = path;
298
+ }
299
+ if (typeof status === 'number') {
300
+ payload.status = status;
301
+ }
302
+ Honeybadger.event('request.handled', payload);
303
+ }
304
+ // App Router / middleware: `req.url` is absolute, so parse out the pathname.
305
+ function emitRequestEvent(req, status, start, ids) {
306
+ let path;
307
+ try {
308
+ path = new URL(req.url).pathname;
309
+ }
310
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
311
+ catch (error) {
312
+ // relative or malformed URL — leave path unset
313
+ }
314
+ emitHandledEvent(req.method, path, status, start, ids);
315
+ }
316
+ // Pages Router: `req.url` is a relative path that may carry a query string.
317
+ function emitNodeRequestEvent(req, status, start, ids) {
318
+ const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;
319
+ emitHandledEvent(req.method, path, status, start, ids);
320
+ }
321
+
322
+ /**
323
+ * The `waitUntil` primitive the hosting platform injects per request. Next.js
324
+ * resolves `after()` through this same accessor, and it is the only channel
325
+ * available in Pages Router API routes, which are invoked as `(req, res)` with
326
+ * no context argument to read it from.
327
+ */
328
+ function requestContextWaitUntil() {
329
+ var _a, _b;
330
+ const context = globalThis[Symbol.for('@next/request-context')];
331
+ 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;
332
+ return typeof waitUntil === 'function' ? waitUntil : undefined;
333
+ }
334
+ /**
335
+ * Middleware receives a `NextFetchEvent` as its second argument. Duck-typed
336
+ * rather than `instanceof` so the edge bundle needs no runtime import, and
337
+ * bound because `waitUntil` is a class method that collects into the event.
338
+ */
339
+ function eventWaitUntil(event) {
340
+ const waitUntil = event === null || event === void 0 ? void 0 : event.waitUntil;
341
+ return typeof waitUntil === 'function' ? waitUntil.bind(event) : undefined;
342
+ }
343
+ /**
344
+ * Ensure Insights events are delivered before the serverless/edge runtime
345
+ * freezes, without delaying the response where the runtime lets us avoid it.
346
+ *
347
+ * In order of preference: Next.js `after()` (stable in 15.1, App Router only —
348
+ * it needs App Router request context, so Pages Router must not call it), then
349
+ * a `waitUntil` from the middleware event or the platform request context,
350
+ * then a blocking `flushAsync()` when the runtime offers neither. Blocking is
351
+ * correct in that last case: no `waitUntil` means nothing is going to freeze
352
+ * the invocation out from under us.
353
+ *
354
+ * Delivery failures are logged by the events worker and must not break the handler.
355
+ */
356
+ function scheduleFlush(options = {}) {
357
+ var _a;
358
+ const flush = () => Honeybadger.flushAsync().catch(() => { });
359
+ if (options.useAfter) {
360
+ const after = nextServer.after;
361
+ if (typeof after === 'function') {
362
+ // Exported but still refusable: `after()` throws outside a supported
363
+ // context. Fall through to the remaining strategies rather than failing
364
+ // the request.
365
+ try {
366
+ after(flush);
367
+ return;
368
+ }
369
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
370
+ catch (error) {
371
+ // try waitUntil / blocking flush below
372
+ }
373
+ }
374
+ }
375
+ const waitUntil = (_a = options.waitUntil) !== null && _a !== void 0 ? _a : requestContextWaitUntil();
376
+ if (waitUntil) {
377
+ waitUntil(flush());
378
+ return;
379
+ }
380
+ return flush();
381
+ }
382
+ function configure(overrides) {
198
383
  var _a;
199
384
  if (((_a = Honeybadger.config.apiKey) === null || _a === void 0 ? void 0 : _a.length) > 0) {
200
385
  return;
@@ -213,7 +398,8 @@ function configure() {
213
398
  apiKey: process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY,
214
399
  environment: process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.VERCEL_ENV || process.env.NODE_ENV,
215
400
  revision: process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,
216
- projectRoot: 'webpack://_N_E/./'
401
+ projectRoot: 'webpack://_N_E/./',
402
+ ...overrides,
217
403
  })
218
404
  .beforeNotify((notice) => {
219
405
  if (!projectRoot) {
@@ -228,20 +414,135 @@ function configure() {
228
414
  });
229
415
  }
230
416
  /**
231
- * Wraps a handler function with Honeybadger error reporting.
232
- * Use with Next.js API route handlers or middleware.
417
+ * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,
418
+ * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`
419
+ * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).
420
+ * These are not real failures — the framework catches them upstream to produce
421
+ * the redirect/404/etc. — so we must let them propagate without reporting them,
422
+ * otherwise every redirect shows up as an error in Honeybadger.
423
+ *
424
+ * We match on the `NEXT_` prefix rather than an exhaustive list so that any
425
+ * present or future framework control-flow digest is covered. This is safe:
426
+ * genuine errors that React tags with a `digest` use an opaque hash, and other
427
+ * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,
428
+ * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.
429
+ */
430
+ function isNextControlFlowError(error) {
431
+ const digest = error === null || error === void 0 ? void 0 : error.digest;
432
+ return typeof digest === 'string' && digest.startsWith('NEXT_');
433
+ }
434
+ /**
435
+ * Detects a Pages Router API invocation: `(req, res)` where `res` is a Node
436
+ * `ServerResponse`. We branch on this structurally because — unlike an App
437
+ * Router route handler — there is no returned `Response` to read the status
438
+ * from; it lives on `res.statusCode`.
439
+ */
440
+ function isPagesApiInvocation(args) {
441
+ const req = args[0];
442
+ const res = args[1];
443
+ return (!!req && typeof req.headers === 'object' && req.headers !== null &&
444
+ !!res && typeof res.statusCode === 'number' && typeof res.end === 'function');
445
+ }
446
+ /**
447
+ * App Router route handlers and middleware: a web `Request`/`NextRequest` in, a
448
+ * `Response`/`NextResponse` out. The status comes from the returned response.
449
+ *
450
+ * `waitUntil` is present for middleware (from its `NextFetchEvent`); route
451
+ * handlers get `{ params }` as their second argument and rely on `after()`.
452
+ */
453
+ async function handleAppRouterRequest(call, req, canIsolate, waitUntil) {
454
+ const ids = seedRequestEventContext(req.headers);
455
+ if (canIsolate) {
456
+ Honeybadger.setEventContext(ids);
457
+ }
458
+ const start = insightsHttpEnabled() ? now() : null;
459
+ try {
460
+ const response = await call();
461
+ if (start !== null) {
462
+ emitRequestEvent(req, response === null || response === void 0 ? void 0 : response.status, start, ids);
463
+ await scheduleFlush({ useAfter: true, waitUntil });
464
+ }
465
+ return response;
466
+ }
467
+ catch (error) {
468
+ if (isNextControlFlowError(error)) {
469
+ throw error;
470
+ }
471
+ if (start !== null) {
472
+ emitRequestEvent(req, 500, start, ids);
473
+ await scheduleFlush({ useAfter: true, waitUntil });
474
+ }
475
+ await Honeybadger.notifyAsync(error);
476
+ throw error;
477
+ }
478
+ }
479
+ /**
480
+ * Pages Router API routes: a Node `req`/`res` pair. The handler writes to `res`
481
+ * and returns nothing meaningful, so the final status is read from
482
+ * `res.statusCode` once it resolves.
483
+ */
484
+ async function handlePagesApiRequest(call, req, res, canIsolate) {
485
+ const ids = seedNodeRequestEventContext(req.headers);
486
+ if (canIsolate) {
487
+ Honeybadger.setEventContext(ids);
488
+ }
489
+ const start = insightsHttpEnabled() ? now() : null;
490
+ try {
491
+ const result = await call();
492
+ if (start !== null) {
493
+ emitNodeRequestEvent(req, res.statusCode, start, ids);
494
+ // No after() here: Pages Router lacks the App Router request context it
495
+ // needs. scheduleFlush falls through to the platform waitUntil instead.
496
+ await scheduleFlush({ useAfter: false });
497
+ }
498
+ return result;
499
+ }
500
+ catch (error) {
501
+ if (isNextControlFlowError(error)) {
502
+ throw error;
503
+ }
504
+ if (start !== null) {
505
+ emitNodeRequestEvent(req, 500, start, ids);
506
+ await scheduleFlush({ useAfter: false });
507
+ }
508
+ await Honeybadger.notifyAsync(error);
509
+ throw error;
510
+ }
511
+ }
512
+ /**
513
+ * Unrecognised invocation shape: still report errors, but emit no insights
514
+ * event since we can't reliably read the request.
233
515
  */
234
- function withHoneybadger(handler) {
235
- configure();
516
+ async function handleUninstrumented(call) {
517
+ try {
518
+ return await call();
519
+ }
520
+ catch (error) {
521
+ if (isNextControlFlowError(error)) {
522
+ throw error;
523
+ }
524
+ await Honeybadger.notifyAsync(error);
525
+ throw error;
526
+ }
527
+ }
528
+ function withHoneybadger(handler, config) {
529
+ configure(config);
236
530
  return new Proxy(handler, {
237
- apply: async (target, thisArg, args) => {
238
- try {
239
- return await Reflect.apply(target, thisArg, args);
240
- }
241
- catch (error) {
242
- await Honeybadger.notifyAsync(error);
243
- throw error; // Re-throw the error after reporting it
244
- }
531
+ apply: (target, thisArg, args) => {
532
+ const canIsolate = typeof Honeybadger.run === 'function';
533
+ const call = () => Reflect.apply(target, thisArg, args);
534
+ const invoke = () => {
535
+ // App Router / middleware first: a web Request as the first argument.
536
+ if (typeof Request !== 'undefined' && args[0] instanceof Request) {
537
+ return handleAppRouterRequest(call, args[0], canIsolate, eventWaitUntil(args[1]));
538
+ }
539
+ // Pages Router API route: a Node req/res pair.
540
+ if (isPagesApiInvocation(args)) {
541
+ return handlePagesApiRequest(call, args[0], args[1], canIsolate);
542
+ }
543
+ return handleUninstrumented(call);
544
+ };
545
+ return canIsolate ? Honeybadger.run(invoke) : invoke();
245
546
  },
246
547
  });
247
548
  }
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-nextjs.esm.js","sources":["../../build/webpack.js","../../build/with-honeybadger.js"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack';\nconst URL_DOCS_SOURCE_MAPS_UPLOAD = 'https://docs.honeybadger.io/lib/javascript/integration/nextjs/#source-map-upload-and-tracking-deploys';\nlet _silent = true;\nfunction log(type, msg) {\n if (['error', 'warn'].includes(type) || !_silent) {\n console[type]('[HoneybadgerNextJs]', msg);\n }\n}\nfunction shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {\n const { dev } = context;\n if (honeybadgerNextJsConfig.disableSourceMapUpload) {\n return false;\n }\n if (!honeybadgerNextJsConfig.webpackPluginOptions || !honeybadgerNextJsConfig.webpackPluginOptions.apiKey) {\n log('warn', `skipping source map upload; here's how to enable: ${URL_DOCS_SOURCE_MAPS_UPLOAD}`);\n return false;\n }\n if (dev || process.env.NODE_ENV === 'development') {\n return false;\n }\n return true;\n}\nfunction mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {\n return function webpackFunctionMergedWithHb(webpackConfig, context) {\n const { isServer, dir: projectDir, nextRuntime } = context;\n const configType = isServer ? (nextRuntime === 'edge' ? 'edge' : 'server') : 'browser';\n log('debug', `reached webpackFunctionMergedWithHb isServer[${isServer}] configType[${configType}]`);\n let result = { ...webpackConfig };\n if (typeof nextJsWebpackConfig === 'function') {\n result = nextJsWebpackConfig(result, context);\n }\n const originalEntry = result.entry;\n result.entry = async () => injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType);\n if (shouldUploadSourceMaps(honeybadgerNextJsConfig, context)) {\n // `result.devtool` must be 'hidden-source-map' or 'source-map' to properly pass sourcemaps.\n // Next.js uses regular `source-map` which doesnt pass its sourcemaps to Webpack.\n // https://github.com/vercel/next.js/blob/89ec21ed686dd79a5770b5c669abaff8f55d8fef/packages/next/build/webpack/config/blocks/base.ts#L40\n // Use the hidden-source-map option when you don't want the source maps to be\n // publicly available on the servers, only to the error reporting\n result.devtool = 'hidden-source-map';\n if (!result.plugins) {\n result.plugins = [];\n }\n const options = getWebpackPluginOptions(honeybadgerNextJsConfig);\n if (options) {\n result.plugins.push(new HoneybadgerSourceMapPlugin(options));\n }\n }\n return result;\n };\n}\nasync function injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType) {\n const result = typeof originalEntry === 'function' ? await originalEntry() : { ...originalEntry };\n const hbConfigFile = getHoneybadgerConfigFile(projectDir, configType);\n if (!hbConfigFile) {\n return result;\n }\n const hbConfigFileRelativePath = `./${hbConfigFile}`;\n if (!Object.keys(result).length) {\n log('debug', `no entry points for configType[${configType}]`);\n }\n for (const entryName in result) {\n addHoneybadgerConfigToEntry(result, entryName, hbConfigFileRelativePath, configType);\n }\n return result;\n}\nfunction addHoneybadgerConfigToEntry(entry, entryName, hbConfigFile, configType) {\n log('debug', `adding entry[${entryName}] to configType[${configType}]`);\n switch (configType) {\n case 'server':\n if (!entryName.startsWith('pages/')) {\n return;\n }\n break;\n case 'browser':\n if (!['pages/_app', 'main-app'].includes(entryName)) {\n return;\n }\n break;\n case 'edge':\n // nothing?\n break;\n }\n const currentEntryPoint = entry[entryName];\n let newEntryPoint = currentEntryPoint;\n if (typeof currentEntryPoint === 'string') {\n newEntryPoint = [hbConfigFile, currentEntryPoint];\n }\n else if (Array.isArray(currentEntryPoint)) {\n newEntryPoint = [hbConfigFile, ...currentEntryPoint];\n } // descriptor object (webpack 5+)\n else if (typeof currentEntryPoint === 'object' && currentEntryPoint && 'import' in currentEntryPoint) {\n const currentImportValue = currentEntryPoint['import'];\n const newImportValue = [hbConfigFile];\n if (typeof currentImportValue === 'string') {\n newImportValue.push(currentImportValue);\n }\n else {\n newImportValue.push(...(currentImportValue));\n }\n newEntryPoint = {\n ...currentEntryPoint,\n import: newImportValue,\n };\n }\n else {\n log('error', 'Could not inject Honeybadger config to entry point: ' + JSON.stringify(currentEntryPoint, null, 2));\n }\n entry[entryName] = newEntryPoint;\n}\nfunction getHoneybadgerConfigFile(projectDir, configType) {\n const possibilities = [`honeybadger.${configType}.config.ts`, `honeybadger.${configType}.config.js`];\n for (const filename of possibilities) {\n if (fs.existsSync(path.resolve(projectDir, filename))) {\n return filename;\n }\n }\n log('debug', `could not find config file in ${projectDir} for ${configType}`);\n return null;\n}\nfunction getWebpackPluginOptions(honeybadgerNextJsConfig) {\n var _a, _b, _c;\n const apiKey = ((_a = honeybadgerNextJsConfig.webpackPluginOptions) === null || _a === void 0 ? void 0 : _a.apiKey) || process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY;\n const assetsUrl = ((_b = honeybadgerNextJsConfig.webpackPluginOptions) === null || _b === void 0 ? void 0 : _b.assetsUrl) || process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL;\n if (!apiKey || !assetsUrl) {\n log('error', 'Missing Honeybadger required configuration for webpack plugin. Source maps will not be uploaded to Honeybadger.');\n return null;\n }\n return {\n ...honeybadgerNextJsConfig.webpackPluginOptions,\n apiKey,\n assetsUrl,\n revision: ((_c = honeybadgerNextJsConfig.webpackPluginOptions) === null || _c === void 0 ? void 0 : _c.revision) || process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n silent: _silent,\n };\n}\nfunction getNextJsVersionInstalled() {\n var _a;\n try {\n return (_a = require('next/package.json').version) === null || _a === void 0 ? void 0 : _a.split('.');\n }\n catch (e) {\n return null;\n }\n}\n/**\n * NextJs will report a warning if the `serverExternalPackages` option is not present.\n * This is because @honeybadger-io/js will try to require configuration files dynamically (https://github.com/honeybadger-io/honeybadger-js/pull/1268).\n *\n * First reported here: https://github.com/honeybadger-io/honeybadger-js/issues/1351\n */\nfunction addServerExternalPackagesOption(config) {\n var _a, _b;\n // this should be available in the upcoming version of Next.js (14.3.0)\n if (config.serverExternalPackages && Array.isArray(config.serverExternalPackages)) {\n log('debug', 'adding @honeybadger-io/js to serverExternalPackages');\n config.serverExternalPackages.push('@honeybadger-io/js');\n return;\n }\n if (((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.serverComponentsExternalPackages) && Array.isArray((_b = config.experimental) === null || _b === void 0 ? void 0 : _b.serverComponentsExternalPackages)) {\n log('debug', 'adding @honeybadger-io/js to experimental.serverComponentsExternalPackages');\n config.experimental.serverComponentsExternalPackages.push('@honeybadger-io/js');\n return;\n }\n const nextJsVersion = getNextJsVersionInstalled();\n if (nextJsVersion) {\n if ((+nextJsVersion[0] === 14 && +nextJsVersion[1] >= 3) || +nextJsVersion[0] > 14) {\n log('debug', 'adding serverExternalPackages option with value [\"@honeybadger-io/js\"]');\n config.serverExternalPackages = ['@honeybadger-io/js'];\n }\n else {\n log('debug', 'adding experimental.serverComponentsExternalPackages option with value [\"@honeybadger-io/js\"]');\n if (!config.experimental) {\n config.experimental = {};\n }\n config.experimental.serverComponentsExternalPackages = ['@honeybadger-io/js'];\n }\n }\n}\nexport function setupHoneybadger(config, honeybadgerNextJsConfig) {\n var _a;\n if (!honeybadgerNextJsConfig) {\n honeybadgerNextJsConfig = {\n silent: true,\n disableSourceMapUpload: false,\n };\n }\n _silent = (_a = honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;\n addServerExternalPackagesOption(config);\n return {\n ...config,\n webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)\n };\n}\n//# sourceMappingURL=webpack.js.map","import Honeybadger from '@honeybadger-io/js';\nfunction configure() {\n var _a;\n if (((_a = Honeybadger.config.apiKey) === null || _a === void 0 ? void 0 : _a.length) > 0) {\n return;\n }\n let projectRoot = undefined;\n try {\n // not available on edge runtime\n projectRoot = process.cwd();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // do nothing\n }\n Honeybadger\n .configure({\n apiKey: process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY,\n environment: process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.VERCEL_ENV || process.env.NODE_ENV,\n revision: process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n projectRoot: 'webpack://_N_E/./'\n })\n .beforeNotify((notice) => {\n if (!projectRoot) {\n return;\n }\n notice === null || notice === void 0 ? void 0 : notice.backtrace.forEach((line) => {\n if (line.file) {\n line.file = line.file.replace(`${projectRoot}/.next/server`, `${process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL}/..`);\n }\n return line;\n });\n });\n}\n/**\n * Wraps a handler function with Honeybadger error reporting.\n * Use with Next.js API route handlers or middleware.\n */\nexport function withHoneybadger(handler) {\n configure();\n return new Proxy(handler, {\n apply: async (target, thisArg, args) => {\n try {\n return await Reflect.apply(target, thisArg, args);\n }\n catch (error) {\n await Honeybadger.notifyAsync(error);\n throw error; // Re-throw the error after reporting it\n }\n },\n });\n}\n//# sourceMappingURL=with-honeybadger.js.map"],"names":[],"mappings":";;;;;AAGA,MAAM,2BAA2B,GAAG,uGAAuG,CAAC;AAC5I,IAAI,OAAO,GAAG,IAAI,CAAC;AACnB,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE;AACxB,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACtD,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;AAClD,KAAK;AACL,CAAC;AACD,SAAS,sBAAsB,CAAC,uBAAuB,EAAE,OAAO,EAAE;AAClE,IAAI,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAC5B,IAAI,IAAI,uBAAuB,CAAC,sBAAsB,EAAE;AACxD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,IAAI,CAAC,uBAAuB,CAAC,oBAAoB,IAAI,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,MAAM,EAAE;AAC/G,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC,kDAAkD,EAAE,2BAA2B,CAAC,CAAC,CAAC,CAAC;AACxG,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,IAAI,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;AACvD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,CAAC;AACD,SAAS,8BAA8B,CAAC,mBAAmB,EAAE,uBAAuB,EAAE;AACtF,IAAI,OAAO,SAAS,2BAA2B,CAAC,aAA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AC,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK;AAC3F,YAAY,IAAI,IAAI,CAAC,IAAI,EAAE;AAC3B,gBAAgB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,GAAG,CAAC,CAAC,CAAC;AACrI,aAAa;AACb,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP,CAAC;AACD;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,OAAO,EAAE;AACzC,IAAI,SAAS,EAAE,CAAC;AAChB,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;AAC9B,QAAQ,KAAK,EAAE,OAAO,MAAM,EAAE,OAAO,EAAE,IAAI,KAAK;AAChD,YAAY,IAAI;AAChB,gBAAgB,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAClE,aAAa;AACb,YAAY,OAAO,KAAK,EAAE;AAC1B,gBAAgB,MAAM,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACrD,gBAAgB,MAAM,KAAK,CAAC;AAC5B,aAAa;AACb,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"honeybadger-nextjs.esm.js","sources":["../../build/webpack.js","../../build/insights-instrumentation.js","../../build/with-honeybadger.js"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack';\nconst URL_DOCS_SOURCE_MAPS_UPLOAD = 'https://docs.honeybadger.io/lib/javascript/integration/nextjs/#source-map-upload-and-tracking-deploys';\nlet _silent = true;\nfunction log(type, msg) {\n if (['error', 'warn'].includes(type) || !_silent) {\n console[type]('[HoneybadgerNextJs]', msg);\n }\n}\nfunction shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {\n const { dev } = context;\n if (honeybadgerNextJsConfig.disableSourceMapUpload) {\n return false;\n }\n if (!honeybadgerNextJsConfig.webpackPluginOptions || !honeybadgerNextJsConfig.webpackPluginOptions.apiKey) {\n log('warn', `skipping source map upload; here's how to enable: ${URL_DOCS_SOURCE_MAPS_UPLOAD}`);\n return false;\n }\n if (dev || process.env.NODE_ENV === 'development') {\n return false;\n }\n return true;\n}\nfunction mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {\n return function webpackFunctionMergedWithHb(webpackConfig, context) {\n const { isServer, dir: projectDir, nextRuntime } = context;\n const configType = isServer ? (nextRuntime === 'edge' ? 'edge' : 'server') : 'browser';\n log('debug', `reached webpackFunctionMergedWithHb isServer[${isServer}] configType[${configType}]`);\n let result = { ...webpackConfig };\n if (typeof nextJsWebpackConfig === 'function') {\n result = nextJsWebpackConfig(result, context);\n }\n const originalEntry = result.entry;\n result.entry = async () => injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType);\n if (shouldUploadSourceMaps(honeybadgerNextJsConfig, context)) {\n // `result.devtool` must be 'hidden-source-map' or 'source-map' to properly pass sourcemaps.\n // Next.js uses regular `source-map` which doesnt pass its sourcemaps to Webpack.\n // https://github.com/vercel/next.js/blob/89ec21ed686dd79a5770b5c669abaff8f55d8fef/packages/next/build/webpack/config/blocks/base.ts#L40\n // Use the hidden-source-map option when you don't want the source maps to be\n // publicly available on the servers, only to the error reporting\n result.devtool = 'hidden-source-map';\n if (!result.plugins) {\n result.plugins = [];\n }\n const options = getWebpackPluginOptions(honeybadgerNextJsConfig);\n if (options) {\n result.plugins.push(new HoneybadgerSourceMapPlugin(options));\n }\n }\n return result;\n };\n}\nasync function injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType) {\n const result = typeof originalEntry === 'function' ? await originalEntry() : { ...originalEntry };\n const hbConfigFile = getHoneybadgerConfigFile(projectDir, configType);\n if (!hbConfigFile) {\n return result;\n }\n const hbConfigFileRelativePath = `./${hbConfigFile}`;\n if (!Object.keys(result).length) {\n log('debug', `no entry points for configType[${configType}]`);\n }\n for (const entryName in result) {\n addHoneybadgerConfigToEntry(result, entryName, hbConfigFileRelativePath, configType);\n }\n return result;\n}\nfunction addHoneybadgerConfigToEntry(entry, entryName, hbConfigFile, configType) {\n log('debug', `adding entry[${entryName}] to configType[${configType}]`);\n switch (configType) {\n case 'server':\n if (!entryName.startsWith('pages/')) {\n return;\n }\n break;\n case 'browser':\n if (!['pages/_app', 'main-app'].includes(entryName)) {\n return;\n }\n break;\n case 'edge':\n // nothing?\n break;\n }\n const currentEntryPoint = entry[entryName];\n let newEntryPoint = currentEntryPoint;\n if (typeof currentEntryPoint === 'string') {\n newEntryPoint = [hbConfigFile, currentEntryPoint];\n }\n else if (Array.isArray(currentEntryPoint)) {\n newEntryPoint = [hbConfigFile, ...currentEntryPoint];\n } // descriptor object (webpack 5+)\n else if (typeof currentEntryPoint === 'object' && currentEntryPoint && 'import' in currentEntryPoint) {\n const currentImportValue = currentEntryPoint['import'];\n const newImportValue = [hbConfigFile];\n if (typeof currentImportValue === 'string') {\n newImportValue.push(currentImportValue);\n }\n else {\n newImportValue.push(...(currentImportValue));\n }\n newEntryPoint = {\n ...currentEntryPoint,\n import: newImportValue,\n };\n }\n else {\n log('error', 'Could not inject Honeybadger config to entry point: ' + JSON.stringify(currentEntryPoint, null, 2));\n }\n entry[entryName] = newEntryPoint;\n}\nfunction getHoneybadgerConfigFile(projectDir, configType) {\n const possibilities = [`honeybadger.${configType}.config.ts`, `honeybadger.${configType}.config.js`];\n for (const filename of possibilities) {\n if (fs.existsSync(path.resolve(projectDir, filename))) {\n return filename;\n }\n }\n log('debug', `could not find config file in ${projectDir} for ${configType}`);\n return null;\n}\nfunction getWebpackPluginOptions(honeybadgerNextJsConfig) {\n var _a, _b, _c;\n const apiKey = ((_a = honeybadgerNextJsConfig.webpackPluginOptions) === null || _a === void 0 ? void 0 : _a.apiKey) || process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY;\n const assetsUrl = ((_b = honeybadgerNextJsConfig.webpackPluginOptions) === null || _b === void 0 ? void 0 : _b.assetsUrl) || process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL;\n if (!apiKey || !assetsUrl) {\n log('error', 'Missing Honeybadger required configuration for webpack plugin. Source maps will not be uploaded to Honeybadger.');\n return null;\n }\n return {\n ...honeybadgerNextJsConfig.webpackPluginOptions,\n apiKey,\n assetsUrl,\n revision: ((_c = honeybadgerNextJsConfig.webpackPluginOptions) === null || _c === void 0 ? void 0 : _c.revision) || process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n silent: _silent,\n };\n}\nfunction getNextJsVersionInstalled() {\n var _a;\n try {\n return (_a = require('next/package.json').version) === null || _a === void 0 ? void 0 : _a.split('.');\n }\n catch (e) {\n return null;\n }\n}\n/**\n * NextJs will report a warning if the `serverExternalPackages` option is not present.\n * This is because @honeybadger-io/js will try to require configuration files dynamically (https://github.com/honeybadger-io/honeybadger-js/pull/1268).\n *\n * First reported here: https://github.com/honeybadger-io/honeybadger-js/issues/1351\n */\nfunction addServerExternalPackagesOption(config) {\n var _a, _b;\n // this should be available in the upcoming version of Next.js (14.3.0)\n if (config.serverExternalPackages && Array.isArray(config.serverExternalPackages)) {\n log('debug', 'adding @honeybadger-io/js to serverExternalPackages');\n config.serverExternalPackages.push('@honeybadger-io/js');\n return;\n }\n if (((_a = config.experimental) === null || _a === void 0 ? void 0 : _a.serverComponentsExternalPackages) && Array.isArray((_b = config.experimental) === null || _b === void 0 ? void 0 : _b.serverComponentsExternalPackages)) {\n log('debug', 'adding @honeybadger-io/js to experimental.serverComponentsExternalPackages');\n config.experimental.serverComponentsExternalPackages.push('@honeybadger-io/js');\n return;\n }\n const nextJsVersion = getNextJsVersionInstalled();\n if (nextJsVersion) {\n if ((+nextJsVersion[0] === 14 && +nextJsVersion[1] >= 3) || +nextJsVersion[0] > 14) {\n log('debug', 'adding serverExternalPackages option with value [\"@honeybadger-io/js\"]');\n config.serverExternalPackages = ['@honeybadger-io/js'];\n }\n else {\n log('debug', 'adding experimental.serverComponentsExternalPackages option with value [\"@honeybadger-io/js\"]');\n if (!config.experimental) {\n config.experimental = {};\n }\n config.experimental.serverComponentsExternalPackages = ['@honeybadger-io/js'];\n }\n }\n}\nexport function setupHoneybadger(config, honeybadgerNextJsConfig) {\n var _a;\n if (!honeybadgerNextJsConfig) {\n honeybadgerNextJsConfig = {\n silent: true,\n disableSourceMapUpload: false,\n };\n }\n _silent = (_a = honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;\n addServerExternalPackagesOption(config);\n return {\n ...config,\n webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)\n };\n}\n//# sourceMappingURL=webpack.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 also load on the edge 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// 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.\nfunction seedIds(read) {\n var _a, _b, _c, _d;\n const requestId = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : generateId();\n const correlationId = (_d = (_c = read('x-correlation-id')) !== null && _c !== void 0 ? _c : read('x-amzn-trace-id')) !== null && _d !== void 0 ? _d : requestId;\n return { request_id: requestId, correlation_id: correlationId };\n}\n// App Router / middleware: headers are a web `Headers` instance.\nexport function seedRequestEventContext(headers) {\n return seedIds((name) => readHeader(headers, name));\n}\n// Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).\nexport function seedNodeRequestEventContext(headers) {\n return seedIds((name) => readNodeHeader(headers, name));\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 on the edge\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//# sourceMappingURL=insights-instrumentation.js.map","import Honeybadger from '@honeybadger-io/js';\nimport * as nextServer from 'next/server';\nimport { emitNodeRequestEvent, emitRequestEvent, insightsHttpEnabled, now, seedNodeRequestEventContext, seedRequestEventContext, } from './insights-instrumentation';\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 */\nfunction 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 * Middleware receives a `NextFetchEvent` as its second argument. Duck-typed\n * rather than `instanceof` so the edge bundle needs no runtime import, and\n * bound because `waitUntil` is a class method that collects into the event.\n */\nfunction eventWaitUntil(event) {\n const waitUntil = event === null || event === void 0 ? void 0 : event.waitUntil;\n return typeof waitUntil === 'function' ? waitUntil.bind(event) : undefined;\n}\n/**\n * Ensure Insights events are delivered before the serverless/edge runtime\n * freezes, without delaying the response where the runtime lets us avoid it.\n *\n * In order of preference: Next.js `after()` (stable in 15.1, App Router only —\n * it needs App Router request context, so Pages Router must not call it), then\n * a `waitUntil` from the middleware event or the platform request context,\n * then a blocking `flushAsync()` when the runtime offers neither. Blocking is\n * correct in that last case: no `waitUntil` means nothing is going to freeze\n * the invocation out from under us.\n *\n * Delivery failures are logged by the events worker and must not break the handler.\n */\nfunction 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}\nfunction configure(overrides) {\n var _a;\n if (((_a = Honeybadger.config.apiKey) === null || _a === void 0 ? void 0 : _a.length) > 0) {\n return;\n }\n let projectRoot = undefined;\n try {\n // not available on edge runtime\n projectRoot = process.cwd();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // do nothing\n }\n Honeybadger\n .configure({\n apiKey: process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY,\n environment: process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.VERCEL_ENV || process.env.NODE_ENV,\n revision: process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n projectRoot: 'webpack://_N_E/./',\n ...overrides,\n })\n .beforeNotify((notice) => {\n if (!projectRoot) {\n return;\n }\n notice === null || notice === void 0 ? void 0 : notice.backtrace.forEach((line) => {\n if (line.file) {\n line.file = line.file.replace(`${projectRoot}/.next/server`, `${process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL}/..`);\n }\n return line;\n });\n });\n}\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 propagate without reporting them,\n * otherwise 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 * Detects a Pages Router API invocation: `(req, res)` where `res` is a Node\n * `ServerResponse`. We branch on this structurally because — unlike an App\n * Router route handler — there is no returned `Response` to read the status\n * from; it lives on `res.statusCode`.\n */\nfunction isPagesApiInvocation(args) {\n const req = args[0];\n const res = args[1];\n return (!!req && typeof req.headers === 'object' && req.headers !== null &&\n !!res && typeof res.statusCode === 'number' && typeof res.end === 'function');\n}\n/**\n * App Router route handlers and middleware: a web `Request`/`NextRequest` in, a\n * `Response`/`NextResponse` out. The status comes from the returned response.\n *\n * `waitUntil` is present for middleware (from its `NextFetchEvent`); route\n * handlers get `{ params }` as their second argument and rely on `after()`.\n */\nasync function handleAppRouterRequest(call, req, canIsolate, waitUntil) {\n const ids = seedRequestEventContext(req.headers);\n if (canIsolate) {\n Honeybadger.setEventContext(ids);\n }\n const start = insightsHttpEnabled() ? now() : null;\n try {\n const response = await call();\n if (start !== null) {\n emitRequestEvent(req, response === null || response === void 0 ? void 0 : response.status, start, ids);\n await scheduleFlush({ useAfter: true, waitUntil });\n }\n return response;\n }\n catch (error) {\n if (isNextControlFlowError(error)) {\n throw error;\n }\n if (start !== null) {\n emitRequestEvent(req, 500, start, ids);\n await scheduleFlush({ useAfter: true, waitUntil });\n }\n await Honeybadger.notifyAsync(error);\n throw error;\n }\n}\n/**\n * Pages Router API routes: a Node `req`/`res` pair. The handler writes to `res`\n * and returns nothing meaningful, so the final status is read from\n * `res.statusCode` once it resolves.\n */\nasync function handlePagesApiRequest(call, req, res, canIsolate) {\n const ids = seedNodeRequestEventContext(req.headers);\n if (canIsolate) {\n Honeybadger.setEventContext(ids);\n }\n const start = insightsHttpEnabled() ? now() : null;\n try {\n const result = await call();\n if (start !== null) {\n emitNodeRequestEvent(req, res.statusCode, start, ids);\n // No after() here: Pages Router lacks the App Router request context it\n // needs. scheduleFlush falls through to the platform waitUntil instead.\n await scheduleFlush({ useAfter: false });\n }\n return result;\n }\n catch (error) {\n if (isNextControlFlowError(error)) {\n throw error;\n }\n if (start !== null) {\n emitNodeRequestEvent(req, 500, start, ids);\n await scheduleFlush({ useAfter: false });\n }\n await Honeybadger.notifyAsync(error);\n throw error;\n }\n}\n/**\n * Unrecognised invocation shape: still report errors, but emit no insights\n * event since we can't reliably read the request.\n */\nasync function handleUninstrumented(call) {\n try {\n return await call();\n }\n catch (error) {\n if (isNextControlFlowError(error)) {\n throw error;\n }\n await Honeybadger.notifyAsync(error);\n throw error;\n }\n}\nexport function withHoneybadger(handler, config) {\n configure(config);\n return new Proxy(handler, {\n apply: (target, thisArg, args) => {\n const canIsolate = typeof Honeybadger.run === 'function';\n const call = () => Reflect.apply(target, thisArg, args);\n const invoke = () => {\n // App Router / middleware first: a web Request as the first argument.\n if (typeof Request !== 'undefined' && args[0] instanceof Request) {\n return handleAppRouterRequest(call, args[0], canIsolate, eventWaitUntil(args[1]));\n }\n // Pages Router API route: a Node req/res pair.\n if (isPagesApiInvocation(args)) {\n return handlePagesApiRequest(call, args[0], args[1], canIsolate);\n }\n return handleUninstrumented(call);\n };\n return canIsolate ? Honeybadger.run(invoke) :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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtG,iBAAiB;AACjB;AACA,gBAAgB,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE;AAChD,oBAAoB,OAAO,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACrF,iBAAiB;AACjB,gBAAgB,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAClD,aAAa,CAAC;AACd,YAAY,OAAO,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;AACnE,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -0,0 +1,17 @@
1
+ export type NodeHeaders = Record<string, string | string[] | undefined>;
2
+ export type NodeRequestLike = {
3
+ method?: string;
4
+ url?: string;
5
+ headers: NodeHeaders;
6
+ };
7
+ export type RequestIds = {
8
+ request_id: string;
9
+ correlation_id: string;
10
+ };
11
+ export declare function seedRequestEventContext(headers: Headers): RequestIds;
12
+ export declare function seedNodeRequestEventContext(headers: NodeHeaders): RequestIds;
13
+ export declare function now(): number;
14
+ export declare function insightsHttpEnabled(): boolean;
15
+ export declare function emitRequestEvent(req: Request, status: number | undefined, start: number, ids: RequestIds): void;
16
+ export declare function emitNodeRequestEvent(req: NodeRequestLike, status: number | undefined, start: number, ids: RequestIds): void;
17
+ //# sourceMappingURL=insights-instrumentation.d.ts.map
@@ -1,7 +1,32 @@
1
+ import Honeybadger from '@honeybadger-io/js';
1
2
  import { NextRequest, NextResponse } from 'next/server';
3
+ import type { NextApiRequest, NextApiResponse } from 'next';
4
+ type AppRouterHandler = (req: NextRequest | Request, ...args: unknown[]) => Promise<NextResponse>;
5
+ type PagesApiHandler = (req: NextApiRequest, res: NextApiResponse, ...args: unknown[]) => unknown;
2
6
  /**
3
- * Wraps a handler function with Honeybadger error reporting.
4
- * Use with Next.js API route handlers or middleware.
7
+ * Wraps a handler function with Honeybadger error reporting. Works with App
8
+ * Router route handlers, middleware, and Pages Router API routes.
9
+ *
10
+ * `request_id` / `correlation_id` are read from the `x-request-id` /
11
+ * `request-id` and `x-correlation-id` / `x-amzn-trace-id` headers (generated
12
+ * when absent). When `insights: { enabled: true, http: true }` is configured,
13
+ * a `request.handled` event carrying the ids plus method, path, status and
14
+ * duration is emitted per request.
15
+ *
16
+ * On the Node.js runtime each invocation additionally runs inside
17
+ * `Honeybadger.run(...)`, so context is isolated per request and the ids are
18
+ * seeded onto the event context — merged onto every event emitted during the
19
+ * request, including programmatic `Honeybadger.event(...)` calls. On the edge
20
+ * runtime (browser build, single global store) seeding the shared event
21
+ * context would leak ids between concurrent requests, so programmatic events
22
+ * there don't inherit them.
23
+ *
24
+ * The webpack config-file auto-injection (`honeybadger.*.config.js`) doesn't
25
+ * reach API routes or edge middleware, so pass `config` to configure
26
+ * Honeybadger explicitly there. It's ignored if Honeybadger is already
27
+ * configured (e.g. by the auto-injected file).
5
28
  */
6
- export declare function withHoneybadger(handler: (req: NextRequest | Request, ...args: unknown[]) => Promise<NextResponse>): (req: NextRequest | Request, ...args: unknown[]) => Promise<NextResponse>;
29
+ export declare function withHoneybadger(handler: AppRouterHandler, config?: Parameters<typeof Honeybadger.configure>[0]): AppRouterHandler;
30
+ export declare function withHoneybadger(handler: PagesApiHandler, config?: Parameters<typeof Honeybadger.configure>[0]): PagesApiHandler;
31
+ export {};
7
32
  //# sourceMappingURL=with-honeybadger.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with-honeybadger.test.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honeybadger-io/nextjs",
3
- "version": "5.10.13",
3
+ "version": "5.11.0",
4
4
  "description": "Next.js integration for Honeybadger",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -17,6 +17,30 @@
17
17
  "main": "dist/honeybadger-nextjs.cjs.js",
18
18
  "module": "dist/honeybadger-nextjs.esm.js",
19
19
  "types": "./dist/index.d.ts",
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": {
23
+ "edge-light": {
24
+ "types": "./dist/edge.d.ts",
25
+ "import": "./dist/honeybadger-nextjs-edge.esm.js",
26
+ "require": "./dist/honeybadger-nextjs-edge.cjs.js"
27
+ },
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/honeybadger-nextjs.esm.js",
30
+ "require": "./dist/honeybadger-nextjs.cjs.js"
31
+ },
32
+ "./package.json": "./package.json",
33
+ "./dist/*.js": "./dist/*.js",
34
+ "./dist/*.d.ts": "./dist/*.d.ts",
35
+ "./dist/*.js.map": "./dist/*.js.map",
36
+ "./dist/*": "./dist/*.js",
37
+ "./src/*.ts": "./src/*.ts",
38
+ "./src/*.tsx": "./src/*.tsx",
39
+ "./src/*.js": "./src/*.js",
40
+ "./src/*": "./src/*.ts",
41
+ "./scripts/*": "./scripts/*",
42
+ "./templates/*": "./templates/*"
43
+ },
20
44
  "files": [
21
45
  "dist",
22
46
  "src",
@@ -42,20 +66,23 @@
42
66
  "next": ">= 13.x"
43
67
  },
44
68
  "dependencies": {
45
- "@honeybadger-io/js": "^6.15.2",
46
- "@honeybadger-io/webpack": "^6.3.3"
69
+ "@honeybadger-io/js": "^6.16.0",
70
+ "@honeybadger-io/webpack": "^6.3.4"
47
71
  },
48
72
  "devDependencies": {
49
- "@honeybadger-io/react": "^6.1.28",
73
+ "@honeybadger-io/react": "^6.1.30",
50
74
  "@rollup/plugin-commonjs": "^22.0.0",
51
75
  "@types/jest": "^29.5.3",
52
76
  "jest": "^29.6.1",
53
77
  "mock-fs": "^5.2.0",
54
78
  "next": "^13.2.3",
79
+ "react": "^18.2.0",
80
+ "react-dom": "^18.2.0",
55
81
  "rollup": "^2.70.2",
56
82
  "rollup-plugin-copy": "^3.4.0",
57
83
  "ts-jest": "^29.1.1",
58
- "typescript": "^4.6.3"
84
+ "typescript": "^4.6.3",
85
+ "undici": "^6.27.0"
59
86
  },
60
87
  "engines": {
61
88
  "node": ">=14"
@@ -63,5 +90,5 @@
63
90
  "publishConfig": {
64
91
  "access": "public"
65
92
  },
66
- "gitHead": "cb57a92ecea594d74b31e7700768c661e8eb401d"
93
+ "gitHead": "471dbce000d6f499b048cb612009fcfed41cdd91"
67
94
  }