Getting Started
Install dependencies and start the development server:
npm install
npm run devThis builds the instrumentation bundle first, then starts Electron in dev mode with hot reload.
Once running, paste your app's URL (e.g. http://localhost:3000) into the onboarding screen. FlowLens loads your app in an embedded browser and auto-injects instrumentation — zero frontend code changes required.
Architecture
FlowLens has three Electron processes:
Data Flow
Embedded page(auto-injected) ──WS :9230──▶ ws-server.ts ──┐
├──▶ trace-engine ──▶ renderer
@nihal/flowlens-node ──HTTP :9229─▶ span-collector ─┘Both frontend events and backend spans are correlated by traceId, which is propagated via the X-FlowLens-Trace-Id header injected into all outgoing fetch/XHR requests.
Event Types
domClick, submit, input, change, focus, blur eventsnetwork-requestOutgoing fetch and XHR requestsnetwork-responseCompleted responses with body previewnetwork-errorFailed network callsconsoleconsole.log, warn, error, info, debugerrorRuntime errors and unhandled rejectionsstate-changeReact useState/useReducer mutationsbackend-spanServer-side request/handler/response phasesElement Inspector
Click the Inspect button in the target toolbar to activate the element inspector. Hover over any element in the embedded page to see:
- • Tag name, classes, and dimensions
- • React component name (if applicable)
- • Source file location of the component
Click an element to navigate directly to its component's source file in the source code panel.
Backend Tracing
Install @nihal/flowlens-node in your backend to correlate server-side spans with frontend traces. The middleware reads the X-FlowLens-Trace-Id header and reports spans back to FlowLens.
npm install @nihal/flowlens-nodeCORS must allow the trace header for cross-origin requests:
import cors from 'cors'
import { flowlens } from '@nihal/flowlens-node'
app.use(cors({
origin: true,
allowedHeaders: ['Content-Type', 'X-FlowLens-Trace-Id']
}))
app.use(flowlens({ serviceName: 'my-api' }))Each backend span appears as three events in the timeline: ingress, route-handler, and egress. Zero overhead when the trace header is absent.
Quick Setup
- 1. Start FlowLens desktop:
npm run dev - 2. Paste your frontend URL (e.g.
http://localhost:3000) — instrumentation is injected automatically - 3. (Optional) Backend: install
@nihal/flowlens-node, attach middleware with CORS headers - 4. Use your app — traces appear with frontend + backend events correlated
SDK Reference
@nihal/flowlens-node
Backend span collection SDK — Express, Fastify, and raw HTTP adapters