Skip to content

Commit 6887610

Browse files
authored
Merge pull request #5 from instructa/feat/network-ws-logs
feat: add opt-in network logging with fetch, XHR, and WebSocket capture
2 parents 5ddd0f3 + a16c609 commit 6887610

37 files changed

+899
-130
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.0] - 2025-09-XX
9+
10+
### Added
11+
- **Network Logs (opt-in)**: Capture fetch, XMLHttpRequest, and WebSocket as `[network]` entries alongside console logs. Disabled by default; enable via `networkLogs.enabled: true` (Vite/Next/Nuxt/Core).
12+
- **Tag Filtering**: `get_logs({ tag })` and diagnostics `GET /__client-logs?tag=...` to filter by stream tag (`[browser]`, `[network]`, `[worker]`).
13+
- **Worker Runtime (internal)**: Dev-only worker console capture runtime available in core (not exported publicly by default).
14+
- **MCP File Logging (opt-in)**: Enable ingest-side file logging with `BROWSER_ECHO_FILE_LOG=true` and optional split via `BROWSER_ECHO_SPLIT_LOGS=true`.
15+
16+
### Changed
17+
- Removed protocol from network log text. Format now: `[NETWORK] [METHOD] [URL] [STATUS] [DURATION ms]` and WS events `[WS OPEN/CLOSE/ERROR]`.
18+
- Next/Nuxt handlers now suppress terminal only when `BROWSER_ECHO_MCP_URL` is set.
19+
820
## [1.0.2] - 2025-09-XX
921

1022
### Fixed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Stream browser `console.*` logs to your dev terminal and optional file logging.
5151
- Colorized terminal output
5252
- Optional file logging (Vite provider only)
5353
- Works great with AI assistants reading your terminal
54+
- Optional network capture (opt‑in): fetch, XMLHttpRequest, WebSocket
5455

5556
## Production
5657

example/next-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"react-dom": "19.1.1"
1515
},
1616
"devDependencies": {
17-
"@browser-echo/mcp": "workspace:*",
18-
"@browser-echo/next": "workspace:*",
17+
"@browser-echo/mcp": "1.0.2",
18+
"@browser-echo/next": "1.0.2",
1919
"@eslint/eslintrc": "^3",
2020
"@tailwindcss/postcss": "^4.1.12",
2121
"@types/node": "^24.3.0",

example/nuxt-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
},
1717
"packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac",
1818
"devDependencies": {
19-
"@browser-echo/nuxt": "workspace:*"
19+
"@browser-echo/nuxt": "1.0.2"
2020
}
2121
}

example/react-vite-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"react-dom": "^19.1.1"
1515
},
1616
"devDependencies": {
17-
"@browser-echo/vite": "workspace:*",
17+
"@browser-echo/vite": "1.0.2",
1818
"@eslint/js": "^9.17.0",
1919
"@types/react": "^19.1.10",
2020
"@types/react-dom": "^19.1.7",

example/tanstack-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"zod": "^4.0.17"
1919
},
2020
"devDependencies": {
21-
"@browser-echo/vite": "workspace:*",
21+
"@browser-echo/vite": "1.0.2",
2222
"@types/node": "^24.3.0",
2323
"@types/react": "^19.1.10",
2424
"@types/react-dom": "^19.1.7",

example/vue-vite-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"vue": "^3.5.18"
1313
},
1414
"devDependencies": {
15-
"@browser-echo/vite": "workspace:*",
15+
"@browser-echo/vite": "1.0.2",
1616
"@vitejs/plugin-vue": "^6.0.1",
1717
"typescript": "~5.9.2",
1818
"vite": "^7.1.3",

packages/core/README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This package provides the `initBrowserEcho` function that patches `console.*` me
1818
- Configurable log levels and batching
1919
- Circular reference handling in logged objects
2020
- No production impact (meant for development only)
21+
- Optional network capture (opt-in): fetch, XMLHttpRequest, WebSocket
2122

2223
## Installation
2324

@@ -42,7 +43,19 @@ initBrowserEcho({
4243
preserveConsole: true,
4344
tag: '[browser]',
4445
batch: { size: 20, interval: 300 },
45-
stackMode: 'condensed'
46+
stackMode: 'condensed',
47+
// Opt-in network logging
48+
networkLogs: {
49+
enabled: true,
50+
captureFull: false,
51+
bodies: {
52+
request: true,
53+
response: true,
54+
maxBytes: 2048,
55+
allowContentTypes: ['application/json', 'text/', 'application/x-www-form-urlencoded'],
56+
prettyJson: true
57+
}
58+
}
4659
});
4760
```
4861

@@ -67,6 +80,18 @@ interface BrowserEchoOptions {
6780
// server-side
6881
truncate?: number; // default: 10_000 chars (Vite)
6982
fileLog?: { enabled?: boolean; dir?: string }; // Vite-only
83+
// network capture (opt-in)
84+
networkLogs?: {
85+
enabled?: boolean;
86+
captureFull?: boolean;
87+
bodies?: {
88+
request?: boolean;
89+
response?: boolean;
90+
maxBytes?: number; // default 2048 bytes
91+
allowContentTypes?: string[]; // default ['application/json','text/','application/x-www-form-urlencoded']
92+
prettyJson?: boolean; // default true
93+
};
94+
}; // default disabled
7095
}
7196
```
7297

packages/core/build.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export default defineBuildConfig({
44
entries: [
55
'./src/index',
66
'./src/client',
7-
'./src/types'
7+
'./src/types',
8+
'./src/worker'
89
],
910
clean: true,
1011
declaration: true,

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@browser-echo/core",
3-
"version": "1.0.1",
3+
"version": "1.1.0-alpha.1",
44
"type": "module",
55
"sideEffects": false,
66
"repository": {

0 commit comments

Comments
 (0)