@logbrew/next 0.1.8 → 0.1.9

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/README.md CHANGED
@@ -128,13 +128,17 @@ it returns. A delivery or callback failure is reported through
128
128
  already handling. The Edge runtime is left unchanged; use a Node.js route or
129
129
  server boundary for LogBrew server delivery.
130
130
 
131
- By default, the issue includes the error message, Next.js error digest, method,
132
- stable route file path, router kind, route type, render source, revalidation
133
- reason, and render type when Next.js supplies them. It does not capture request
134
- headers, authorization values, cookies, request bodies, query strings, URL
135
- fragments, concrete dynamic path values, or raw stack text. Set
136
- `includePathname: true` only when a query-free concrete pathname is intentional
137
- and acceptable for that application.
131
+ By default, the issue includes the error message, exception type, structured
132
+ stack frames, Next.js error digest, method, stable route file path, router kind,
133
+ route type, render source, revalidation reason, and render type when Next.js
134
+ supplies them. The exception mechanism is `nextjs.on_request_error`, or
135
+ `nextjs.route_handler` for errors thrown inside `withLogBrewRouteHandler`.
136
+ Frames keep only the file basename, line, column, and function name. The issue
137
+ does not capture request headers, authorization values, cookies, request
138
+ bodies, query strings, URL fragments, concrete dynamic path values, or raw
139
+ stack text. Set `includePathname: true` only when a query-free concrete
140
+ pathname is intentional and acceptable for that application, and
141
+ `includeErrorStack: true` only when raw stack text is acceptable.
138
142
 
139
143
  If the same Route Handler also uses `withLogBrewRouteHandler`, set
140
144
  `captureErrors: false` on that wrapper so the global request-error hook is the
@@ -232,7 +236,7 @@ import {
232
236
  const client = createLogBrewNextBrowserClient({
233
237
  clientKey: "LOGBREW_CLIENT_KEY",
234
238
  sdkName: "my-next-app",
235
- sdkVersion: "0.1.8"
239
+ sdkVersion: "0.1.9"
236
240
  });
237
241
 
238
242
  const routePatterns = [
@@ -269,7 +273,7 @@ import { createLogBrewNextClient } from "@logbrew/next";
269
273
  const client = createLogBrewNextClient({
270
274
  serverApiKey: "LOGBREW_SERVER_API_KEY",
271
275
  sdkName: "my-next-app",
272
- sdkVersion: "0.1.8"
276
+ sdkVersion: "0.1.9"
273
277
  });
274
278
  ```
275
279
 
package/client.cjs CHANGED
@@ -13,7 +13,7 @@ function createLogBrewNextBrowserClient({
13
13
  context,
14
14
  eventFilter,
15
15
  sdkName = "logbrew-next-client",
16
- sdkVersion = "0.1.8",
16
+ sdkVersion = "0.1.9",
17
17
  maxQueueSize,
18
18
  maxRetries = 2,
19
19
  onEventDropped
package/client.js CHANGED
@@ -13,7 +13,7 @@ export function createLogBrewNextBrowserClient({
13
13
  context,
14
14
  eventFilter,
15
15
  sdkName = "logbrew-next-client",
16
- sdkVersion = "0.1.8",
16
+ sdkVersion = "0.1.9",
17
17
  maxQueueSize,
18
18
  maxRetries = 2,
19
19
  onEventDropped
@@ -24,7 +24,7 @@ const event = captureNextNavigation(client, {
24
24
  });
25
25
 
26
26
  const payload = JSON.parse(client.previewJson());
27
- if (!event || event.attributes.metadata.routeTemplate !== "/projects/[projectId]/settings" || event.attributes.metadata.operation !== "browser.navigation" || payload.sdk.version !== "0.1.8") {
27
+ if (!event || event.attributes.metadata.routeTemplate !== "/projects/[projectId]/settings" || event.attributes.metadata.operation !== "browser.navigation" || payload.sdk.version !== "0.1.9") {
28
28
  throw new Error(`unexpected Next client route span: ${JSON.stringify(event)}`);
29
29
  }
30
30
 
@@ -12,7 +12,7 @@ const POST = withLogBrewRouteHandler(
12
12
  serverApiKey: "LOGBREW_SERVER_API_KEY",
13
13
  captureRequests: false,
14
14
  sdkName: "logbrew-next-readme-example",
15
- sdkVersion: "0.1.8",
15
+ sdkVersion: "0.1.9",
16
16
  transport
17
17
  }
18
18
  );
@@ -12,7 +12,7 @@ const POST = withLogBrewRouteHandler(
12
12
  serverApiKey: "LOGBREW_SERVER_API_KEY",
13
13
  captureRequests: false,
14
14
  sdkName: "logbrew-next-real-user-smoke",
15
- sdkVersion: "0.1.8",
15
+ sdkVersion: "0.1.9",
16
16
  maxRetries: 1,
17
17
  transport
18
18
  }
package/index.cjs CHANGED
@@ -2,6 +2,7 @@ const { AsyncLocalStorage } = require("node:async_hooks");
2
2
  const {
3
3
  LogBrewClient,
4
4
  SdkError,
5
+ createIssueAttributesFromError,
5
6
  parseTraceparent
6
7
  } = require("@logbrew/sdk");
7
8
  const { createNodeFetchTransport } = require("@logbrew/node");
@@ -24,7 +25,7 @@ function createLogBrewNextClient({
24
25
  serverApiKey,
25
26
  context,
26
27
  sdkName = "logbrew-next",
27
- sdkVersion = "0.1.8",
28
+ sdkVersion = "0.1.9",
28
29
  maxRetries = 2
29
30
  } = {}) {
30
31
  const authKey = serverApiKey ?? apiKey ?? readEnvServerApiKey() ?? readEnvApiKey();
@@ -72,6 +73,7 @@ function createLogBrewNextRequestErrorHandler(options = {}) {
72
73
  }
73
74
 
74
75
  function createNextRequestErrorEvent(error, request = {}, context = {}, {
76
+ includeErrorStack = false,
75
77
  includePathname = false,
76
78
  now = () => new Date().toISOString(),
77
79
  idFactory = defaultNextRequestErrorId
@@ -83,10 +85,13 @@ function createNextRequestErrorEvent(error, request = {}, context = {}, {
83
85
  return {
84
86
  id: idFactory(error, request, context),
85
87
  timestamp: now(),
86
- attributes: {
88
+ attributes: createIssueAttributesFromError(error, {
87
89
  title: `${method} ${routePath} failed`,
88
- level: "error",
89
90
  message: nextErrorMessage(error),
91
+ mechanism: "nextjs.on_request_error",
92
+ handled: false,
93
+ source: "nextjs.on_request_error",
94
+ includeErrorStack,
90
95
  metadata: {
91
96
  framework: "nextjs",
92
97
  method,
@@ -100,7 +105,7 @@ function createNextRequestErrorEvent(error, request = {}, context = {}, {
100
105
  ...(errorDigest ? { errorDigest } : {}),
101
106
  ...(pathname ? { pathname } : {})
102
107
  }
103
- }
108
+ })
104
109
  };
105
110
  }
106
111
 
@@ -184,6 +189,7 @@ function createRouteRequestEvent(request, response, {
184
189
  }
185
190
 
186
191
  function createRouteErrorEvent(error, request, {
192
+ includeErrorStack = false,
187
193
  includeSearchParams = false,
188
194
  now = () => new Date().toISOString(),
189
195
  idFactory = defaultRouteErrorId,
@@ -193,15 +199,16 @@ function createRouteErrorEvent(error, request, {
193
199
  const url = safeUrl(request);
194
200
  const routePath = routeTemplateOnly(routeTemplate);
195
201
  const method = request?.method ?? "GET";
196
- const message = error instanceof Error ? error.message : String(error);
197
202
  const routeTrace = trace ?? getActiveLogBrewTrace();
198
203
  return {
199
204
  id: idFactory(request, routePath),
200
205
  timestamp: now(),
201
- attributes: {
206
+ attributes: createIssueAttributesFromError(error, {
202
207
  title: `${method} ${routePath} failed`,
203
- level: "error",
204
- message,
208
+ mechanism: "nextjs.route_handler",
209
+ handled: false,
210
+ source: "nextjs.route_handler",
211
+ includeErrorStack,
205
212
  metadata: {
206
213
  framework: "nextjs",
207
214
  method,
@@ -210,7 +217,7 @@ function createRouteErrorEvent(error, request, {
210
217
  ...(includeSearchParams ? { search: url.search || null } : {}),
211
218
  ...traceMetadata(routeTrace)
212
219
  }
213
- }
220
+ })
214
221
  };
215
222
  }
216
223
 
package/index.d.cts CHANGED
@@ -75,6 +75,7 @@ export type LogBrewNextRequestErrorOptions = CreateLogBrewNextClientConfig & Nod
75
75
  transport?: Transport | ((context: LogBrewNextRequestErrorInput & { client: LogBrewClient }) => Transport);
76
76
  /** Opt into a query-free concrete pathname. Stable routePath metadata remains the default. */
77
77
  includePathname?: boolean;
78
+ /** Include raw stack text in issue metadata. Structured frames are always captured. Defaults to false. */
78
79
  now?: () => string;
79
80
  idFactory?: (
80
81
  error: LogBrewNextRequestError,
@@ -177,6 +178,8 @@ export type LogBrewRouteOptions<TContext = LogBrewRouteContext> = CreateLogBrewN
177
178
  captureRequests?: boolean;
178
179
  captureRequestMetrics?: boolean;
179
180
  captureErrors?: boolean;
181
+ /** Include raw stack text in issue metadata. Structured frames are always captured. Defaults to false. */
182
+ includeErrorStack?: boolean;
180
183
  includeSearchParams?: boolean;
181
184
  metricName?: string;
182
185
  /** Supply a stable route template. Missing or invalid templates use "/" without reading the request pathname. */
@@ -224,6 +227,7 @@ export declare function createNextRequestErrorEvent(
224
227
  request: LogBrewNextRequestErrorRequest,
225
228
  context: LogBrewNextRequestErrorContext,
226
229
  options?: {
230
+ includeErrorStack?: boolean;
227
231
  includePathname?: boolean;
228
232
  now?: () => string;
229
233
  idFactory?: (
@@ -270,6 +274,7 @@ export declare function createRouteErrorEvent(
270
274
  error: unknown,
271
275
  request: Request,
272
276
  options?: {
277
+ includeErrorStack?: boolean;
273
278
  includeSearchParams?: boolean;
274
279
  now?: () => string;
275
280
  idFactory?: (request: Request, routeTemplate?: string) => string;
package/index.d.ts CHANGED
@@ -75,6 +75,7 @@ export type LogBrewNextRequestErrorOptions = CreateLogBrewNextClientConfig & Nod
75
75
  transport?: Transport | ((context: LogBrewNextRequestErrorInput & { client: LogBrewClient }) => Transport);
76
76
  /** Opt into a query-free concrete pathname. Stable routePath metadata remains the default. */
77
77
  includePathname?: boolean;
78
+ /** Include raw stack text in issue metadata. Structured frames are always captured. Defaults to false. */
78
79
  now?: () => string;
79
80
  idFactory?: (
80
81
  error: LogBrewNextRequestError,
@@ -177,6 +178,8 @@ export type LogBrewRouteOptions<TContext = LogBrewRouteContext> = CreateLogBrewN
177
178
  captureRequests?: boolean;
178
179
  captureRequestMetrics?: boolean;
179
180
  captureErrors?: boolean;
181
+ /** Include raw stack text in issue metadata. Structured frames are always captured. Defaults to false. */
182
+ includeErrorStack?: boolean;
180
183
  includeSearchParams?: boolean;
181
184
  metricName?: string;
182
185
  /** Supply a stable route template. Missing or invalid templates use "/" without reading the request pathname. */
@@ -224,6 +227,7 @@ export declare function createNextRequestErrorEvent(
224
227
  request: LogBrewNextRequestErrorRequest,
225
228
  context: LogBrewNextRequestErrorContext,
226
229
  options?: {
230
+ includeErrorStack?: boolean;
227
231
  includePathname?: boolean;
228
232
  now?: () => string;
229
233
  idFactory?: (
@@ -270,6 +274,7 @@ export declare function createRouteErrorEvent(
270
274
  error: unknown,
271
275
  request: Request,
272
276
  options?: {
277
+ includeErrorStack?: boolean;
273
278
  includeSearchParams?: boolean;
274
279
  now?: () => string;
275
280
  idFactory?: (request: Request, routeTemplate?: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logbrew/next",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Next.js App Router helpers for the public LogBrew JavaScript SDK.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",