@honeybadger-io/nextjs 5.10.9 → 5.10.11

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/edge.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './with-honeybadger';
2
+ //# sourceMappingURL=edge.d.ts.map
@@ -0,0 +1,295 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Honeybadger = require('@honeybadger-io/js');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var Honeybadger__default = /*#__PURE__*/_interopDefaultLegacy(Honeybadger);
10
+
11
+ /**
12
+ * Edge-safe equivalents of the inbound instrumentation helpers in
13
+ * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are
14
+ * duplicated here because this module must also load on the edge runtime where
15
+ * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep
16
+ * the header names and the `request_id` / `correlation_id` contract in sync
17
+ * with that file.
18
+ *
19
+ * Both request shapes Next.js uses are supported: the `*RequestEventContext` /
20
+ * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router
21
+ * route handlers and middleware) and a Node-bag variant (Pages Router API
22
+ * routes, which only ever run on the Node runtime).
23
+ */
24
+ function generateId() {
25
+ const webCrypto = globalThis.crypto;
26
+ if (webCrypto && typeof webCrypto.randomUUID === 'function') {
27
+ try {
28
+ return webCrypto.randomUUID();
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ catch (error) {
32
+ // fall through to manual generation
33
+ }
34
+ }
35
+ // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,
36
+ // not a security token.
37
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {
38
+ const r = (Math.random() * 16) | 0;
39
+ const v = ch === 'x' ? r : (r & 0x3) | 0x8;
40
+ return v.toString(16);
41
+ });
42
+ }
43
+ function readHeader(headers, name) {
44
+ const value = headers.get(name);
45
+ if (typeof value !== 'string') {
46
+ return undefined;
47
+ }
48
+ const trimmed = value.trim();
49
+ return trimmed.length ? trimmed : undefined;
50
+ }
51
+ function readNodeHeader(headers, name) {
52
+ if (!headers) {
53
+ return undefined;
54
+ }
55
+ const lower = name.toLowerCase();
56
+ let value = headers[lower];
57
+ if (value === undefined) {
58
+ for (const key of Object.keys(headers)) {
59
+ if (key.toLowerCase() === lower) {
60
+ value = headers[key];
61
+ break;
62
+ }
63
+ }
64
+ }
65
+ if (Array.isArray(value)) {
66
+ value = value[0];
67
+ }
68
+ if (typeof value !== 'string') {
69
+ return undefined;
70
+ }
71
+ const trimmed = value.trim();
72
+ return trimmed.length ? trimmed : undefined;
73
+ }
74
+ // Shared id precedence. Kept in one place (rather than once per request shape)
75
+ // so the header-name contract documented above is only spelled out once.
76
+ function seedIds(read) {
77
+ var _a, _b, _c, _d;
78
+ const requestId = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : generateId();
79
+ const correlationId = (_d = (_c = read('x-correlation-id')) !== null && _c !== void 0 ? _c : read('x-amzn-trace-id')) !== null && _d !== void 0 ? _d : requestId;
80
+ return { request_id: requestId, correlation_id: correlationId };
81
+ }
82
+ // App Router / middleware: headers are a web `Headers` instance.
83
+ function seedRequestEventContext(headers) {
84
+ return seedIds((name) => readHeader(headers, name));
85
+ }
86
+ // Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).
87
+ function seedNodeRequestEventContext(headers) {
88
+ return seedIds((name) => readNodeHeader(headers, name));
89
+ }
90
+ function now() {
91
+ return typeof performance !== 'undefined' ? performance.now() : Date.now();
92
+ }
93
+ // Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and
94
+ // the per-source flag must both be on.
95
+ function insightsHttpEnabled() {
96
+ const insights = Honeybadger__default["default"].config.insights;
97
+ return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;
98
+ }
99
+ // The ids are embedded directly in the payload (instead of relying on the
100
+ // store's eventContext merge) so the event carries them even on the edge
101
+ // runtime, where there is no per-request store isolation. On the Node.js
102
+ // runtime they match the seeded event context, so embedding is a no-op.
103
+ function emitHandledEvent(method, path, status, start, ids) {
104
+ const payload = {
105
+ method,
106
+ duration: Math.round(now() - start),
107
+ ...ids,
108
+ };
109
+ if (typeof path === 'string') {
110
+ payload.path = path;
111
+ }
112
+ if (typeof status === 'number') {
113
+ payload.status = status;
114
+ }
115
+ Honeybadger__default["default"].event('request.handled', payload);
116
+ }
117
+ // App Router / middleware: `req.url` is absolute, so parse out the pathname.
118
+ function emitRequestEvent(req, status, start, ids) {
119
+ let path;
120
+ try {
121
+ path = new URL(req.url).pathname;
122
+ }
123
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
124
+ catch (error) {
125
+ // relative or malformed URL — leave path unset
126
+ }
127
+ emitHandledEvent(req.method, path, status, start, ids);
128
+ }
129
+ // Pages Router: `req.url` is a relative path that may carry a query string.
130
+ function emitNodeRequestEvent(req, status, start, ids) {
131
+ const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;
132
+ emitHandledEvent(req.method, path, status, start, ids);
133
+ }
134
+
135
+ function configure(overrides) {
136
+ var _a;
137
+ if (((_a = Honeybadger__default["default"].config.apiKey) === null || _a === void 0 ? void 0 : _a.length) > 0) {
138
+ return;
139
+ }
140
+ let projectRoot = undefined;
141
+ try {
142
+ // not available on edge runtime
143
+ projectRoot = process.cwd();
144
+ }
145
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
146
+ catch (error) {
147
+ // do nothing
148
+ }
149
+ Honeybadger__default["default"]
150
+ .configure({
151
+ apiKey: process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY,
152
+ environment: process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.VERCEL_ENV || process.env.NODE_ENV,
153
+ revision: process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,
154
+ projectRoot: 'webpack://_N_E/./',
155
+ ...overrides,
156
+ })
157
+ .beforeNotify((notice) => {
158
+ if (!projectRoot) {
159
+ return;
160
+ }
161
+ notice === null || notice === void 0 ? void 0 : notice.backtrace.forEach((line) => {
162
+ if (line.file) {
163
+ line.file = line.file.replace(`${projectRoot}/.next/server`, `${process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL}/..`);
164
+ }
165
+ return line;
166
+ });
167
+ });
168
+ }
169
+ /**
170
+ * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,
171
+ * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`
172
+ * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).
173
+ * These are not real failures — the framework catches them upstream to produce
174
+ * the redirect/404/etc. — so we must let them propagate without reporting them,
175
+ * otherwise every redirect shows up as an error in Honeybadger.
176
+ *
177
+ * We match on the `NEXT_` prefix rather than an exhaustive list so that any
178
+ * present or future framework control-flow digest is covered. This is safe:
179
+ * genuine errors that React tags with a `digest` use an opaque hash, and other
180
+ * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,
181
+ * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.
182
+ */
183
+ function isNextControlFlowError(error) {
184
+ const digest = error === null || error === void 0 ? void 0 : error.digest;
185
+ return typeof digest === 'string' && digest.startsWith('NEXT_');
186
+ }
187
+ /**
188
+ * Detects a Pages Router API invocation: `(req, res)` where `res` is a Node
189
+ * `ServerResponse`. We branch on this structurally because — unlike an App
190
+ * Router route handler — there is no returned `Response` to read the status
191
+ * from; it lives on `res.statusCode`.
192
+ */
193
+ function isPagesApiInvocation(args) {
194
+ const req = args[0];
195
+ const res = args[1];
196
+ return (!!req && typeof req.headers === 'object' && req.headers !== null &&
197
+ !!res && typeof res.statusCode === 'number' && typeof res.end === 'function');
198
+ }
199
+ /**
200
+ * App Router route handlers and middleware: a web `Request`/`NextRequest` in, a
201
+ * `Response`/`NextResponse` out. The status comes from the returned response.
202
+ */
203
+ async function handleAppRouterRequest(call, req, canIsolate) {
204
+ const ids = seedRequestEventContext(req.headers);
205
+ if (canIsolate) {
206
+ Honeybadger__default["default"].setEventContext(ids);
207
+ }
208
+ const start = insightsHttpEnabled() ? now() : null;
209
+ try {
210
+ const response = await call();
211
+ if (start !== null) {
212
+ emitRequestEvent(req, response === null || response === void 0 ? void 0 : response.status, start, ids);
213
+ }
214
+ return response;
215
+ }
216
+ catch (error) {
217
+ if (isNextControlFlowError(error)) {
218
+ throw error;
219
+ }
220
+ if (start !== null) {
221
+ emitRequestEvent(req, 500, start, ids);
222
+ }
223
+ await Honeybadger__default["default"].notifyAsync(error);
224
+ throw error;
225
+ }
226
+ }
227
+ /**
228
+ * Pages Router API routes: a Node `req`/`res` pair. The handler writes to `res`
229
+ * and returns nothing meaningful, so the final status is read from
230
+ * `res.statusCode` once it resolves.
231
+ */
232
+ async function handlePagesApiRequest(call, req, res, canIsolate) {
233
+ const ids = seedNodeRequestEventContext(req.headers);
234
+ if (canIsolate) {
235
+ Honeybadger__default["default"].setEventContext(ids);
236
+ }
237
+ const start = insightsHttpEnabled() ? now() : null;
238
+ try {
239
+ const result = await call();
240
+ if (start !== null) {
241
+ emitNodeRequestEvent(req, res.statusCode, start, ids);
242
+ }
243
+ return result;
244
+ }
245
+ catch (error) {
246
+ if (isNextControlFlowError(error)) {
247
+ throw error;
248
+ }
249
+ if (start !== null) {
250
+ emitNodeRequestEvent(req, 500, start, ids);
251
+ }
252
+ await Honeybadger__default["default"].notifyAsync(error);
253
+ throw error;
254
+ }
255
+ }
256
+ /**
257
+ * Unrecognised invocation shape: still report errors, but emit no insights
258
+ * event since we can't reliably read the request.
259
+ */
260
+ async function handleUninstrumented(call) {
261
+ try {
262
+ return await call();
263
+ }
264
+ catch (error) {
265
+ if (isNextControlFlowError(error)) {
266
+ throw error;
267
+ }
268
+ await Honeybadger__default["default"].notifyAsync(error);
269
+ throw error;
270
+ }
271
+ }
272
+ function withHoneybadger(handler, config) {
273
+ configure(config);
274
+ return new Proxy(handler, {
275
+ apply: (target, thisArg, args) => {
276
+ const canIsolate = typeof Honeybadger__default["default"].run === 'function';
277
+ const call = () => Reflect.apply(target, thisArg, args);
278
+ const invoke = () => {
279
+ // App Router / middleware first: a web Request as the first argument.
280
+ if (typeof Request !== 'undefined' && args[0] instanceof Request) {
281
+ return handleAppRouterRequest(call, args[0], canIsolate);
282
+ }
283
+ // Pages Router API route: a Node req/res pair.
284
+ if (isPagesApiInvocation(args)) {
285
+ return handlePagesApiRequest(call, args[0], args[1], canIsolate);
286
+ }
287
+ return handleUninstrumented(call);
288
+ };
289
+ return canIsolate ? Honeybadger__default["default"].run(invoke) : invoke();
290
+ },
291
+ });
292
+ }
293
+
294
+ exports.withHoneybadger = withHoneybadger;
295
+ //# sourceMappingURL=honeybadger-nextjs-edge.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"honeybadger-nextjs-edge.cjs.js","sources":["../../build/insights-instrumentation.js","../../build/with-honeybadger.js"],"sourcesContent":["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 { emitNodeRequestEvent, emitRequestEvent, insightsHttpEnabled, now, seedNodeRequestEventContext, seedRequestEventContext, } from './insights-instrumentation';\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 */\nasync function handleAppRouterRequest(call, req, canIsolate) {\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 }\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 }\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 }\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 }\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);\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) : invoke();\n },\n });\n}\n//# sourceMappingURL=with-honeybadger.js.map"],"names":["Honeybadger"],"mappings":";;;;;;;;;;AACA;AACA;A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AAgB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,OAAO,EAAE;AAClF,oBAAoB,OAAO,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAC7E,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,GAAGA,+BAAW,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;AACnE,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -0,0 +1,287 @@
1
+ import Honeybadger from '@honeybadger-io/js';
2
+
3
+ /**
4
+ * Edge-safe equivalents of the inbound instrumentation helpers in
5
+ * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are
6
+ * duplicated here because this module must also load on the edge runtime where
7
+ * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep
8
+ * the header names and the `request_id` / `correlation_id` contract in sync
9
+ * with that file.
10
+ *
11
+ * Both request shapes Next.js uses are supported: the `*RequestEventContext` /
12
+ * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router
13
+ * route handlers and middleware) and a Node-bag variant (Pages Router API
14
+ * routes, which only ever run on the Node runtime).
15
+ */
16
+ function generateId() {
17
+ const webCrypto = globalThis.crypto;
18
+ if (webCrypto && typeof webCrypto.randomUUID === 'function') {
19
+ try {
20
+ return webCrypto.randomUUID();
21
+ }
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ catch (error) {
24
+ // fall through to manual generation
25
+ }
26
+ }
27
+ // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,
28
+ // not a security token.
29
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {
30
+ const r = (Math.random() * 16) | 0;
31
+ const v = ch === 'x' ? r : (r & 0x3) | 0x8;
32
+ return v.toString(16);
33
+ });
34
+ }
35
+ function readHeader(headers, name) {
36
+ const value = headers.get(name);
37
+ if (typeof value !== 'string') {
38
+ return undefined;
39
+ }
40
+ const trimmed = value.trim();
41
+ return trimmed.length ? trimmed : undefined;
42
+ }
43
+ function readNodeHeader(headers, name) {
44
+ if (!headers) {
45
+ return undefined;
46
+ }
47
+ const lower = name.toLowerCase();
48
+ let value = headers[lower];
49
+ if (value === undefined) {
50
+ for (const key of Object.keys(headers)) {
51
+ if (key.toLowerCase() === lower) {
52
+ value = headers[key];
53
+ break;
54
+ }
55
+ }
56
+ }
57
+ if (Array.isArray(value)) {
58
+ value = value[0];
59
+ }
60
+ if (typeof value !== 'string') {
61
+ return undefined;
62
+ }
63
+ const trimmed = value.trim();
64
+ return trimmed.length ? trimmed : undefined;
65
+ }
66
+ // Shared id precedence. Kept in one place (rather than once per request shape)
67
+ // so the header-name contract documented above is only spelled out once.
68
+ function seedIds(read) {
69
+ var _a, _b, _c, _d;
70
+ const requestId = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : generateId();
71
+ const correlationId = (_d = (_c = read('x-correlation-id')) !== null && _c !== void 0 ? _c : read('x-amzn-trace-id')) !== null && _d !== void 0 ? _d : requestId;
72
+ return { request_id: requestId, correlation_id: correlationId };
73
+ }
74
+ // App Router / middleware: headers are a web `Headers` instance.
75
+ function seedRequestEventContext(headers) {
76
+ return seedIds((name) => readHeader(headers, name));
77
+ }
78
+ // Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).
79
+ function seedNodeRequestEventContext(headers) {
80
+ return seedIds((name) => readNodeHeader(headers, name));
81
+ }
82
+ function now() {
83
+ return typeof performance !== 'undefined' ? performance.now() : Date.now();
84
+ }
85
+ // Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and
86
+ // the per-source flag must both be on.
87
+ function insightsHttpEnabled() {
88
+ const insights = Honeybadger.config.insights;
89
+ return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;
90
+ }
91
+ // The ids are embedded directly in the payload (instead of relying on the
92
+ // store's eventContext merge) so the event carries them even on the edge
93
+ // runtime, where there is no per-request store isolation. On the Node.js
94
+ // runtime they match the seeded event context, so embedding is a no-op.
95
+ function emitHandledEvent(method, path, status, start, ids) {
96
+ const payload = {
97
+ method,
98
+ duration: Math.round(now() - start),
99
+ ...ids,
100
+ };
101
+ if (typeof path === 'string') {
102
+ payload.path = path;
103
+ }
104
+ if (typeof status === 'number') {
105
+ payload.status = status;
106
+ }
107
+ Honeybadger.event('request.handled', payload);
108
+ }
109
+ // App Router / middleware: `req.url` is absolute, so parse out the pathname.
110
+ function emitRequestEvent(req, status, start, ids) {
111
+ let path;
112
+ try {
113
+ path = new URL(req.url).pathname;
114
+ }
115
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
116
+ catch (error) {
117
+ // relative or malformed URL — leave path unset
118
+ }
119
+ emitHandledEvent(req.method, path, status, start, ids);
120
+ }
121
+ // Pages Router: `req.url` is a relative path that may carry a query string.
122
+ function emitNodeRequestEvent(req, status, start, ids) {
123
+ const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;
124
+ emitHandledEvent(req.method, path, status, start, ids);
125
+ }
126
+
127
+ function configure(overrides) {
128
+ var _a;
129
+ if (((_a = Honeybadger.config.apiKey) === null || _a === void 0 ? void 0 : _a.length) > 0) {
130
+ return;
131
+ }
132
+ let projectRoot = undefined;
133
+ try {
134
+ // not available on edge runtime
135
+ projectRoot = process.cwd();
136
+ }
137
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
138
+ catch (error) {
139
+ // do nothing
140
+ }
141
+ Honeybadger
142
+ .configure({
143
+ apiKey: process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY,
144
+ environment: process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.VERCEL_ENV || process.env.NODE_ENV,
145
+ revision: process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,
146
+ projectRoot: 'webpack://_N_E/./',
147
+ ...overrides,
148
+ })
149
+ .beforeNotify((notice) => {
150
+ if (!projectRoot) {
151
+ return;
152
+ }
153
+ notice === null || notice === void 0 ? void 0 : notice.backtrace.forEach((line) => {
154
+ if (line.file) {
155
+ line.file = line.file.replace(`${projectRoot}/.next/server`, `${process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL}/..`);
156
+ }
157
+ return line;
158
+ });
159
+ });
160
+ }
161
+ /**
162
+ * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,
163
+ * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`
164
+ * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).
165
+ * These are not real failures — the framework catches them upstream to produce
166
+ * the redirect/404/etc. — so we must let them propagate without reporting them,
167
+ * otherwise every redirect shows up as an error in Honeybadger.
168
+ *
169
+ * We match on the `NEXT_` prefix rather than an exhaustive list so that any
170
+ * present or future framework control-flow digest is covered. This is safe:
171
+ * genuine errors that React tags with a `digest` use an opaque hash, and other
172
+ * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,
173
+ * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.
174
+ */
175
+ function isNextControlFlowError(error) {
176
+ const digest = error === null || error === void 0 ? void 0 : error.digest;
177
+ return typeof digest === 'string' && digest.startsWith('NEXT_');
178
+ }
179
+ /**
180
+ * Detects a Pages Router API invocation: `(req, res)` where `res` is a Node
181
+ * `ServerResponse`. We branch on this structurally because — unlike an App
182
+ * Router route handler — there is no returned `Response` to read the status
183
+ * from; it lives on `res.statusCode`.
184
+ */
185
+ function isPagesApiInvocation(args) {
186
+ const req = args[0];
187
+ const res = args[1];
188
+ return (!!req && typeof req.headers === 'object' && req.headers !== null &&
189
+ !!res && typeof res.statusCode === 'number' && typeof res.end === 'function');
190
+ }
191
+ /**
192
+ * App Router route handlers and middleware: a web `Request`/`NextRequest` in, a
193
+ * `Response`/`NextResponse` out. The status comes from the returned response.
194
+ */
195
+ async function handleAppRouterRequest(call, req, canIsolate) {
196
+ const ids = seedRequestEventContext(req.headers);
197
+ if (canIsolate) {
198
+ Honeybadger.setEventContext(ids);
199
+ }
200
+ const start = insightsHttpEnabled() ? now() : null;
201
+ try {
202
+ const response = await call();
203
+ if (start !== null) {
204
+ emitRequestEvent(req, response === null || response === void 0 ? void 0 : response.status, start, ids);
205
+ }
206
+ return response;
207
+ }
208
+ catch (error) {
209
+ if (isNextControlFlowError(error)) {
210
+ throw error;
211
+ }
212
+ if (start !== null) {
213
+ emitRequestEvent(req, 500, start, ids);
214
+ }
215
+ await Honeybadger.notifyAsync(error);
216
+ throw error;
217
+ }
218
+ }
219
+ /**
220
+ * Pages Router API routes: a Node `req`/`res` pair. The handler writes to `res`
221
+ * and returns nothing meaningful, so the final status is read from
222
+ * `res.statusCode` once it resolves.
223
+ */
224
+ async function handlePagesApiRequest(call, req, res, canIsolate) {
225
+ const ids = seedNodeRequestEventContext(req.headers);
226
+ if (canIsolate) {
227
+ Honeybadger.setEventContext(ids);
228
+ }
229
+ const start = insightsHttpEnabled() ? now() : null;
230
+ try {
231
+ const result = await call();
232
+ if (start !== null) {
233
+ emitNodeRequestEvent(req, res.statusCode, start, ids);
234
+ }
235
+ return result;
236
+ }
237
+ catch (error) {
238
+ if (isNextControlFlowError(error)) {
239
+ throw error;
240
+ }
241
+ if (start !== null) {
242
+ emitNodeRequestEvent(req, 500, start, ids);
243
+ }
244
+ await Honeybadger.notifyAsync(error);
245
+ throw error;
246
+ }
247
+ }
248
+ /**
249
+ * Unrecognised invocation shape: still report errors, but emit no insights
250
+ * event since we can't reliably read the request.
251
+ */
252
+ async function handleUninstrumented(call) {
253
+ try {
254
+ return await call();
255
+ }
256
+ catch (error) {
257
+ if (isNextControlFlowError(error)) {
258
+ throw error;
259
+ }
260
+ await Honeybadger.notifyAsync(error);
261
+ throw error;
262
+ }
263
+ }
264
+ function withHoneybadger(handler, config) {
265
+ configure(config);
266
+ return new Proxy(handler, {
267
+ apply: (target, thisArg, args) => {
268
+ const canIsolate = typeof Honeybadger.run === 'function';
269
+ const call = () => Reflect.apply(target, thisArg, args);
270
+ const invoke = () => {
271
+ // App Router / middleware first: a web Request as the first argument.
272
+ if (typeof Request !== 'undefined' && args[0] instanceof Request) {
273
+ return handleAppRouterRequest(call, args[0], canIsolate);
274
+ }
275
+ // Pages Router API route: a Node req/res pair.
276
+ if (isPagesApiInvocation(args)) {
277
+ return handlePagesApiRequest(call, args[0], args[1], canIsolate);
278
+ }
279
+ return handleUninstrumented(call);
280
+ };
281
+ return canIsolate ? Honeybadger.run(invoke) : invoke();
282
+ },
283
+ });
284
+ }
285
+
286
+ export { withHoneybadger };
287
+ //# sourceMappingURL=honeybadger-nextjs-edge.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"honeybadger-nextjs-edge.esm.js","sources":["../../build/insights-instrumentation.js","../../build/with-honeybadger.js"],"sourcesContent":["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 { emitNodeRequestEvent, emitRequestEvent, insightsHttpEnabled, now, seedNodeRequestEventContext, seedRequestEventContext, } from './insights-instrumentation';\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 */\nasync function handleAppRouterRequest(call, req, canIsolate) {\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 }\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 }\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 }\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 }\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);\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) : invoke();\n },\n });\n}\n//# sourceMappingURL=with-honeybadger.js.map"],"names":[],"mappings":";;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,GAAG;AACtB,IAAI,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC;AACxC,IAAI,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,EAAE;AACjE,QAAQ,IAAI;AACZ,YAAY,OAAO,SAAS,CAAC,UAAU,EAAE,CAAC;AAC1C,SAAS;AACT;AACA,QAAQ,OAAO,KAAK,EAAE;AACtB;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA,IAAI,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK;AAC3E,QAAQ,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AAC3C,QAAQ,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC;AACnD,QAAQ,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC9B,KAAK,CAAC,CAAC;AACP,CAAC;AACD,SAAS,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE;AACnC,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACpC,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACnC,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;AACjC,IAAI,OAAO,OAAO,CAAC,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAChD,CAAC;AACD,SAAS,cAAc,CAAC,OAAO,EAAE,IAAI,E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AAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACpE,YAAY,MAAM,MAAM,GAAG,MAAM;AACjC;AACA,gBAAgB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,OAAO,EAAE;AAClF,oBAAoB,OAAO,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAC7E,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
@@ -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.9",
3
+ "version": "5.10.11",
4
4
  "description": "Next.js integration for Honeybadger",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -42,8 +42,8 @@
42
42
  "next": ">= 13.x"
43
43
  },
44
44
  "dependencies": {
45
- "@honeybadger-io/js": "^6.14.0",
46
- "@honeybadger-io/webpack": "^6.3.1"
45
+ "@honeybadger-io/js": "^6.15.0",
46
+ "@honeybadger-io/webpack": "^6.3.2"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@honeybadger-io/react": "^6.1.27",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "45ebb2cd68689d0b53548ae623f8ea72922ccbe9"
66
+ "gitHead": "e14abbd07685a389b93f772ed26f1242ab21e9de"
67
67
  }