@logbrew/next 0.1.14 → 0.1.16
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 +5 -5
- package/client.cjs +10 -17
- package/client.d.cts +1 -1
- package/client.d.ts +1 -1
- package/client.js +10 -17
- package/edge.cjs +1 -1
- package/examples/client-route-spans.mjs +1 -1
- package/examples/readme-example.mjs +1 -1
- package/examples/real-user-smoke.mjs +1 -1
- package/index.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -270,7 +270,7 @@ import {
|
|
|
270
270
|
const client = createLogBrewNextBrowserClient({
|
|
271
271
|
clientKey: "LOGBREW_CLIENT_KEY",
|
|
272
272
|
sdkName: "my-next-app",
|
|
273
|
-
sdkVersion: "0.1.
|
|
273
|
+
sdkVersion: "0.1.16"
|
|
274
274
|
});
|
|
275
275
|
|
|
276
276
|
const routePatterns = [
|
|
@@ -295,14 +295,14 @@ export function LogBrewNextNavigationSpans({ traceparent }) {
|
|
|
295
295
|
|
|
296
296
|
`useLogBrewNextNavigation` records one `browser.navigation` span named `next.route <routeTemplate>` when `pathname` changes to a route that matches one of your stable `routePatterns`. Use `createNextRouteTemplate` directly when you want to preview how a concrete `pathname` maps to `/projects/[projectId]/settings`, `[...catchAll]`, `[[...optionalCatchAll]]`, or a route-group pattern such as `/(app)/dashboard/[teamId]`.
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
Pass W3C trace context through `traceparent`, `traceId`, or `traceId` plus `spanId`. A missing span ID comes from `spanIdFactory`, and a navigation without trace input starts a new trace. The hook never throws into your page: when a capture fails, for example on a malformed `traceparent`, it drops that span and calls `onCaptureError` if you pass one. It does not patch `fetch`, `XMLHttpRequest`, browser history, or the Next router. It never records the concrete pathname, query string, hash, headers, cookies, request body, or raw `traceparent` value. If a pathname cannot be matched to a stable route template, it skips the span instead of emitting a high-cardinality URL. Metadata is primitive-only.
|
|
299
299
|
|
|
300
300
|
Use `captureNextNavigation(client, input)` when you want to emit a route span from app-owned navigation callbacks instead of the React hook.
|
|
301
301
|
|
|
302
302
|
## Client Errors
|
|
303
303
|
|
|
304
|
-
`createLogBrewNextBrowserClient()` sends events on its own with `fetch` (
|
|
305
|
-
|
|
304
|
+
`createLogBrewNextBrowserClient()` sends events on its own with `fetch` (1
|
|
305
|
+
second after the first queued event). Pass a `transport` to
|
|
306
306
|
replace it, or `transport: null` to keep the client manual. Browser events
|
|
307
307
|
carry the release and environment from `NEXT_PUBLIC_LOGBREW_RELEASE` and
|
|
308
308
|
`NEXT_PUBLIC_LOGBREW_ENVIRONMENT`, or from `NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA`
|
|
@@ -347,7 +347,7 @@ import { createLogBrewNextClient } from "@logbrew/next";
|
|
|
347
347
|
const client = createLogBrewNextClient({
|
|
348
348
|
serverApiKey: "LOGBREW_SERVER_API_KEY",
|
|
349
349
|
sdkName: "my-next-app",
|
|
350
|
-
sdkVersion: "0.1.
|
|
350
|
+
sdkVersion: "0.1.16"
|
|
351
351
|
});
|
|
352
352
|
```
|
|
353
353
|
|
package/client.cjs
CHANGED
|
@@ -10,8 +10,8 @@ const {
|
|
|
10
10
|
} = require("@logbrew/sdk");
|
|
11
11
|
|
|
12
12
|
const DEFAULT_ENDPOINT = "https://api.logbrew.co/v1/events";
|
|
13
|
-
//
|
|
14
|
-
const DEFAULT_BROWSER_DELIVERY_INTERVAL_MS =
|
|
13
|
+
// Send 1 second after the first queued event; pagehide flushes the rest when the page closes.
|
|
14
|
+
const DEFAULT_BROWSER_DELIVERY_INTERVAL_MS = 1000;
|
|
15
15
|
const clientEndpoints = new WeakMap();
|
|
16
16
|
|
|
17
17
|
function createLogBrewNextBrowserClient({
|
|
@@ -22,7 +22,7 @@ function createLogBrewNextBrowserClient({
|
|
|
22
22
|
endpoint = DEFAULT_ENDPOINT,
|
|
23
23
|
eventFilter,
|
|
24
24
|
sdkName = "logbrew-next-client",
|
|
25
|
-
sdkVersion = "0.1.
|
|
25
|
+
sdkVersion = "0.1.16",
|
|
26
26
|
maxQueueSize,
|
|
27
27
|
maxRetries = 2,
|
|
28
28
|
onEventDropped,
|
|
@@ -274,11 +274,10 @@ function useLogBrewNextNavigation(options = {}) {
|
|
|
274
274
|
options.onNavigation(event);
|
|
275
275
|
}
|
|
276
276
|
} catch (error) {
|
|
277
|
+
// Telemetry never breaks the page: report the failure to the app if it asked, then drop the event.
|
|
277
278
|
if (typeof options.onCaptureError === "function") {
|
|
278
279
|
options.onCaptureError(error);
|
|
279
|
-
return;
|
|
280
280
|
}
|
|
281
|
-
throw error;
|
|
282
281
|
}
|
|
283
282
|
});
|
|
284
283
|
}
|
|
@@ -297,18 +296,12 @@ function compactMetadata(metadata) {
|
|
|
297
296
|
}
|
|
298
297
|
|
|
299
298
|
function traceContextFromInput({ parentSpanId, spanId, spanIdFactory, traceId, traceparent }) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
if (!traceId || !spanId) {
|
|
309
|
-
throw new SdkError("configuration_error", "Next.js navigation requires traceparent or traceId and spanId");
|
|
310
|
-
}
|
|
311
|
-
return { parentSpanId, spanId, traceId };
|
|
299
|
+
const parsed = typeof traceparent === "string" ? parseTraceparent(traceparent) : undefined;
|
|
300
|
+
return {
|
|
301
|
+
parentSpanId: parentSpanId ?? parsed?.parentSpanId,
|
|
302
|
+
spanId: spanId ?? spanIdFactory(),
|
|
303
|
+
traceId: traceId ?? parsed?.traceId ?? randomHex(16)
|
|
304
|
+
};
|
|
312
305
|
}
|
|
313
306
|
|
|
314
307
|
function normalizeRouteTemplate(value) {
|
package/client.d.cts
CHANGED
|
@@ -19,7 +19,7 @@ export type CreateLogBrewNextBrowserClientConfig = {
|
|
|
19
19
|
eventFilter?: EventFilter;
|
|
20
20
|
maxQueueSize?: number;
|
|
21
21
|
onEventDropped?: (drop: DroppedEvent) => void;
|
|
22
|
-
/** Delivery interval after the first queued event. Defaults to
|
|
22
|
+
/** Delivery interval after the first queued event. Defaults to 1000 ms. */
|
|
23
23
|
deliveryIntervalMs?: number;
|
|
24
24
|
/** Ingest endpoint for the built-in fetch transport. */
|
|
25
25
|
endpoint?: string;
|
package/client.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type CreateLogBrewNextBrowserClientConfig = {
|
|
|
19
19
|
eventFilter?: EventFilter;
|
|
20
20
|
maxQueueSize?: number;
|
|
21
21
|
onEventDropped?: (drop: DroppedEvent) => void;
|
|
22
|
-
/** Delivery interval after the first queued event. Defaults to
|
|
22
|
+
/** Delivery interval after the first queued event. Defaults to 1000 ms. */
|
|
23
23
|
deliveryIntervalMs?: number;
|
|
24
24
|
/** Ingest endpoint for the built-in fetch transport. */
|
|
25
25
|
endpoint?: string;
|
package/client.js
CHANGED
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
} from "@logbrew/sdk";
|
|
11
11
|
|
|
12
12
|
const DEFAULT_ENDPOINT = "https://api.logbrew.co/v1/events";
|
|
13
|
-
//
|
|
14
|
-
const DEFAULT_BROWSER_DELIVERY_INTERVAL_MS =
|
|
13
|
+
// Send 1 second after the first queued event; pagehide flushes the rest when the page closes.
|
|
14
|
+
const DEFAULT_BROWSER_DELIVERY_INTERVAL_MS = 1000;
|
|
15
15
|
const clientEndpoints = new WeakMap();
|
|
16
16
|
|
|
17
17
|
export function createLogBrewNextBrowserClient({
|
|
@@ -22,7 +22,7 @@ export function createLogBrewNextBrowserClient({
|
|
|
22
22
|
endpoint = DEFAULT_ENDPOINT,
|
|
23
23
|
eventFilter,
|
|
24
24
|
sdkName = "logbrew-next-client",
|
|
25
|
-
sdkVersion = "0.1.
|
|
25
|
+
sdkVersion = "0.1.16",
|
|
26
26
|
maxQueueSize,
|
|
27
27
|
maxRetries = 2,
|
|
28
28
|
onEventDropped,
|
|
@@ -274,11 +274,10 @@ export function useLogBrewNextNavigation(options = {}) {
|
|
|
274
274
|
options.onNavigation(event);
|
|
275
275
|
}
|
|
276
276
|
} catch (error) {
|
|
277
|
+
// Telemetry never breaks the page: report the failure to the app if it asked, then drop the event.
|
|
277
278
|
if (typeof options.onCaptureError === "function") {
|
|
278
279
|
options.onCaptureError(error);
|
|
279
|
-
return;
|
|
280
280
|
}
|
|
281
|
-
throw error;
|
|
282
281
|
}
|
|
283
282
|
});
|
|
284
283
|
}
|
|
@@ -297,18 +296,12 @@ function compactMetadata(metadata) {
|
|
|
297
296
|
}
|
|
298
297
|
|
|
299
298
|
function traceContextFromInput({ parentSpanId, spanId, spanIdFactory, traceId, traceparent }) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
if (!traceId || !spanId) {
|
|
309
|
-
throw new SdkError("configuration_error", "Next.js navigation requires traceparent or traceId and spanId");
|
|
310
|
-
}
|
|
311
|
-
return { parentSpanId, spanId, traceId };
|
|
299
|
+
const parsed = typeof traceparent === "string" ? parseTraceparent(traceparent) : undefined;
|
|
300
|
+
return {
|
|
301
|
+
parentSpanId: parentSpanId ?? parsed?.parentSpanId,
|
|
302
|
+
spanId: spanId ?? spanIdFactory(),
|
|
303
|
+
traceId: traceId ?? parsed?.traceId ?? randomHex(16)
|
|
304
|
+
};
|
|
312
305
|
}
|
|
313
306
|
|
|
314
307
|
function normalizeRouteTemplate(value) {
|
package/edge.cjs
CHANGED
|
@@ -25,7 +25,7 @@ function createLogBrewNextEdgeRequestErrorHandler(options = {}) {
|
|
|
25
25
|
apiKey: authKey,
|
|
26
26
|
context: deploymentContext,
|
|
27
27
|
sdkName: options.sdkName ?? "logbrew-next",
|
|
28
|
-
sdkVersion: options.sdkVersion ?? "0.1.
|
|
28
|
+
sdkVersion: options.sdkVersion ?? "0.1.16",
|
|
29
29
|
maxRetries: options.maxRetries ?? 2
|
|
30
30
|
});
|
|
31
31
|
const event = typeof options.errorEvent === "function"
|
|
@@ -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.
|
|
27
|
+
if (!event || event.attributes.metadata.routeTemplate !== "/projects/[projectId]/settings" || event.attributes.metadata.operation !== "browser.navigation" || payload.sdk.version !== "0.1.16") {
|
|
28
28
|
throw new Error(`unexpected Next client route span: ${JSON.stringify(event)}`);
|
|
29
29
|
}
|
|
30
30
|
|
package/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ function createLogBrewNextClient({
|
|
|
23
23
|
serverApiKey,
|
|
24
24
|
context,
|
|
25
25
|
sdkName = "logbrew-next",
|
|
26
|
-
sdkVersion = "0.1.
|
|
26
|
+
sdkVersion = "0.1.16",
|
|
27
27
|
maxRetries = 2
|
|
28
28
|
} = {}) {
|
|
29
29
|
const authKey = serverApiKey ?? apiKey ?? readEnvServerApiKey() ?? readEnvApiKey();
|