@autter/runtime-next 1.0.0 → 1.1.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 +32 -4
- package/dist/chunk-X4TT6GB4.js +38 -0
- package/dist/client.cjs +85 -0
- package/dist/client.js +53 -0
- package/dist/index.cjs +21 -55
- package/dist/index.d.cts +2 -68
- package/dist/index.d.ts +2 -68
- package/dist/index.js +22 -57
- package/dist/server.cjs +59 -0
- package/dist/server.d.cts +38 -0
- package/dist/server.d.ts +38 -0
- package/dist/server.js +28 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -9,7 +9,15 @@ 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 three small files
|
|
12
|
+
Set `AUTTER_RUNTIME_KEY` in your environment. Then three small files.
|
|
13
|
+
|
|
14
|
+
The package has two entry points — this split is what keeps the Node
|
|
15
|
+
OpenTelemetry SDK out of your browser bundle:
|
|
16
|
+
|
|
17
|
+
- `@autter/runtime-next` (or `@autter/runtime-next/server`) — server only:
|
|
18
|
+
`instrumentation.ts`, route handlers, server components.
|
|
19
|
+
- `@autter/runtime-next/client` — client components: browser tracker +
|
|
20
|
+
error boundary. Never imports Node code.
|
|
13
21
|
|
|
14
22
|
**1. `instrumentation.ts`** — server tracing/errors:
|
|
15
23
|
|
|
@@ -27,6 +35,13 @@ export async function register() {
|
|
|
27
35
|
}
|
|
28
36
|
```
|
|
29
37
|
|
|
38
|
+
`registerAutter` passes options straight to `initAutterServer`, so the
|
|
39
|
+
server SDK's defaults apply out of the box: exporters are flushed on
|
|
40
|
+
process exit (`autoFlush`) and custom attributes are scrubbed for PII
|
|
41
|
+
before export (`redactAttributes`). See the `@autter/runtime-node` README
|
|
42
|
+
for every option; `makeSafeCapture`, `installAutterAutoFlush`, and
|
|
43
|
+
`redactAttributes` are also re-exported from this package.
|
|
44
|
+
|
|
30
45
|
**2. `app/api/autter-runtime/route.ts`** — browser relay (key stays server-side):
|
|
31
46
|
|
|
32
47
|
```ts
|
|
@@ -41,7 +56,7 @@ export const { POST } = createAutterRelayRoute({
|
|
|
41
56
|
|
|
42
57
|
```tsx
|
|
43
58
|
"use client";
|
|
44
|
-
import { initAutterBrowser, AutterErrorBoundary } from "@autter/runtime-next";
|
|
59
|
+
import { initAutterBrowser, AutterErrorBoundary } from "@autter/runtime-next/client";
|
|
45
60
|
|
|
46
61
|
initAutterBrowser({
|
|
47
62
|
endpoint: "/api/autter-runtime",
|
|
@@ -62,5 +77,18 @@ React render errors don't reach `window.onerror` — the boundary reports
|
|
|
62
77
|
them via `captureException` and then renders your fallback.
|
|
63
78
|
|
|
64
79
|
Also re-exported for convenience: `captureException`, `captureMessage`,
|
|
65
|
-
`trackEvent`, `setUser`, `setContext`, `flush` (
|
|
66
|
-
`captureServerException`,
|
|
80
|
+
`trackEvent`, `setUser`, `setContext`, `flush` (from
|
|
81
|
+
`@autter/runtime-next/client`) and `captureServerException`,
|
|
82
|
+
`captureServerMessage`, `withProcessSpan`, `withLlmCall`, `trackLlmCall`,
|
|
83
|
+
`instrumentLlmClient`, `emitLlmSelftestTrace` (from the root /
|
|
84
|
+
`@autter/runtime-next/server`).
|
|
85
|
+
|
|
86
|
+
> Importing the root entry from a client component pulls the Node OTel SDK
|
|
87
|
+
> into the browser bundle and fails the build (`fs` cannot be resolved).
|
|
88
|
+
> Client code must always use `@autter/runtime-next/client`.
|
|
89
|
+
|
|
90
|
+
LLM tracing is on automatically once `registerAutter` runs: Vercel AI SDK
|
|
91
|
+
calls with `experimental_telemetry: { isEnabled: true }` (and anything
|
|
92
|
+
wrapped in `withLlmCall` or an `instrumentLlmClient` client) are recorded at
|
|
93
|
+
100% — every call, with model, tokens, latency, and cost. See the
|
|
94
|
+
[`@autter/runtime-node` README](../runtime-node) for the API.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/server.ts
|
|
2
|
+
import {
|
|
3
|
+
createBrowserRelayFetchHandler,
|
|
4
|
+
initAutterServer
|
|
5
|
+
} from "@autter/runtime-node";
|
|
6
|
+
import {
|
|
7
|
+
captureException,
|
|
8
|
+
captureMessage,
|
|
9
|
+
withProcessSpan,
|
|
10
|
+
withLlmCall,
|
|
11
|
+
trackLlmCall,
|
|
12
|
+
instrumentLlmClient,
|
|
13
|
+
emitLlmSelftestTrace,
|
|
14
|
+
makeSafeCapture,
|
|
15
|
+
installAutterAutoFlush,
|
|
16
|
+
redactAttributes
|
|
17
|
+
} from "@autter/runtime-node";
|
|
18
|
+
function registerAutter(options) {
|
|
19
|
+
return initAutterServer(options);
|
|
20
|
+
}
|
|
21
|
+
function createAutterRelayRoute(options) {
|
|
22
|
+
return { POST: createBrowserRelayFetchHandler(options) };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
registerAutter,
|
|
27
|
+
createAutterRelayRoute,
|
|
28
|
+
captureException,
|
|
29
|
+
captureMessage,
|
|
30
|
+
withProcessSpan,
|
|
31
|
+
withLlmCall,
|
|
32
|
+
trackLlmCall,
|
|
33
|
+
instrumentLlmClient,
|
|
34
|
+
emitLlmSelftestTrace,
|
|
35
|
+
makeSafeCapture,
|
|
36
|
+
installAutterAutoFlush,
|
|
37
|
+
redactAttributes
|
|
38
|
+
};
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
|
+
|
|
33
|
+
// src/client.ts
|
|
34
|
+
var client_exports = {};
|
|
35
|
+
__export(client_exports, {
|
|
36
|
+
AutterErrorBoundary: () => AutterErrorBoundary,
|
|
37
|
+
captureException: () => import_runtime_browser2.captureException,
|
|
38
|
+
captureMessage: () => import_runtime_browser2.captureMessage,
|
|
39
|
+
flush: () => import_runtime_browser2.flush,
|
|
40
|
+
initAutterBrowser: () => import_runtime_browser2.initAutterBrowser,
|
|
41
|
+
setContext: () => import_runtime_browser2.setContext,
|
|
42
|
+
setUser: () => import_runtime_browser2.setUser,
|
|
43
|
+
trackEvent: () => import_runtime_browser2.trackEvent
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(client_exports);
|
|
46
|
+
var import_runtime_browser2 = require("@autter/runtime-browser");
|
|
47
|
+
|
|
48
|
+
// src/error-boundary.ts
|
|
49
|
+
var React = __toESM(require("react"), 1);
|
|
50
|
+
var import_runtime_browser = require("@autter/runtime-browser");
|
|
51
|
+
var AutterErrorBoundary = class extends React.Component {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
__publicField(this, "state", { hasError: false });
|
|
55
|
+
}
|
|
56
|
+
static getDerivedStateFromError() {
|
|
57
|
+
return { hasError: true };
|
|
58
|
+
}
|
|
59
|
+
componentDidCatch(error, info) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
(0, import_runtime_browser.captureException)(error, {
|
|
62
|
+
react: true,
|
|
63
|
+
...info.componentStack ? { componentStack: String(info.componentStack).slice(0, 4e3) } : {}
|
|
64
|
+
});
|
|
65
|
+
(_b = (_a = this.props).onError) == null ? void 0 : _b.call(_a, error, info);
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
var _a;
|
|
69
|
+
if (this.state.hasError) {
|
|
70
|
+
return (_a = this.props.fallback) != null ? _a : null;
|
|
71
|
+
}
|
|
72
|
+
return this.props.children;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
AutterErrorBoundary,
|
|
78
|
+
captureException,
|
|
79
|
+
captureMessage,
|
|
80
|
+
flush,
|
|
81
|
+
initAutterBrowser,
|
|
82
|
+
setContext,
|
|
83
|
+
setUser,
|
|
84
|
+
trackEvent
|
|
85
|
+
});
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
|
|
6
|
+
// src/client.ts
|
|
7
|
+
import {
|
|
8
|
+
initAutterBrowser,
|
|
9
|
+
captureException as captureException2,
|
|
10
|
+
captureMessage,
|
|
11
|
+
trackEvent,
|
|
12
|
+
setUser,
|
|
13
|
+
setContext,
|
|
14
|
+
flush
|
|
15
|
+
} from "@autter/runtime-browser";
|
|
16
|
+
|
|
17
|
+
// src/error-boundary.ts
|
|
18
|
+
import * as React from "react";
|
|
19
|
+
import { captureException } from "@autter/runtime-browser";
|
|
20
|
+
var AutterErrorBoundary = class extends React.Component {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
__publicField(this, "state", { hasError: false });
|
|
24
|
+
}
|
|
25
|
+
static getDerivedStateFromError() {
|
|
26
|
+
return { hasError: true };
|
|
27
|
+
}
|
|
28
|
+
componentDidCatch(error, info) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
captureException(error, {
|
|
31
|
+
react: true,
|
|
32
|
+
...info.componentStack ? { componentStack: String(info.componentStack).slice(0, 4e3) } : {}
|
|
33
|
+
});
|
|
34
|
+
(_b = (_a = this.props).onError) == null ? void 0 : _b.call(_a, error, info);
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
var _a;
|
|
38
|
+
if (this.state.hasError) {
|
|
39
|
+
return (_a = this.props.fallback) != null ? _a : null;
|
|
40
|
+
}
|
|
41
|
+
return this.props.children;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
AutterErrorBoundary,
|
|
46
|
+
captureException2 as captureException,
|
|
47
|
+
captureMessage,
|
|
48
|
+
flush,
|
|
49
|
+
initAutterBrowser,
|
|
50
|
+
setContext,
|
|
51
|
+
setUser,
|
|
52
|
+
trackEvent
|
|
53
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,60 +15,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
AutterErrorBoundary: () => AutterErrorBoundary,
|
|
34
|
-
captureException: () => import_runtime_browser2.captureException,
|
|
35
|
-
captureMessage: () => import_runtime_browser2.captureMessage,
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
36
23
|
captureServerException: () => import_runtime_node2.captureException,
|
|
37
24
|
captureServerMessage: () => import_runtime_node2.captureMessage,
|
|
38
25
|
createAutterRelayRoute: () => createAutterRelayRoute,
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
emitLlmSelftestTrace: () => import_runtime_node2.emitLlmSelftestTrace,
|
|
27
|
+
installAutterAutoFlush: () => import_runtime_node2.installAutterAutoFlush,
|
|
28
|
+
instrumentLlmClient: () => import_runtime_node2.instrumentLlmClient,
|
|
29
|
+
makeSafeCapture: () => import_runtime_node2.makeSafeCapture,
|
|
30
|
+
redactAttributes: () => import_runtime_node2.redactAttributes,
|
|
41
31
|
registerAutter: () => registerAutter,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
trackLlmCall: () => import_runtime_node2.trackLlmCall,
|
|
33
|
+
withLlmCall: () => import_runtime_node2.withLlmCall,
|
|
34
|
+
withProcessSpan: () => import_runtime_node2.withProcessSpan
|
|
45
35
|
});
|
|
46
|
-
module.exports = __toCommonJS(
|
|
47
|
-
var import_runtime_node = require("@autter/runtime-node");
|
|
48
|
-
var import_runtime_browser2 = require("@autter/runtime-browser");
|
|
49
|
-
|
|
50
|
-
// src/error-boundary.ts
|
|
51
|
-
var React = __toESM(require("react"), 1);
|
|
52
|
-
var import_runtime_browser = require("@autter/runtime-browser");
|
|
53
|
-
var AutterErrorBoundary = class extends React.Component {
|
|
54
|
-
state = { hasError: false };
|
|
55
|
-
static getDerivedStateFromError() {
|
|
56
|
-
return { hasError: true };
|
|
57
|
-
}
|
|
58
|
-
componentDidCatch(error, info) {
|
|
59
|
-
(0, import_runtime_browser.captureException)(error, {
|
|
60
|
-
react: true,
|
|
61
|
-
...info.componentStack ? { componentStack: String(info.componentStack).slice(0, 4e3) } : {}
|
|
62
|
-
});
|
|
63
|
-
this.props.onError?.(error, info);
|
|
64
|
-
}
|
|
65
|
-
render() {
|
|
66
|
-
if (this.state.hasError) {
|
|
67
|
-
return this.props.fallback ?? null;
|
|
68
|
-
}
|
|
69
|
-
return this.props.children;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
72
37
|
|
|
73
|
-
// src/
|
|
38
|
+
// src/server.ts
|
|
39
|
+
var import_runtime_node = require("@autter/runtime-node");
|
|
74
40
|
var import_runtime_node2 = require("@autter/runtime-node");
|
|
75
41
|
function registerAutter(options) {
|
|
76
42
|
return (0, import_runtime_node.initAutterServer)(options);
|
|
@@ -80,16 +46,16 @@ function createAutterRelayRoute(options) {
|
|
|
80
46
|
}
|
|
81
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
48
|
0 && (module.exports = {
|
|
83
|
-
AutterErrorBoundary,
|
|
84
|
-
captureException,
|
|
85
|
-
captureMessage,
|
|
86
49
|
captureServerException,
|
|
87
50
|
captureServerMessage,
|
|
88
51
|
createAutterRelayRoute,
|
|
89
|
-
|
|
90
|
-
|
|
52
|
+
emitLlmSelftestTrace,
|
|
53
|
+
installAutterAutoFlush,
|
|
54
|
+
instrumentLlmClient,
|
|
55
|
+
makeSafeCapture,
|
|
56
|
+
redactAttributes,
|
|
91
57
|
registerAutter,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
58
|
+
trackLlmCall,
|
|
59
|
+
withLlmCall,
|
|
60
|
+
withProcessSpan
|
|
95
61
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { captureException as captureServerException, captureMessage as captureServerMessage } from '@autter/runtime-node';
|
|
3
|
-
export { AutterSeverity, captureException, captureMessage, flush, initAutterBrowser, setContext, setUser, trackEvent } from '@autter/runtime-browser';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* React error boundary that reports render errors to Autter Runtime.
|
|
8
|
-
* React rendering errors do NOT hit `window.onerror`, so the browser
|
|
9
|
-
* tracker alone misses them — wrap your app:
|
|
10
|
-
*
|
|
11
|
-
* <AutterErrorBoundary fallback={<ErrorPage />}>
|
|
12
|
-
* <Application />
|
|
13
|
-
* </AutterErrorBoundary>
|
|
14
|
-
*/
|
|
15
|
-
interface AutterErrorBoundaryProps {
|
|
16
|
-
fallback?: React.ReactNode;
|
|
17
|
-
/** Called after the error is reported (e.g. to show a toast). */
|
|
18
|
-
onError?: (error: Error, info: React.ErrorInfo) => void;
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
}
|
|
21
|
-
interface State {
|
|
22
|
-
hasError: boolean;
|
|
23
|
-
}
|
|
24
|
-
declare class AutterErrorBoundary extends React.Component<AutterErrorBoundaryProps, State> {
|
|
25
|
-
state: State;
|
|
26
|
-
static getDerivedStateFromError(): State;
|
|
27
|
-
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
28
|
-
render(): React.ReactNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @autter/runtime-next — one-command Autter Runtime for Next.js.
|
|
33
|
-
*
|
|
34
|
-
* 1. `instrumentation.ts` (server tracing):
|
|
35
|
-
*
|
|
36
|
-
* export async function register() {
|
|
37
|
-
* if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
38
|
-
* const { registerAutter } = await import("@autter/runtime-next");
|
|
39
|
-
* registerAutter({
|
|
40
|
-
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
41
|
-
* service: "web-app",
|
|
42
|
-
* release: process.env.GIT_SHA,
|
|
43
|
-
* });
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
*
|
|
47
|
-
* 2. `app/api/autter-runtime/route.ts` (browser relay):
|
|
48
|
-
*
|
|
49
|
-
* import { createAutterRelayRoute } from "@autter/runtime-next";
|
|
50
|
-
* export const { POST } = createAutterRelayRoute({
|
|
51
|
-
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
52
|
-
* });
|
|
53
|
-
*
|
|
54
|
-
* 3. A client component (browser tracker + boundary):
|
|
55
|
-
*
|
|
56
|
-
* "use client";
|
|
57
|
-
* import { initAutterBrowser, AutterErrorBoundary } from "@autter/runtime-next";
|
|
58
|
-
* initAutterBrowser({ endpoint: "/api/autter-runtime", service: "web-app" });
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/** Server OTel init for Next.js `instrumentation.ts`. */
|
|
62
|
-
declare function registerAutter(options: AutterServerOptions): AutterServer;
|
|
63
|
-
/** App Router relay route: `export const { POST } = createAutterRelayRoute({...})`. */
|
|
64
|
-
declare function createAutterRelayRoute(options: RelayOptions): {
|
|
65
|
-
POST: (request: Request) => Promise<Response>;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export { AutterErrorBoundary, type AutterErrorBoundaryProps, createAutterRelayRoute, registerAutter };
|
|
1
|
+
export { createAutterRelayRoute, registerAutter } from './server.cjs';
|
|
2
|
+
export { AutoFlushHandle, AutoFlushOptions, AutterServer, AutterServerOptions, FlushTarget, InstrumentLlmOptions, LlmCallHandle, LlmCallInfo, LlmUsage, RedactOptions, RelayOptions, SafeCapture, TrackedLlmCall, captureException as captureServerException, captureMessage as captureServerMessage, emitLlmSelftestTrace, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, redactAttributes, trackLlmCall, withLlmCall, withProcessSpan } from '@autter/runtime-node';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { captureException as captureServerException, captureMessage as captureServerMessage } from '@autter/runtime-node';
|
|
3
|
-
export { AutterSeverity, captureException, captureMessage, flush, initAutterBrowser, setContext, setUser, trackEvent } from '@autter/runtime-browser';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* React error boundary that reports render errors to Autter Runtime.
|
|
8
|
-
* React rendering errors do NOT hit `window.onerror`, so the browser
|
|
9
|
-
* tracker alone misses them — wrap your app:
|
|
10
|
-
*
|
|
11
|
-
* <AutterErrorBoundary fallback={<ErrorPage />}>
|
|
12
|
-
* <Application />
|
|
13
|
-
* </AutterErrorBoundary>
|
|
14
|
-
*/
|
|
15
|
-
interface AutterErrorBoundaryProps {
|
|
16
|
-
fallback?: React.ReactNode;
|
|
17
|
-
/** Called after the error is reported (e.g. to show a toast). */
|
|
18
|
-
onError?: (error: Error, info: React.ErrorInfo) => void;
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
}
|
|
21
|
-
interface State {
|
|
22
|
-
hasError: boolean;
|
|
23
|
-
}
|
|
24
|
-
declare class AutterErrorBoundary extends React.Component<AutterErrorBoundaryProps, State> {
|
|
25
|
-
state: State;
|
|
26
|
-
static getDerivedStateFromError(): State;
|
|
27
|
-
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
28
|
-
render(): React.ReactNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @autter/runtime-next — one-command Autter Runtime for Next.js.
|
|
33
|
-
*
|
|
34
|
-
* 1. `instrumentation.ts` (server tracing):
|
|
35
|
-
*
|
|
36
|
-
* export async function register() {
|
|
37
|
-
* if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
38
|
-
* const { registerAutter } = await import("@autter/runtime-next");
|
|
39
|
-
* registerAutter({
|
|
40
|
-
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
41
|
-
* service: "web-app",
|
|
42
|
-
* release: process.env.GIT_SHA,
|
|
43
|
-
* });
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
*
|
|
47
|
-
* 2. `app/api/autter-runtime/route.ts` (browser relay):
|
|
48
|
-
*
|
|
49
|
-
* import { createAutterRelayRoute } from "@autter/runtime-next";
|
|
50
|
-
* export const { POST } = createAutterRelayRoute({
|
|
51
|
-
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
52
|
-
* });
|
|
53
|
-
*
|
|
54
|
-
* 3. A client component (browser tracker + boundary):
|
|
55
|
-
*
|
|
56
|
-
* "use client";
|
|
57
|
-
* import { initAutterBrowser, AutterErrorBoundary } from "@autter/runtime-next";
|
|
58
|
-
* initAutterBrowser({ endpoint: "/api/autter-runtime", service: "web-app" });
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/** Server OTel init for Next.js `instrumentation.ts`. */
|
|
62
|
-
declare function registerAutter(options: AutterServerOptions): AutterServer;
|
|
63
|
-
/** App Router relay route: `export const { POST } = createAutterRelayRoute({...})`. */
|
|
64
|
-
declare function createAutterRelayRoute(options: RelayOptions): {
|
|
65
|
-
POST: (request: Request) => Promise<Response>;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export { AutterErrorBoundary, type AutterErrorBoundaryProps, createAutterRelayRoute, registerAutter };
|
|
1
|
+
export { createAutterRelayRoute, registerAutter } from './server.js';
|
|
2
|
+
export { AutoFlushHandle, AutoFlushOptions, AutterServer, AutterServerOptions, FlushTarget, InstrumentLlmOptions, LlmCallHandle, LlmCallInfo, LlmUsage, RedactOptions, RelayOptions, SafeCapture, TrackedLlmCall, captureException as captureServerException, captureMessage as captureServerMessage, emitLlmSelftestTrace, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, redactAttributes, trackLlmCall, withLlmCall, withProcessSpan } from '@autter/runtime-node';
|
package/dist/index.js
CHANGED
|
@@ -1,63 +1,28 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
initAutterServer
|
|
5
|
-
} from "@autter/runtime-node";
|
|
6
|
-
import {
|
|
7
|
-
initAutterBrowser,
|
|
8
|
-
captureException as captureException2,
|
|
2
|
+
captureException,
|
|
9
3
|
captureMessage,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
static getDerivedStateFromError() {
|
|
22
|
-
return { hasError: true };
|
|
23
|
-
}
|
|
24
|
-
componentDidCatch(error, info) {
|
|
25
|
-
captureException(error, {
|
|
26
|
-
react: true,
|
|
27
|
-
...info.componentStack ? { componentStack: String(info.componentStack).slice(0, 4e3) } : {}
|
|
28
|
-
});
|
|
29
|
-
this.props.onError?.(error, info);
|
|
30
|
-
}
|
|
31
|
-
render() {
|
|
32
|
-
if (this.state.hasError) {
|
|
33
|
-
return this.props.fallback ?? null;
|
|
34
|
-
}
|
|
35
|
-
return this.props.children;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/index.ts
|
|
40
|
-
import {
|
|
41
|
-
captureException as captureException3,
|
|
42
|
-
captureMessage as captureMessage2
|
|
43
|
-
} from "@autter/runtime-node";
|
|
44
|
-
function registerAutter(options) {
|
|
45
|
-
return initAutterServer(options);
|
|
46
|
-
}
|
|
47
|
-
function createAutterRelayRoute(options) {
|
|
48
|
-
return { POST: createBrowserRelayFetchHandler(options) };
|
|
49
|
-
}
|
|
4
|
+
createAutterRelayRoute,
|
|
5
|
+
emitLlmSelftestTrace,
|
|
6
|
+
installAutterAutoFlush,
|
|
7
|
+
instrumentLlmClient,
|
|
8
|
+
makeSafeCapture,
|
|
9
|
+
redactAttributes,
|
|
10
|
+
registerAutter,
|
|
11
|
+
trackLlmCall,
|
|
12
|
+
withLlmCall,
|
|
13
|
+
withProcessSpan
|
|
14
|
+
} from "./chunk-X4TT6GB4.js";
|
|
50
15
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
captureMessage,
|
|
54
|
-
captureException3 as captureServerException,
|
|
55
|
-
captureMessage2 as captureServerMessage,
|
|
16
|
+
captureException as captureServerException,
|
|
17
|
+
captureMessage as captureServerMessage,
|
|
56
18
|
createAutterRelayRoute,
|
|
57
|
-
|
|
58
|
-
|
|
19
|
+
emitLlmSelftestTrace,
|
|
20
|
+
installAutterAutoFlush,
|
|
21
|
+
instrumentLlmClient,
|
|
22
|
+
makeSafeCapture,
|
|
23
|
+
redactAttributes,
|
|
59
24
|
registerAutter,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
25
|
+
trackLlmCall,
|
|
26
|
+
withLlmCall,
|
|
27
|
+
withProcessSpan
|
|
63
28
|
};
|
package/dist/server.cjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/server.ts
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
captureServerException: () => import_runtime_node2.captureException,
|
|
24
|
+
captureServerMessage: () => import_runtime_node2.captureMessage,
|
|
25
|
+
createAutterRelayRoute: () => createAutterRelayRoute,
|
|
26
|
+
emitLlmSelftestTrace: () => import_runtime_node2.emitLlmSelftestTrace,
|
|
27
|
+
installAutterAutoFlush: () => import_runtime_node2.installAutterAutoFlush,
|
|
28
|
+
instrumentLlmClient: () => import_runtime_node2.instrumentLlmClient,
|
|
29
|
+
makeSafeCapture: () => import_runtime_node2.makeSafeCapture,
|
|
30
|
+
redactAttributes: () => import_runtime_node2.redactAttributes,
|
|
31
|
+
registerAutter: () => registerAutter,
|
|
32
|
+
trackLlmCall: () => import_runtime_node2.trackLlmCall,
|
|
33
|
+
withLlmCall: () => import_runtime_node2.withLlmCall,
|
|
34
|
+
withProcessSpan: () => import_runtime_node2.withProcessSpan
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(server_exports);
|
|
37
|
+
var import_runtime_node = require("@autter/runtime-node");
|
|
38
|
+
var import_runtime_node2 = require("@autter/runtime-node");
|
|
39
|
+
function registerAutter(options) {
|
|
40
|
+
return (0, import_runtime_node.initAutterServer)(options);
|
|
41
|
+
}
|
|
42
|
+
function createAutterRelayRoute(options) {
|
|
43
|
+
return { POST: (0, import_runtime_node.createBrowserRelayFetchHandler)(options) };
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
captureServerException,
|
|
48
|
+
captureServerMessage,
|
|
49
|
+
createAutterRelayRoute,
|
|
50
|
+
emitLlmSelftestTrace,
|
|
51
|
+
installAutterAutoFlush,
|
|
52
|
+
instrumentLlmClient,
|
|
53
|
+
makeSafeCapture,
|
|
54
|
+
redactAttributes,
|
|
55
|
+
registerAutter,
|
|
56
|
+
trackLlmCall,
|
|
57
|
+
withLlmCall,
|
|
58
|
+
withProcessSpan
|
|
59
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RelayOptions, AutterServerOptions, AutterServer } from '@autter/runtime-node';
|
|
2
|
+
export { AutoFlushHandle, AutoFlushOptions, AutterServer, AutterServerOptions, FlushTarget, InstrumentLlmOptions, LlmCallHandle, LlmCallInfo, LlmUsage, RedactOptions, RelayOptions, SafeCapture, TrackedLlmCall, captureException as captureServerException, captureMessage as captureServerMessage, emitLlmSelftestTrace, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, redactAttributes, trackLlmCall, withLlmCall, withProcessSpan } from '@autter/runtime-node';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Server half of @autter/runtime-next. Safe to import anywhere Node runs:
|
|
6
|
+
* `instrumentation.ts`, route handlers, server components, server actions.
|
|
7
|
+
*
|
|
8
|
+
* 1. `instrumentation.ts` (server tracing):
|
|
9
|
+
*
|
|
10
|
+
* export async function register() {
|
|
11
|
+
* if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
12
|
+
* const { registerAutter } = await import("@autter/runtime-next");
|
|
13
|
+
* registerAutter({
|
|
14
|
+
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
15
|
+
* service: "web-app",
|
|
16
|
+
* release: process.env.GIT_SHA,
|
|
17
|
+
* });
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* 2. `app/api/autter-runtime/route.ts` (browser relay):
|
|
22
|
+
*
|
|
23
|
+
* import { createAutterRelayRoute } from "@autter/runtime-next";
|
|
24
|
+
* export const { POST } = createAutterRelayRoute({
|
|
25
|
+
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* Browser tracker + error boundary live in `@autter/runtime-next/client`.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** Server OTel init for Next.js `instrumentation.ts`. */
|
|
32
|
+
declare function registerAutter(options: AutterServerOptions): AutterServer;
|
|
33
|
+
/** App Router relay route: `export const { POST } = createAutterRelayRoute({...})`. */
|
|
34
|
+
declare function createAutterRelayRoute(options: RelayOptions): {
|
|
35
|
+
POST: (request: Request) => Promise<Response>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { createAutterRelayRoute, registerAutter };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RelayOptions, AutterServerOptions, AutterServer } from '@autter/runtime-node';
|
|
2
|
+
export { AutoFlushHandle, AutoFlushOptions, AutterServer, AutterServerOptions, FlushTarget, InstrumentLlmOptions, LlmCallHandle, LlmCallInfo, LlmUsage, RedactOptions, RelayOptions, SafeCapture, TrackedLlmCall, captureException as captureServerException, captureMessage as captureServerMessage, emitLlmSelftestTrace, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, redactAttributes, trackLlmCall, withLlmCall, withProcessSpan } from '@autter/runtime-node';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Server half of @autter/runtime-next. Safe to import anywhere Node runs:
|
|
6
|
+
* `instrumentation.ts`, route handlers, server components, server actions.
|
|
7
|
+
*
|
|
8
|
+
* 1. `instrumentation.ts` (server tracing):
|
|
9
|
+
*
|
|
10
|
+
* export async function register() {
|
|
11
|
+
* if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
12
|
+
* const { registerAutter } = await import("@autter/runtime-next");
|
|
13
|
+
* registerAutter({
|
|
14
|
+
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
15
|
+
* service: "web-app",
|
|
16
|
+
* release: process.env.GIT_SHA,
|
|
17
|
+
* });
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* 2. `app/api/autter-runtime/route.ts` (browser relay):
|
|
22
|
+
*
|
|
23
|
+
* import { createAutterRelayRoute } from "@autter/runtime-next";
|
|
24
|
+
* export const { POST } = createAutterRelayRoute({
|
|
25
|
+
* apiKey: process.env.AUTTER_RUNTIME_KEY!,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* Browser tracker + error boundary live in `@autter/runtime-next/client`.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** Server OTel init for Next.js `instrumentation.ts`. */
|
|
32
|
+
declare function registerAutter(options: AutterServerOptions): AutterServer;
|
|
33
|
+
/** App Router relay route: `export const { POST } = createAutterRelayRoute({...})`. */
|
|
34
|
+
declare function createAutterRelayRoute(options: RelayOptions): {
|
|
35
|
+
POST: (request: Request) => Promise<Response>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { createAutterRelayRoute, registerAutter };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
captureException,
|
|
3
|
+
captureMessage,
|
|
4
|
+
createAutterRelayRoute,
|
|
5
|
+
emitLlmSelftestTrace,
|
|
6
|
+
installAutterAutoFlush,
|
|
7
|
+
instrumentLlmClient,
|
|
8
|
+
makeSafeCapture,
|
|
9
|
+
redactAttributes,
|
|
10
|
+
registerAutter,
|
|
11
|
+
trackLlmCall,
|
|
12
|
+
withLlmCall,
|
|
13
|
+
withProcessSpan
|
|
14
|
+
} from "./chunk-X4TT6GB4.js";
|
|
15
|
+
export {
|
|
16
|
+
captureException as captureServerException,
|
|
17
|
+
captureMessage as captureServerMessage,
|
|
18
|
+
createAutterRelayRoute,
|
|
19
|
+
emitLlmSelftestTrace,
|
|
20
|
+
installAutterAutoFlush,
|
|
21
|
+
instrumentLlmClient,
|
|
22
|
+
makeSafeCapture,
|
|
23
|
+
redactAttributes,
|
|
24
|
+
registerAutter,
|
|
25
|
+
trackLlmCall,
|
|
26
|
+
withLlmCall,
|
|
27
|
+
withProcessSpan
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autter/runtime-next",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "One-command Autter Runtime for Next.js: server OTel, browser tracker, relay route, and React error boundary",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,6 +12,16 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
14
|
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./server": {
|
|
17
|
+
"types": "./dist/server.d.ts",
|
|
18
|
+
"import": "./dist/server.js",
|
|
19
|
+
"require": "./dist/server.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./client": {
|
|
22
|
+
"types": "./dist/client.d.ts",
|
|
23
|
+
"import": "./dist/client.js",
|
|
24
|
+
"require": "./dist/client.cjs"
|
|
15
25
|
}
|
|
16
26
|
},
|
|
17
27
|
"files": [
|
|
@@ -23,7 +33,7 @@
|
|
|
23
33
|
"directory": "packages/runtime-next"
|
|
24
34
|
},
|
|
25
35
|
"scripts": {
|
|
26
|
-
"build": "tsup
|
|
36
|
+
"build": "tsup"
|
|
27
37
|
},
|
|
28
38
|
"dependencies": {
|
|
29
39
|
"@autter/runtime-browser": "^1.0.0",
|