File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,7 +45,17 @@ initBrowserEcho({
4545 batch: { size: 20 , interval: 300 },
4646 stackMode: ' condensed' ,
4747 // Opt-in network logging
48- networkLogs: { enabled: true , captureFull: false }
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+ }
4959});
5060```
5161
@@ -71,7 +81,17 @@ interface BrowserEchoOptions {
7181 truncate? : number ; // default: 10_000 chars (Vite)
7282 fileLog? : { enabled? : boolean ; dir? : string }; // Vite-only
7383 // network capture (opt-in)
74- networkLogs? : { enabled? : boolean ; captureFull? : boolean }; // default disabled
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
7595}
7696```
7797
Original file line number Diff line number Diff line change @@ -60,7 +60,17 @@ interface BrowserEchoScriptProps {
6060 // batching
6161 batch? : { size? : number ; interval? : number }; // default: 20 / 300ms
6262 // Opt-in network capture (fetch/XHR/WS)
63- networkLogs? : { enabled? : boolean ; captureFull? : boolean };
63+ networkLogs? : {
64+ enabled? : boolean ;
65+ captureFull? : boolean ;
66+ bodies? : {
67+ request? : boolean ;
68+ response? : boolean ;
69+ maxBytes? : number ; // default 2048 bytes
70+ allowContentTypes? : string []; // default ['application/json','text/','application/x-www-form-urlencoded']
71+ prettyJson? : boolean ; // default true
72+ };
73+ };
6474}
6575```
6676
@@ -102,6 +112,10 @@ export default function RootLayout({ children }: { children: ReactNode }) {
102112 stackMode = " condensed"
103113 showSource = { true }
104114 batch = { { size: 10 , interval: 500 }}
115+ networkLogs = { {
116+ enabled: true ,
117+ bodies: { request: true , response: true , maxBytes: 2048 }
118+ }}
105119 />
106120 )}
107121 </head >
Original file line number Diff line number Diff line change @@ -63,7 +63,17 @@ interface BrowserEchoNuxtOptions {
6363 batch? : { size? : number ; interval? : number }; // default: 20 / 300ms
6464 stackMode? : ' full' | ' condensed' | ' none' ; // default: 'condensed'
6565 // Opt-in network capture (fetch/XHR/WS)
66- networkLogs? : { enabled? : boolean ; captureFull? : boolean };
66+ networkLogs? : {
67+ enabled? : boolean ;
68+ captureFull? : boolean ;
69+ bodies? : {
70+ request? : boolean ;
71+ response? : boolean ;
72+ maxBytes? : number ; // default 2048 bytes
73+ allowContentTypes? : string []; // default ['application/json','text/','application/x-www-form-urlencoded']
74+ prettyJson? : boolean ; // default true
75+ };
76+ };
6777}
6878```
6979
@@ -94,6 +104,11 @@ export default defineNuxtConfig({
94104 batch: {
95105 size: 10 , // Send after 10 logs
96106 interval: 500 // Or after 500ms
107+ },
108+ // Enable network body snippets (opt-in)
109+ networkLogs: {
110+ enabled: true ,
111+ bodies: { request: true , response: true , maxBytes: 2048 }
97112 }
98113 }
99114});
Original file line number Diff line number Diff line change @@ -70,6 +70,23 @@ ReactDOM.createRoot(document.getElementById('root')!).render(<Root />);
7070You need a development server endpoint that accepts POST requests at ` /__client-logs ` and prints the received logs to your terminal. The React provider only handles the client side.
7171
7272Note: Network capture (fetch/XHR/WS) is available via ` @browser-echo/core ` and framework providers (Vite, Next, Nuxt). This React (non-Vite) package does not inject network capture on its own.
73+ If you use ` initBrowserEcho ` directly, you can also enable network body snippets via core options:
74+
75+ ``` ts
76+ initBrowserEcho ({
77+ route: ' /__client-logs' ,
78+ networkLogs: {
79+ enabled: true ,
80+ bodies: {
81+ request: true ,
82+ response: true ,
83+ maxBytes: 2048 ,
84+ allowContentTypes: [' application/json' ,' text/' ,' application/x-www-form-urlencoded' ],
85+ prettyJson: true
86+ }
87+ }
88+ });
89+ ```
7390
7491Example Express.js endpoint:
7592
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ This package provides a Vite plugin that includes dev middleware and a virtual m
2121- Full stack trace support with multiple modes
2222- Works with ` index.html ` or server-side rendered apps
2323 - Optional network capture (opt-in): fetch, XMLHttpRequest, WebSocket
24+ - Optional request/response body snippets (opt-in) with safe truncation
2425
2526## Installation
2627
@@ -141,7 +142,17 @@ interface BrowserEchoViteOptions {
141142 };
142143 discoverMcp? : boolean ; // Enable MCP auto-discovery (default: true)
143144 discoveryRefreshMs? : number ; // Discovery refresh interval (default: 30000)
144- networkLogs? : { enabled? : boolean ; captureFull? : boolean }; // default disabled
145+ networkLogs? : {
146+ enabled? : boolean ;
147+ captureFull? : boolean ;
148+ bodies? : {
149+ request? : boolean ;
150+ response? : boolean ;
151+ maxBytes? : number ; // default 2048 bytes
152+ allowContentTypes? : string []; // default ['application/json','text/','application/x-www-form-urlencoded']
153+ prettyJson? : boolean ; // default true
154+ };
155+ }; // default disabled
145156}
146157```
147158
@@ -172,6 +183,31 @@ browserEcho({
172183})
173184```
174185
186+ ### Network body snippets (opt-in)
187+
188+ ``` ts
189+ browserEcho ({
190+ networkLogs: {
191+ enabled: true ,
192+ bodies: {
193+ request: true ,
194+ response: true ,
195+ maxBytes: 2048 ,
196+ allowContentTypes: [' application/json' ,' text/' ,' application/x-www-form-urlencoded' ],
197+ prettyJson: true
198+ }
199+ }
200+ })
201+ ```
202+
203+ Output example:
204+
205+ ```
206+ [NETWORK] [POST] [/api/users] [200] [18ms]
207+ req: {"name":"Ada"}
208+ res: { "id": 1, "name": "Ada" }
209+ ```
210+
175211### Disable MCP
176212
177213``` ts
You can’t perform that action at this time.
0 commit comments