next-plugin-agent-tail 0.3.0 → 0.3.2
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 -5
- package/dist/handler.mjs +1 -1
- package/dist/index.mjs +9 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Next.js plugin for [agent-tail](https://agent-tail.vercel.app/) — captures browser `console.log`, `console.warn`, `console.error`, unhandled errors, and unhandled promise rejections to log files on disk during development.
|
|
4
4
|
|
|
5
|
+
> **Tip:** Install the umbrella [`agent-tail`](https://www.npmjs.com/package/agent-tail) package to get the CLI, Vite plugin, and Next.js plugin in one install: `npm install -D agent-tail`
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
npm install -D
|
|
10
|
+
npm install -D agent-tail
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
## Setup
|
|
12
14
|
|
|
13
15
|
```ts
|
|
14
16
|
// next.config.ts
|
|
15
|
-
import { withAgentTail } from "
|
|
17
|
+
import { withAgentTail } from "agent-tail/next"
|
|
16
18
|
|
|
17
19
|
export default withAgentTail({
|
|
18
20
|
// your Next.js config
|
|
@@ -21,7 +23,7 @@ export default withAgentTail({
|
|
|
21
23
|
|
|
22
24
|
```tsx
|
|
23
25
|
// app/layout.tsx
|
|
24
|
-
import { AgentTailScript } from "
|
|
26
|
+
import { AgentTailScript } from "agent-tail/next/script"
|
|
25
27
|
|
|
26
28
|
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
27
29
|
return (
|
|
@@ -37,7 +39,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|
|
37
39
|
|
|
38
40
|
```ts
|
|
39
41
|
// app/api/__browser-logs/route.ts
|
|
40
|
-
export { POST } from "
|
|
42
|
+
export { POST } from "agent-tail/next/handler"
|
|
41
43
|
```
|
|
42
44
|
|
|
43
45
|
Then in another terminal:
|
|
@@ -51,7 +53,7 @@ tail -f tmp/logs/latest/browser.log
|
|
|
51
53
|
Use both the plugin and the CLI to get browser console logs *and* server output in one place:
|
|
52
54
|
|
|
53
55
|
```bash
|
|
54
|
-
|
|
56
|
+
agent-tail run 'fe: npm run dev' 'api: uvicorn main:app'
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
## Docs
|
package/dist/handler.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { AgentTailScript } from "./script.mjs";
|
|
2
2
|
import { POST, pages_handler } from "./handler.mjs";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { DEFAULT_OPTIONS, LogManager, SESSION_ENV_VAR, resolve_options } from "agent-tail-core";
|
|
4
5
|
|
|
5
6
|
//#region src/with-browser-logs.ts
|
|
6
7
|
function withAgentTail(next_config = {}, user_options) {
|
|
7
8
|
const options = resolve_options(user_options);
|
|
8
9
|
const log_manager = new LogManager(options);
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const parent_session = process.env[SESSION_ENV_VAR];
|
|
11
|
+
let log_path;
|
|
12
|
+
if (parent_session && fs.existsSync(parent_session)) log_path = log_manager.join_session(parent_session);
|
|
13
|
+
else {
|
|
14
|
+
const project_root = process.cwd();
|
|
15
|
+
log_path = log_manager.initialize(project_root);
|
|
16
|
+
}
|
|
11
17
|
return {
|
|
12
18
|
...next_config,
|
|
13
19
|
env: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-plugin-agent-tail",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"description": "Next.js plugin for agent-tail — pipes browser console logs to files on disk during development.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"README.md"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"agent-tail-core": "^0.3.
|
|
41
|
+
"agent-tail-core": "^0.3.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"next": ">=13.0.0"
|