@autter/runtime-next 1.6.0 → 1.7.0

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
@@ -9,8 +9,8 @@ same-origin relay route, and a React error boundary.
9
9
  npm install @autter/runtime-next
10
10
  ```
11
11
 
12
- Set `AUTTER_RUNTIME_KEY` in your environment. Then one line of
13
- `next.config` and three small files.
12
+ Set `AUTTER_RUNTIME_KEY` in your environment. Then three small files, and
13
+ (recommended) one line of `next.config`.
14
14
 
15
15
  The package has two entry points — this split is what keeps the Node
16
16
  OpenTelemetry SDK out of your browser bundle:
@@ -22,8 +22,8 @@ OpenTelemetry SDK out of your browser bundle:
22
22
  - `@autter/runtime-next/instrumentation` — `onRequestError` for
23
23
  `instrumentation.ts`; safe on both the Node and edge runtimes.
24
24
 
25
- **`next.config`** — one copy of the Node SDK for `instrumentation.ts` and
26
- your routes:
25
+ **`next.config`** (recommended) — load the Node SDK from `node_modules`
26
+ instead of bundling it:
27
27
 
28
28
  ```js
29
29
  // next.config.mjs
@@ -33,12 +33,16 @@ export default {
33
33
  ```
34
34
 
35
35
  Next bundles server dependencies separately into `instrumentation.ts` and
36
- into each route. Without this line, code in routes, server components and
37
- server actions (`withRuntimeRequest`, `captureServerException`,
38
- `runtimeLogger`, `runtimeContext`, …) reaches a copy of the SDK that
39
- `registerAutter` never started: request summaries are printed to the
40
- console instead of being exported, and an error `withRuntimeRequest`
41
- reports is reported a second time by `onRequestError`. Next 14.2:
36
+ into the route bundles. Since 1.6.1 every copy shares the SDK
37
+ `registerAutter` started, so routes, server components and server actions
38
+ (`withRuntimeRequest`, `captureServerException`, `runtimeLogger`,
39
+ `runtimeContext`, …) export through it, and an error `withRuntimeRequest`
40
+ reported is not reported again by `onRequestError`, with or without this
41
+ line. The line keeps the SDK and its OpenTelemetry
42
+ dependencies out of the route bundles: in our Next 15.5 and 16.4 test app
43
+ the server output had 1.1 to 2.3 MB less JavaScript. (1.6.0 needed it:
44
+ without it, request summaries went to the console and errors were reported
45
+ twice.) Next 14.2:
42
46
  `experimental: { serverComponentsExternalPackages: ["@autter/runtime-node"] }`.
43
47
 
44
48
  **1. `instrumentation.ts`** — server tracing/errors:
@@ -75,6 +79,14 @@ only inside a `process.env.NEXT_RUNTIME` branch Next removes from edge
75
79
  bundles. Without edge errors to report, `export { onRequestError } from
76
80
  "@autter/runtime-next/instrumentation"` is enough.
77
81
 
82
+ Request counts and latency per route come from the `http.server.duration`
83
+ metric of every request, under Next's route template (`/blog/[slug]`,
84
+ `/api/items/[id]`, `/_not-found` for 404s), since 1.7.0: the SDK reads the
85
+ `next.route` Next puts on its own spans while it serves the request. 1.7.0
86
+ also instruments Next's server from the first request; before, it was
87
+ instrumented only once a later request happened to load `http` again (in
88
+ our test app, the first edge-route request), and its metrics had no route.
89
+
78
90
  On Node the error is recorded on the request span through the
79
91
  `registerAutter` tracker — once, even when `withRuntimeRequest` already
80
92
  reported it (Next's context is then added to that report). Recorded with
@@ -141,6 +153,24 @@ export function Providers({ children }: { children: React.ReactNode }) {
141
153
  React render errors don't reach `window.onerror` — the boundary reports
142
154
  them via `captureException` and then renders your fallback.
143
155
 
156
+ **Linking browser errors to server traces** (opt-in): call
157
+ `enableTracePropagation` from `@autter/runtime-next/client`, next to
158
+ `initAutterBrowser` and before the app sends requests. Same-origin `fetch`
159
+ and XHR requests (your route handlers and server actions) then carry a W3C
160
+ `traceparent`, which `registerAutter` continues, so a browser error links to
161
+ the server trace of the request behind it. Cross-origin APIs get one only
162
+ when listed in `tracePropagationTargets`, and must allow the header in CORS.
163
+ `disableTracePropagation()` turns it off; the rules are in
164
+ `@autter/runtime-browser`'s README ("Trace propagation").
165
+
166
+ ```tsx
167
+ "use client";
168
+ import { initAutterBrowser, enableTracePropagation } from "@autter/runtime-next/client";
169
+
170
+ initAutterBrowser({ endpoint: "/api/autter-runtime", service: "web-app" });
171
+ enableTracePropagation({ tracePropagationTargets: ["https://api.example.com/"] });
172
+ ```
173
+
144
174
  Also re-exported for convenience: `captureException`, `captureMessage`,
145
175
  `trackEvent`, `setUser`, `setContext`, `flush` (from
146
176
  `@autter/runtime-next/client`) and `captureServerException`,
@@ -8,7 +8,7 @@ import {
8
8
  // package.json
9
9
  var package_default = {
10
10
  name: "@autter/runtime-next",
11
- version: "1.6.0",
11
+ version: "1.7.0",
12
12
  description: "One-command Autter Runtime for Next.js: server OTel, request wide events, coded errors, browser tracker, relay route, edge middleware and React error boundary",
13
13
  license: "MIT",
14
14
  type: "module",
@@ -65,7 +65,7 @@ var package_default = {
65
65
  dependencies: {
66
66
  "@autter/runtime-browser": "^1.6.0",
67
67
  "@autter/runtime-edge": "^1.1.0",
68
- "@autter/runtime-node": "^1.6.0"
68
+ "@autter/runtime-node": "^1.7.0"
69
69
  },
70
70
  peerDependencies: {
71
71
  react: ">=18"
package/dist/client.cjs CHANGED
@@ -40,7 +40,9 @@ __export(client_exports, {
40
40
  captureMessage: () => import_runtime_browser2.captureMessage,
41
41
  captureOutcome: () => import_runtime_browser2.captureOutcome,
42
42
  clearBreadcrumbs: () => import_breadcrumbs.clearBreadcrumbs,
43
+ disableTracePropagation: () => import_tracing.disableTracePropagation,
43
44
  enableBreadcrumbs: () => import_breadcrumbs.enableBreadcrumbs,
45
+ enableTracePropagation: () => import_tracing.enableTracePropagation,
44
46
  flush: () => import_runtime_browser2.flush,
45
47
  initAutterBrowser: () => import_runtime_browser2.initAutterBrowser,
46
48
  setContext: () => import_runtime_browser2.setContext,
@@ -50,6 +52,7 @@ __export(client_exports, {
50
52
  module.exports = __toCommonJS(client_exports);
51
53
  var import_runtime_browser2 = require("@autter/runtime-browser");
52
54
  var import_breadcrumbs = require("@autter/runtime-browser/breadcrumbs");
55
+ var import_tracing = require("@autter/runtime-browser/tracing");
53
56
 
54
57
  // src/error-boundary.ts
55
58
  var React = __toESM(require("react"), 1);
@@ -87,7 +90,9 @@ var AutterErrorBoundary = class extends React.Component {
87
90
  captureMessage,
88
91
  captureOutcome,
89
92
  clearBreadcrumbs,
93
+ disableTracePropagation,
90
94
  enableBreadcrumbs,
95
+ enableTracePropagation,
91
96
  flush,
92
97
  initAutterBrowser,
93
98
  setContext,
package/dist/client.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { AutterSeverity, autterErrorFromResponse, captureException, captureMessage, captureOutcome, flush, initAutterBrowser, setContext, setUser, trackEvent } from '@autter/runtime-browser';
2
2
  export { Breadcrumb, BreadcrumbInput, BreadcrumbOptions, addBreadcrumb, clearBreadcrumbs, enableBreadcrumbs } from '@autter/runtime-browser/breadcrumbs';
3
+ export { TracePropagationOptions, disableTracePropagation, enableTracePropagation } from '@autter/runtime-browser/tracing';
3
4
  import * as React from 'react';
4
5
 
5
6
  /**
package/dist/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { AutterSeverity, autterErrorFromResponse, captureException, captureMessage, captureOutcome, flush, initAutterBrowser, setContext, setUser, trackEvent } from '@autter/runtime-browser';
2
2
  export { Breadcrumb, BreadcrumbInput, BreadcrumbOptions, addBreadcrumb, clearBreadcrumbs, enableBreadcrumbs } from '@autter/runtime-browser/breadcrumbs';
3
+ export { TracePropagationOptions, disableTracePropagation, enableTracePropagation } from '@autter/runtime-browser/tracing';
3
4
  import * as React from 'react';
4
5
 
5
6
  /**
package/dist/client.js CHANGED
@@ -20,6 +20,10 @@ import {
20
20
  addBreadcrumb,
21
21
  clearBreadcrumbs
22
22
  } from "@autter/runtime-browser/breadcrumbs";
23
+ import {
24
+ enableTracePropagation,
25
+ disableTracePropagation
26
+ } from "@autter/runtime-browser/tracing";
23
27
 
24
28
  // src/error-boundary.ts
25
29
  import * as React from "react";
@@ -56,7 +60,9 @@ export {
56
60
  captureMessage,
57
61
  captureOutcome,
58
62
  clearBreadcrumbs,
63
+ disableTracePropagation,
59
64
  enableBreadcrumbs,
65
+ enableTracePropagation,
60
66
  flush,
61
67
  initAutterBrowser,
62
68
  setContext,
package/dist/index.cjs CHANGED
@@ -73,7 +73,7 @@ var import_runtime_node = require("@autter/runtime-node");
73
73
  // package.json
74
74
  var package_default = {
75
75
  name: "@autter/runtime-next",
76
- version: "1.6.0",
76
+ version: "1.7.0",
77
77
  description: "One-command Autter Runtime for Next.js: server OTel, request wide events, coded errors, browser tracker, relay route, edge middleware and React error boundary",
78
78
  license: "MIT",
79
79
  type: "module",
@@ -130,7 +130,7 @@ var package_default = {
130
130
  dependencies: {
131
131
  "@autter/runtime-browser": "^1.6.0",
132
132
  "@autter/runtime-edge": "^1.1.0",
133
- "@autter/runtime-node": "^1.6.0"
133
+ "@autter/runtime-node": "^1.7.0"
134
134
  },
135
135
  peerDependencies: {
136
136
  react: ">=18"
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  withProcessSpan,
44
44
  withRuntimeOperation,
45
45
  withRuntimeRequest
46
- } from "./chunk-QFEFRAVO.js";
46
+ } from "./chunk-3YYZYC6L.js";
47
47
  export {
48
48
  CODE_PATTERN,
49
49
  RuntimeError,
package/dist/server.cjs CHANGED
@@ -71,7 +71,7 @@ var import_runtime_node = require("@autter/runtime-node");
71
71
  // package.json
72
72
  var package_default = {
73
73
  name: "@autter/runtime-next",
74
- version: "1.6.0",
74
+ version: "1.7.0",
75
75
  description: "One-command Autter Runtime for Next.js: server OTel, request wide events, coded errors, browser tracker, relay route, edge middleware and React error boundary",
76
76
  license: "MIT",
77
77
  type: "module",
@@ -128,7 +128,7 @@ var package_default = {
128
128
  dependencies: {
129
129
  "@autter/runtime-browser": "^1.6.0",
130
130
  "@autter/runtime-edge": "^1.1.0",
131
- "@autter/runtime-node": "^1.6.0"
131
+ "@autter/runtime-node": "^1.7.0"
132
132
  },
133
133
  peerDependencies: {
134
134
  react: ">=18"
package/dist/server.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  withProcessSpan,
44
44
  withRuntimeOperation,
45
45
  withRuntimeRequest
46
- } from "./chunk-QFEFRAVO.js";
46
+ } from "./chunk-3YYZYC6L.js";
47
47
  export {
48
48
  CODE_PATTERN,
49
49
  RuntimeError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autter/runtime-next",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "One-command Autter Runtime for Next.js: server OTel, request wide events, coded errors, browser tracker, relay route, edge middleware and React error boundary",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@autter/runtime-browser": "^1.6.0",
59
59
  "@autter/runtime-edge": "^1.1.0",
60
- "@autter/runtime-node": "^1.6.0"
60
+ "@autter/runtime-node": "^1.7.0"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": ">=18"