@logbrew/next 0.1.10 → 0.1.12
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 +25 -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
|
@@ -75,6 +75,24 @@ rm -f "$HOME/.logbrew/next-service.ingest"
|
|
|
75
75
|
unset LOGBREW_PROJECT_ID
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
## Read Events Back
|
|
79
|
+
|
|
80
|
+
A successful send shows that LogBrew accepted the request. It does not show
|
|
81
|
+
that you can read the event. After your app sends one event, read it
|
|
82
|
+
back with a project read key:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
logbrew projects keys create "<project_id>" --kind read \
|
|
86
|
+
--ingest-key-file "$HOME/.logbrew/setup-check.read" --json
|
|
87
|
+
export LOGBREW_TOKEN="$(< "$HOME/.logbrew/setup-check.read")"
|
|
88
|
+
logbrew read logs --since 1h --json
|
|
89
|
+
logbrew issues --since 1h --json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
A read key reads 1 project and cannot send telemetry. Run `unset LOGBREW_TOKEN`
|
|
93
|
+
when you finish. [Read your events back](https://docs.logbrew.co/guides/verify-setup)
|
|
94
|
+
covers key kinds, empty results, and how to revoke the key.
|
|
95
|
+
|
|
78
96
|
## Release Artifacts
|
|
79
97
|
|
|
80
98
|
For production Next.js builds, wrap `next.config.mjs` with the build-time release-artifact helper. It enables `productionBrowserSourceMaps` only when your config has not chosen a value, runs after the production compile, injects matching Debug IDs, strips embedded source text by default, writes a privacy-bounded manifest next to `.next`, and can upload the prepared artifacts before the build completes:
|
|
@@ -245,7 +263,7 @@ import {
|
|
|
245
263
|
const client = createLogBrewNextBrowserClient({
|
|
246
264
|
clientKey: "LOGBREW_CLIENT_KEY",
|
|
247
265
|
sdkName: "my-next-app",
|
|
248
|
-
sdkVersion: "0.1.
|
|
266
|
+
sdkVersion: "0.1.12"
|
|
249
267
|
});
|
|
250
268
|
|
|
251
269
|
const routePatterns = [
|
|
@@ -308,7 +326,11 @@ never a concrete path.
|
|
|
308
326
|
Call `installLogBrewNextClientErrorCapture({ client })` once in a client
|
|
309
327
|
component to also report uncaught browser errors (`nextjs.window_error`) and
|
|
310
328
|
unhandled rejections (`nextjs.unhandled_rejection`), and to flush queued events
|
|
311
|
-
when the page is hidden.
|
|
329
|
+
when the page is hidden. Each issue carries the last 64 breadcrumbs: console
|
|
330
|
+
calls (message template only), fetch and XHR requests (method, URL without
|
|
331
|
+
query, status), and route changes. Requests to the LogBrew endpoint are
|
|
332
|
+
skipped. Pass `breadcrumbs: false` to turn them off. `uninstall()` removes the
|
|
333
|
+
listeners and puts back every patched method.
|
|
312
334
|
|
|
313
335
|
## Server Client Helper
|
|
314
336
|
|
|
@@ -318,7 +340,7 @@ import { createLogBrewNextClient } from "@logbrew/next";
|
|
|
318
340
|
const client = createLogBrewNextClient({
|
|
319
341
|
serverApiKey: "LOGBREW_SERVER_API_KEY",
|
|
320
342
|
sdkName: "my-next-app",
|
|
321
|
-
sdkVersion: "0.1.
|
|
343
|
+
sdkVersion: "0.1.12"
|
|
322
344
|
});
|
|
323
345
|
```
|
|
324
346
|
|
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.12",
|
|
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.12",
|
|
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.12",
|
|
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.12") {
|
|
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.12",
|
|
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.12",
|
|
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"
|