@logbrew/next 0.1.10 → 0.1.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/README.md +7 -3
- package/client.cjs +12 -3
- package/client.d.cts +2 -0
- package/client.d.ts +2 -0
- package/client.js +12 -3
- 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 +2 -2
package/README.md
CHANGED
|
@@ -245,7 +245,7 @@ import {
|
|
|
245
245
|
const client = createLogBrewNextBrowserClient({
|
|
246
246
|
clientKey: "LOGBREW_CLIENT_KEY",
|
|
247
247
|
sdkName: "my-next-app",
|
|
248
|
-
sdkVersion: "0.1.
|
|
248
|
+
sdkVersion: "0.1.11"
|
|
249
249
|
});
|
|
250
250
|
|
|
251
251
|
const routePatterns = [
|
|
@@ -308,7 +308,11 @@ never a concrete path.
|
|
|
308
308
|
Call `installLogBrewNextClientErrorCapture({ client })` once in a client
|
|
309
309
|
component to also report uncaught browser errors (`nextjs.window_error`) and
|
|
310
310
|
unhandled rejections (`nextjs.unhandled_rejection`), and to flush queued events
|
|
311
|
-
when the page is hidden.
|
|
311
|
+
when the page is hidden. Each issue carries the last 64 breadcrumbs: console
|
|
312
|
+
calls (message template only), fetch and XHR requests (method, URL without
|
|
313
|
+
query, status), and route changes. Requests to the LogBrew endpoint are
|
|
314
|
+
skipped. Pass `breadcrumbs: false` to turn them off. `uninstall()` removes the
|
|
315
|
+
listeners and puts back every patched method.
|
|
312
316
|
|
|
313
317
|
## Server Client Helper
|
|
314
318
|
|
|
@@ -318,7 +322,7 @@ import { createLogBrewNextClient } from "@logbrew/next";
|
|
|
318
322
|
const client = createLogBrewNextClient({
|
|
319
323
|
serverApiKey: "LOGBREW_SERVER_API_KEY",
|
|
320
324
|
sdkName: "my-next-app",
|
|
321
|
-
sdkVersion: "0.1.
|
|
325
|
+
sdkVersion: "0.1.11"
|
|
322
326
|
});
|
|
323
327
|
```
|
|
324
328
|
|
package/client.cjs
CHANGED
|
@@ -5,12 +5,14 @@ const {
|
|
|
5
5
|
LogBrewClient,
|
|
6
6
|
SdkError,
|
|
7
7
|
createIssueAttributesFromError,
|
|
8
|
+
installBrowserBreadcrumbs,
|
|
8
9
|
parseTraceparent
|
|
9
10
|
} = require("@logbrew/sdk");
|
|
10
11
|
|
|
11
12
|
const DEFAULT_ENDPOINT = "https://api.logbrew.co/v1/events";
|
|
12
13
|
// Browsers keep a 5-second interval to save battery and radio; pagehide flushes the rest.
|
|
13
14
|
const DEFAULT_BROWSER_DELIVERY_INTERVAL_MS = 5000;
|
|
15
|
+
const clientEndpoints = new WeakMap();
|
|
14
16
|
|
|
15
17
|
function createLogBrewNextBrowserClient({
|
|
16
18
|
apiKey,
|
|
@@ -20,7 +22,7 @@ function createLogBrewNextBrowserClient({
|
|
|
20
22
|
endpoint = DEFAULT_ENDPOINT,
|
|
21
23
|
eventFilter,
|
|
22
24
|
sdkName = "logbrew-next-client",
|
|
23
|
-
sdkVersion = "0.1.
|
|
25
|
+
sdkVersion = "0.1.11",
|
|
24
26
|
maxQueueSize,
|
|
25
27
|
maxRetries = 2,
|
|
26
28
|
onEventDropped,
|
|
@@ -31,7 +33,7 @@ function createLogBrewNextBrowserClient({
|
|
|
31
33
|
throw new SdkError("configuration_error", "createLogBrewNextBrowserClient requires clientKey or apiKey");
|
|
32
34
|
}
|
|
33
35
|
const deploymentContext = withPublicDeployment(context);
|
|
34
|
-
|
|
36
|
+
const client = LogBrewClient.create({
|
|
35
37
|
apiKey: authKey,
|
|
36
38
|
context: deploymentContext,
|
|
37
39
|
deliveryIntervalMs,
|
|
@@ -44,6 +46,8 @@ function createLogBrewNextBrowserClient({
|
|
|
44
46
|
// Sends on its own; pass transport: null to keep the client manual.
|
|
45
47
|
...(transport === null ? {} : { transport: transport ?? createNextBrowserTransport(endpoint) })
|
|
46
48
|
});
|
|
49
|
+
clientEndpoints.set(client, endpoint);
|
|
50
|
+
return client;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
// Report an error from app/error.tsx or app/global-error.tsx, then deliver it.
|
|
@@ -67,7 +71,8 @@ function captureNextClientError(client, error, { digest, routeTemplate, flush =
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
// Report uncaught browser errors and unhandled rejections, and flush queued events on pagehide.
|
|
70
|
-
|
|
74
|
+
// Console, fetch, XHR, and route-change breadcrumbs ride along with each issue; breadcrumbs: false turns them off.
|
|
75
|
+
function installLogBrewNextClientErrorCapture({ breadcrumbs = true, browserWindow = globalThis.window, client } = {}) {
|
|
71
76
|
if (!client || !browserWindow || typeof browserWindow.addEventListener !== "function") {
|
|
72
77
|
throw new SdkError("configuration_error", "installLogBrewNextClientErrorCapture requires a client and a browser window");
|
|
73
78
|
}
|
|
@@ -92,8 +97,12 @@ function installLogBrewNextClientErrorCapture({ client, browserWindow = globalTh
|
|
|
92
97
|
for (const [type, listener] of Object.entries(listeners)) {
|
|
93
98
|
browserWindow.addEventListener(type, listener);
|
|
94
99
|
}
|
|
100
|
+
const uninstallBreadcrumbs = breadcrumbs === false
|
|
101
|
+
? () => undefined
|
|
102
|
+
: installBrowserBreadcrumbs(browserWindow, client, { ignoredUrls: [clientEndpoints.get(client) ?? DEFAULT_ENDPOINT] });
|
|
95
103
|
return {
|
|
96
104
|
uninstall() {
|
|
105
|
+
uninstallBreadcrumbs();
|
|
97
106
|
for (const [type, listener] of Object.entries(listeners)) {
|
|
98
107
|
browserWindow.removeEventListener?.(type, listener);
|
|
99
108
|
}
|
package/client.d.cts
CHANGED
|
@@ -47,6 +47,8 @@ export declare function captureNextClientError(
|
|
|
47
47
|
export declare function installLogBrewNextClientErrorCapture(options: {
|
|
48
48
|
client: LogBrewClient;
|
|
49
49
|
browserWindow?: Window;
|
|
50
|
+
/** Console, fetch, XHR, and route-change breadcrumbs on each issue. Defaults to true. */
|
|
51
|
+
breadcrumbs?: boolean;
|
|
50
52
|
}): { uninstall(): void };
|
|
51
53
|
|
|
52
54
|
export type NextRoutePattern = string;
|
package/client.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare function captureNextClientError(
|
|
|
47
47
|
export declare function installLogBrewNextClientErrorCapture(options: {
|
|
48
48
|
client: LogBrewClient;
|
|
49
49
|
browserWindow?: Window;
|
|
50
|
+
/** Console, fetch, XHR, and route-change breadcrumbs on each issue. Defaults to true. */
|
|
51
|
+
breadcrumbs?: boolean;
|
|
50
52
|
}): { uninstall(): void };
|
|
51
53
|
|
|
52
54
|
export type NextRoutePattern = string;
|
package/client.js
CHANGED
|
@@ -5,12 +5,14 @@ import {
|
|
|
5
5
|
LogBrewClient,
|
|
6
6
|
SdkError,
|
|
7
7
|
createIssueAttributesFromError,
|
|
8
|
+
installBrowserBreadcrumbs,
|
|
8
9
|
parseTraceparent
|
|
9
10
|
} from "@logbrew/sdk";
|
|
10
11
|
|
|
11
12
|
const DEFAULT_ENDPOINT = "https://api.logbrew.co/v1/events";
|
|
12
13
|
// Browsers keep a 5-second interval to save battery and radio; pagehide flushes the rest.
|
|
13
14
|
const DEFAULT_BROWSER_DELIVERY_INTERVAL_MS = 5000;
|
|
15
|
+
const clientEndpoints = new WeakMap();
|
|
14
16
|
|
|
15
17
|
export function createLogBrewNextBrowserClient({
|
|
16
18
|
apiKey,
|
|
@@ -20,7 +22,7 @@ export function createLogBrewNextBrowserClient({
|
|
|
20
22
|
endpoint = DEFAULT_ENDPOINT,
|
|
21
23
|
eventFilter,
|
|
22
24
|
sdkName = "logbrew-next-client",
|
|
23
|
-
sdkVersion = "0.1.
|
|
25
|
+
sdkVersion = "0.1.11",
|
|
24
26
|
maxQueueSize,
|
|
25
27
|
maxRetries = 2,
|
|
26
28
|
onEventDropped,
|
|
@@ -31,7 +33,7 @@ export function createLogBrewNextBrowserClient({
|
|
|
31
33
|
throw new SdkError("configuration_error", "createLogBrewNextBrowserClient requires clientKey or apiKey");
|
|
32
34
|
}
|
|
33
35
|
const deploymentContext = withPublicDeployment(context);
|
|
34
|
-
|
|
36
|
+
const client = LogBrewClient.create({
|
|
35
37
|
apiKey: authKey,
|
|
36
38
|
context: deploymentContext,
|
|
37
39
|
deliveryIntervalMs,
|
|
@@ -44,6 +46,8 @@ export function createLogBrewNextBrowserClient({
|
|
|
44
46
|
// Sends on its own; pass transport: null to keep the client manual.
|
|
45
47
|
...(transport === null ? {} : { transport: transport ?? createNextBrowserTransport(endpoint) })
|
|
46
48
|
});
|
|
49
|
+
clientEndpoints.set(client, endpoint);
|
|
50
|
+
return client;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
// Report an error from app/error.tsx or app/global-error.tsx, then deliver it.
|
|
@@ -67,7 +71,8 @@ export function captureNextClientError(client, error, { digest, routeTemplate, f
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
// Report uncaught browser errors and unhandled rejections, and flush queued events on pagehide.
|
|
70
|
-
|
|
74
|
+
// Console, fetch, XHR, and route-change breadcrumbs ride along with each issue; breadcrumbs: false turns them off.
|
|
75
|
+
export function installLogBrewNextClientErrorCapture({ breadcrumbs = true, browserWindow = globalThis.window, client } = {}) {
|
|
71
76
|
if (!client || !browserWindow || typeof browserWindow.addEventListener !== "function") {
|
|
72
77
|
throw new SdkError("configuration_error", "installLogBrewNextClientErrorCapture requires a client and a browser window");
|
|
73
78
|
}
|
|
@@ -92,8 +97,12 @@ export function installLogBrewNextClientErrorCapture({ client, browserWindow = g
|
|
|
92
97
|
for (const [type, listener] of Object.entries(listeners)) {
|
|
93
98
|
browserWindow.addEventListener(type, listener);
|
|
94
99
|
}
|
|
100
|
+
const uninstallBreadcrumbs = breadcrumbs === false
|
|
101
|
+
? () => undefined
|
|
102
|
+
: installBrowserBreadcrumbs(browserWindow, client, { ignoredUrls: [clientEndpoints.get(client) ?? DEFAULT_ENDPOINT] });
|
|
95
103
|
return {
|
|
96
104
|
uninstall() {
|
|
105
|
+
uninstallBreadcrumbs();
|
|
97
106
|
for (const [type, listener] of Object.entries(listeners)) {
|
|
98
107
|
browserWindow.removeEventListener?.(type, listener);
|
|
99
108
|
}
|
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.11",
|
|
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.11") {
|
|
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.11",
|
|
27
27
|
maxRetries = 2
|
|
28
28
|
} = {}) {
|
|
29
29
|
const authKey = serverApiKey ?? apiKey ?? readEnvServerApiKey() ?? readEnvApiKey();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logbrew/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Next.js App Router helpers for the public LogBrew JavaScript SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.cjs",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"@logbrew/node": "^0.1.2",
|
|
97
|
-
"@logbrew/sdk": "^0.1.
|
|
97
|
+
"@logbrew/sdk": "^0.1.32",
|
|
98
98
|
"next": ">=15",
|
|
99
99
|
"react": ">=18",
|
|
100
100
|
"react-dom": ">=18"
|