@getlimelight/sdk 0.6.1 โ†’ 0.7.8

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 CHANGED
@@ -1,6 +1,7 @@
1
1
  # Limelight SDK
2
2
 
3
- > **Chrome DevTools for React Native** - Real-time debugging with state inspection, network monitoring, console streaming, and render tracking.
3
+ > **React Native Devtools** - Zero-config network inspector, render profiling, state tracking, and console streaming โ€”
4
+ > all in one workspace. Designed for AI workflows.
4
5
 
5
6
  [![npm version](https://img.shields.io/npm/v/@getlimelight/sdk.svg)](https://www.npmjs.com/package/@getlimelight/sdk)
6
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@@ -8,16 +9,24 @@
8
9
 
9
10
  ## Documentation
10
11
 
11
- ๐Ÿ“š **Full documentation at [docs.getlimelight.io](https://docs.getlimelight.io)**
12
+ **Full documentation at [docs.getlimelight.io](https://docs.getlimelight.io)**
13
+
14
+ ## Landing page
15
+
16
+ **Landing page at [getlimelight.io](https://getlimelight.io)**
12
17
 
13
18
  ## Features
14
19
 
15
- - ๐Ÿ”ฎ **State Inspection** - Debug Zustand and Redux stores in real-time
16
- - ๐Ÿ” **Network Monitoring** - Inspect all HTTP requests with GraphQL-first support
17
- - ๐Ÿ“Š **Console Streaming** - View logs with stack traces and source detection
18
- - โšก **Render Tracking** - Find why components re-render
19
- - ๐Ÿ›ก๏ธ **Privacy-First** - Automatic redaction of sensitive data
20
- - ๐ŸŽจ **Zero Config** - Works out of the box
20
+ - **State Inspection** - Debug Zustand and Redux stores in real-time
21
+ - **Network Monitoring** - Inspect all HTTP requests with GraphQL-first support
22
+ - **Console Streaming** - View logs with stack traces and source detection
23
+ - **Render Tracking** - Find why components re-render
24
+ - **Privacy-First** - Automatic redaction of sensitive data
25
+ - **Zero Config** - Works out of the box
26
+ - **Framework Agnostic** - Work in React, RN, Node, Nextjs, etc...
27
+ - **Full-Stack** - See client to server requests traced together and full-stack logs in one place
28
+ - **Automatic Issue Detection** - Limelight automatically detects issues in your app and server
29
+ - **AI Enabled** - Give your AI coding tools insights into your apps runtime context via the Limelight MCP or thorugh the app
21
30
 
22
31
  ## Installation
23
32
 
@@ -90,14 +99,51 @@ Limelight.connect({
90
99
  });
91
100
  ```
92
101
 
102
+ ### Server-Side (Express / Next.js)
103
+
104
+ Capture incoming HTTP requests and responses on your backend.
105
+
106
+ **Express / Connect:**
107
+
108
+ ```typescript
109
+ import express from "express";
110
+ import { Limelight } from "@getlimelight/sdk";
111
+
112
+ const app = express();
113
+
114
+ app.use(express.json());
115
+ app.use(Limelight.middleware());
116
+ ```
117
+
118
+ **Next.js Pages Router (`pages/api/`):**
119
+
120
+ ```typescript
121
+ // pages/api/users.ts
122
+ import { Limelight } from "@getlimelight/sdk";
123
+
124
+ export default Limelight.withLimelight((req, res) => {
125
+ res.json({ ok: true });
126
+ });
127
+ ```
128
+
129
+ Both methods automatically capture request/response headers, bodies, status codes, and timing โ€” and propagate a trace ID (`x-limelight-trace-id`) for full-stack tracing.
130
+
131
+ **Outbound HTTP interception** is automatic in Node.js environments. When `enableNetworkInspector` is `true` (the default), the SDK patches `http.request` and `https.request` to capture all outgoing calls your server makes โ€” API calls to other services, auth servers, databases over HTTP, etc. Combined with the incoming middleware, this gives you full end-to-end tracing:
132
+
133
+ ```
134
+ Client (fetch) โ†’ Your Server (middleware) โ†’ Downstream Service (http interceptor)
135
+ โ†‘ same trace ID propagated across all three โ†‘
136
+ ```
137
+
138
+ No additional setup is required โ€” just connect the SDK and add the middleware.
139
+
93
140
  ## Learn More
94
141
 
95
142
  - [Quick Start Guide](https://docs.getlimelight.io/quickstart)
96
143
  - [State Inspection](https://docs.getlimelight.io/features/state)
97
- - [Network Monitoring](https://docs.getlimelight.io/features/network)
98
- - [Console Streaming](https://docs.getlimelight.io/features/console)
99
- - [Render Tracking](https://docs.getlimelight.io/features/renders)
100
- - [Configuration Reference](https://docs.getlimelight.io/configuration)
144
+ - [Network Monitoring](https://docs.getlimelight.io/features/network-requests)
145
+ - [Console Streaming](https://docs.getlimelight.io/features/console-logs)
146
+ - [Render Tracking](https://docs.getlimelight.io/features/render-tracking)
101
147
 
102
148
  ## License
103
149
 
@@ -105,4 +151,4 @@ MIT ยฉ Limelight
105
151
 
106
152
  ---
107
153
 
108
- [Documentation](https://docs.getlimelight.io) ยท [GitHub](https://github.com/getlimelight/limelight) ยท [Issues](https://github.com/getlimelight/limelight/issues)
154
+ [Documentation](https://docs.getlimelight.io) ยท [GitHub](https://github.com/getlimelight/limelight-sdk) ยท [Issues](https://github.com/getlimelight/limelight-sdk/issues)
package/dist/index.d.mts CHANGED
@@ -1,7 +1,12 @@
1
+ import * as http from 'http';
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+
1
4
  declare enum NetworkType {
2
5
  FETCH = "fetch",
3
6
  XHR = "xhr",
4
- GRAPHQL = "graphql"
7
+ GRAPHQL = "graphql",
8
+ INCOMING = "incoming",
9
+ HTTP = "http"
5
10
  }
6
11
  declare enum NetworkPhase {
7
12
  CONNECT = "CONNECT",
@@ -51,6 +56,7 @@ interface SerializedBody {
51
56
  */
52
57
  interface BaseNetworkEvent {
53
58
  id: string;
59
+ traceId?: string;
54
60
  sessionId: string;
55
61
  timestamp: number;
56
62
  phase: NetworkPhase;
@@ -109,6 +115,9 @@ interface ConnectEvent {
109
115
  platform: "ios" | "android";
110
116
  };
111
117
  }
118
+ /**
119
+ * Request with its corresponding response (for UI display)
120
+ */
112
121
  declare enum EventType {
113
122
  NETWORK = "NETWORK",
114
123
  CONSOLE = "CONSOLE"
@@ -118,29 +127,6 @@ declare enum EventType {
118
127
  */
119
128
  type NetworkEvent = ConnectEvent | NetworkRequest | NetworkResponse | NetworkErrorEvent | GraphQLRequest | GraphQLResponse;
120
129
  type LimelightEvent = NetworkEvent | ConsoleEvent;
121
- interface Session {
122
- id: string;
123
- appName: string;
124
- platform: "ios" | "android";
125
- connectedAt: number;
126
- }
127
- /**
128
- * Request with its corresponding response (for UI display)
129
- */
130
- interface NetworkRequestWithResponse extends NetworkRequest {
131
- response?: NetworkResponse;
132
- status?: number;
133
- duration?: number;
134
- error?: NetworkErrorEvent;
135
- }
136
- /**
137
- * Request with its corresponding response (for UI display)
138
- */
139
- interface NetworkRequestWithResponse extends NetworkRequest {
140
- response?: NetworkResponse;
141
- status?: number;
142
- duration?: number;
143
- }
144
130
 
145
131
  /**
146
132
  * Console log levels
@@ -398,9 +384,9 @@ interface LimelightConfig {
398
384
  */
399
385
  projectKey?: string;
400
386
  /**
401
- * The platform of the application (e.g., "ios", "android").
387
+ * The platform of the application. Auto-detected if not provided.
402
388
  */
403
- platform?: string;
389
+ platform?: "ios" | "android" | "web" | "react-native" | "node" | (string & {});
404
390
  /**
405
391
  * The URL of the Limelight server to connect to. If not provided, it falls back to the local wss server url if there is no project key, or the web wss url if there is a project key.
406
392
  */
@@ -411,26 +397,32 @@ interface LimelightConfig {
411
397
  appName?: string;
412
398
  /**
413
399
  * Flag to enable or disable the Limelight SDK.
400
+ * @default true (SDK is enabled by default)
414
401
  */
415
402
  enabled?: boolean;
416
403
  /**
417
404
  * Flag to enable or disable network request inspection.
405
+ * @default true
418
406
  */
419
407
  enableNetworkInspector?: boolean;
420
408
  /**
421
409
  * Flag to enable or disable console event capturing.
410
+ * @default true
422
411
  */
423
412
  enableConsole?: boolean;
424
413
  /**
425
414
  * Flag to enable or disable GraphQL request capturing.
415
+ * @default true
426
416
  */
427
417
  enableGraphQL?: boolean;
428
418
  /**
429
419
  * Flag to disable capturing of request and response bodies.
420
+ * @default false (bodies are captured by default)
430
421
  */
431
422
  disableBodyCapture?: boolean;
432
423
  /**
433
424
  * Flag to enable or disable render inspection.
425
+ * @default true
434
426
  */
435
427
  enableRenderInspector?: boolean;
436
428
  /**
@@ -445,16 +437,30 @@ interface LimelightConfig {
445
437
  enableStateInspector?: boolean;
446
438
  /**
447
439
  * Flag to enable or disable internal logging for the Limelight SDK
440
+ * @default false
448
441
  */
449
442
  enableInternalLogging?: boolean;
450
443
  /**
451
444
  * Target destination for events. Set to "mcp" to send events to the MCP server at ws://localhost:9229.
452
445
  */
453
446
  target?: "mcp";
447
+ /**
448
+ * Custom header name used for trace ID propagation across client and server.
449
+ * @default 'x-limelight-trace-id'
450
+ */
451
+ traceHeaderName?: string;
454
452
  /**
455
453
  * A callback function to modify or filter events before they are sent to the server
456
454
  */
457
455
  beforeSend?: (event: LimelightMessage) => LimelightMessage | null;
456
+ /**
457
+ * Custom WebSocket implementation for Node.js environments where WebSocket
458
+ * is not globally available (Node < 22). Pass the `ws` package constructor.
459
+ * @example
460
+ * import WebSocket from 'ws';
461
+ * Limelight.connect({ webSocketImpl: WebSocket });
462
+ */
463
+ webSocketImpl?: new (url: string, protocols?: string | string[]) => WebSocket;
458
464
  }
459
465
  /**
460
466
  * Represents a connection or disconnection event in the Limelight SDK.
@@ -520,6 +526,41 @@ interface ResponseBridgeConfig {
520
526
  body?: any;
521
527
  }
522
528
 
529
+ interface MiddlewareOptions {
530
+ /** Maximum body size to capture in bytes. Bodies larger than this are truncated. Default: 64KB */
531
+ maxBodySize?: number;
532
+ }
533
+
534
+ type NextApiHandler = (req: IncomingMessage & {
535
+ body?: unknown;
536
+ query?: Record<string, unknown>;
537
+ }, res: ServerResponse) => void | Promise<void>;
538
+ /**
539
+ * Wraps a Next.js Pages API route handler with Limelight request/response capture.
540
+ *
541
+ * NOTE: This works with Next.js Pages Router API routes (`pages/api/`)
542
+ * which use the Node.js `(req, res)` signature. It does NOT work with
543
+ * App Router route handlers (`app/api/`) which use the Web Standard
544
+ * `Request`/`Response` objects. App Router support is planned for a future release.
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * // pages/api/users.ts
549
+ * import { Limelight } from '@getlimelight/sdk';
550
+ *
551
+ * export default Limelight.withLimelight((req, res) => {
552
+ * res.json({ ok: true });
553
+ * });
554
+ * ```
555
+ *
556
+ * @param sendMessage Function to send Limelight messages to the server
557
+ * @param getSessionId Function to retrieve the current Limelight session ID
558
+ * @param getConfig Function to retrieve the current Limelight configuration
559
+ * @param options Optional middleware options (e.g. maxBodySize)
560
+ * @returns A function that wraps a Next.js API route handler with Limelight capture
561
+ */
562
+ declare const createWithLimelight: (sendMessage: (message: LimelightMessage) => void, getSessionId: () => string, getConfig: () => LimelightConfig | null, options?: MiddlewareOptions) => (handler: NextApiHandler) => NextApiHandler;
563
+
523
564
  declare class LimelightClient {
524
565
  private ws;
525
566
  private config;
@@ -532,9 +573,11 @@ declare class LimelightClient {
532
573
  private maxQueueSize;
533
574
  private networkInterceptor;
534
575
  private xhrInterceptor;
576
+ private httpInterceptor;
535
577
  private consoleInterceptor;
536
578
  private renderInterceptor;
537
579
  private stateInterceptor;
580
+ private errorInterceptor;
538
581
  private requestBridge;
539
582
  private commandHandler;
540
583
  constructor();
@@ -620,6 +663,37 @@ declare class LimelightClient {
620
663
  * @param error - The error that occurred
621
664
  */
622
665
  failRequest(requestId: string, error: unknown): void;
666
+ /**
667
+ * Returns an Express/Connect-compatible middleware that captures incoming
668
+ * HTTP requests and responses.
669
+ *
670
+ * Place after body-parser middleware (express.json(), etc.) for request body capture.
671
+ *
672
+ * @example
673
+ * ```ts
674
+ * app.use(express.json());
675
+ * app.use(Limelight.middleware());
676
+ * ```
677
+ */
678
+ middleware(options?: MiddlewareOptions): (req: http.IncomingMessage & {
679
+ body?: unknown;
680
+ }, res: http.ServerResponse, next: () => void) => void;
681
+ /**
682
+ * Wraps a Next.js Pages API route handler with request/response capture.
683
+ * Works with Pages Router (`pages/api/`), not App Router (`app/api/`).
684
+ *
685
+ * @example
686
+ * ```ts
687
+ * // pages/api/users.ts
688
+ * export default Limelight.withLimelight((req, res) => {
689
+ * res.json({ ok: true });
690
+ * });
691
+ * ```
692
+ */
693
+ withLimelight(handler: Parameters<ReturnType<typeof createWithLimelight>>[0]): (req: http.IncomingMessage & {
694
+ body?: unknown;
695
+ query?: Record<string, unknown>;
696
+ }, res: http.ServerResponse) => void | Promise<void>;
623
697
  }
624
698
  declare const Limelight: LimelightClient;
625
699
 
@@ -627,6 +701,7 @@ declare global {
627
701
  interface XMLHttpRequest {
628
702
  _limelightData?: {
629
703
  id: string;
704
+ traceId?: string;
630
705
  method: string;
631
706
  url: string;
632
707
  headers: Record<string, string>;
@@ -637,4 +712,4 @@ declare global {
637
712
  }
638
713
  }
639
714
 
640
- export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type NetworkRequestWithResponse, type NetworkResponse, NetworkType, type ParsedStackTrace, type RequestBridgeConfig, type ResponseBridgeConfig, type SerializedBody, type Session, type StackFrame };
715
+ export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type NetworkResponse, NetworkType, type ParsedStackTrace, type RequestBridgeConfig, type ResponseBridgeConfig, type SerializedBody, type StackFrame };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
+ import * as http from 'http';
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+
1
4
  declare enum NetworkType {
2
5
  FETCH = "fetch",
3
6
  XHR = "xhr",
4
- GRAPHQL = "graphql"
7
+ GRAPHQL = "graphql",
8
+ INCOMING = "incoming",
9
+ HTTP = "http"
5
10
  }
6
11
  declare enum NetworkPhase {
7
12
  CONNECT = "CONNECT",
@@ -51,6 +56,7 @@ interface SerializedBody {
51
56
  */
52
57
  interface BaseNetworkEvent {
53
58
  id: string;
59
+ traceId?: string;
54
60
  sessionId: string;
55
61
  timestamp: number;
56
62
  phase: NetworkPhase;
@@ -109,6 +115,9 @@ interface ConnectEvent {
109
115
  platform: "ios" | "android";
110
116
  };
111
117
  }
118
+ /**
119
+ * Request with its corresponding response (for UI display)
120
+ */
112
121
  declare enum EventType {
113
122
  NETWORK = "NETWORK",
114
123
  CONSOLE = "CONSOLE"
@@ -118,29 +127,6 @@ declare enum EventType {
118
127
  */
119
128
  type NetworkEvent = ConnectEvent | NetworkRequest | NetworkResponse | NetworkErrorEvent | GraphQLRequest | GraphQLResponse;
120
129
  type LimelightEvent = NetworkEvent | ConsoleEvent;
121
- interface Session {
122
- id: string;
123
- appName: string;
124
- platform: "ios" | "android";
125
- connectedAt: number;
126
- }
127
- /**
128
- * Request with its corresponding response (for UI display)
129
- */
130
- interface NetworkRequestWithResponse extends NetworkRequest {
131
- response?: NetworkResponse;
132
- status?: number;
133
- duration?: number;
134
- error?: NetworkErrorEvent;
135
- }
136
- /**
137
- * Request with its corresponding response (for UI display)
138
- */
139
- interface NetworkRequestWithResponse extends NetworkRequest {
140
- response?: NetworkResponse;
141
- status?: number;
142
- duration?: number;
143
- }
144
130
 
145
131
  /**
146
132
  * Console log levels
@@ -398,9 +384,9 @@ interface LimelightConfig {
398
384
  */
399
385
  projectKey?: string;
400
386
  /**
401
- * The platform of the application (e.g., "ios", "android").
387
+ * The platform of the application. Auto-detected if not provided.
402
388
  */
403
- platform?: string;
389
+ platform?: "ios" | "android" | "web" | "react-native" | "node" | (string & {});
404
390
  /**
405
391
  * The URL of the Limelight server to connect to. If not provided, it falls back to the local wss server url if there is no project key, or the web wss url if there is a project key.
406
392
  */
@@ -411,26 +397,32 @@ interface LimelightConfig {
411
397
  appName?: string;
412
398
  /**
413
399
  * Flag to enable or disable the Limelight SDK.
400
+ * @default true (SDK is enabled by default)
414
401
  */
415
402
  enabled?: boolean;
416
403
  /**
417
404
  * Flag to enable or disable network request inspection.
405
+ * @default true
418
406
  */
419
407
  enableNetworkInspector?: boolean;
420
408
  /**
421
409
  * Flag to enable or disable console event capturing.
410
+ * @default true
422
411
  */
423
412
  enableConsole?: boolean;
424
413
  /**
425
414
  * Flag to enable or disable GraphQL request capturing.
415
+ * @default true
426
416
  */
427
417
  enableGraphQL?: boolean;
428
418
  /**
429
419
  * Flag to disable capturing of request and response bodies.
420
+ * @default false (bodies are captured by default)
430
421
  */
431
422
  disableBodyCapture?: boolean;
432
423
  /**
433
424
  * Flag to enable or disable render inspection.
425
+ * @default true
434
426
  */
435
427
  enableRenderInspector?: boolean;
436
428
  /**
@@ -445,16 +437,30 @@ interface LimelightConfig {
445
437
  enableStateInspector?: boolean;
446
438
  /**
447
439
  * Flag to enable or disable internal logging for the Limelight SDK
440
+ * @default false
448
441
  */
449
442
  enableInternalLogging?: boolean;
450
443
  /**
451
444
  * Target destination for events. Set to "mcp" to send events to the MCP server at ws://localhost:9229.
452
445
  */
453
446
  target?: "mcp";
447
+ /**
448
+ * Custom header name used for trace ID propagation across client and server.
449
+ * @default 'x-limelight-trace-id'
450
+ */
451
+ traceHeaderName?: string;
454
452
  /**
455
453
  * A callback function to modify or filter events before they are sent to the server
456
454
  */
457
455
  beforeSend?: (event: LimelightMessage) => LimelightMessage | null;
456
+ /**
457
+ * Custom WebSocket implementation for Node.js environments where WebSocket
458
+ * is not globally available (Node < 22). Pass the `ws` package constructor.
459
+ * @example
460
+ * import WebSocket from 'ws';
461
+ * Limelight.connect({ webSocketImpl: WebSocket });
462
+ */
463
+ webSocketImpl?: new (url: string, protocols?: string | string[]) => WebSocket;
458
464
  }
459
465
  /**
460
466
  * Represents a connection or disconnection event in the Limelight SDK.
@@ -520,6 +526,41 @@ interface ResponseBridgeConfig {
520
526
  body?: any;
521
527
  }
522
528
 
529
+ interface MiddlewareOptions {
530
+ /** Maximum body size to capture in bytes. Bodies larger than this are truncated. Default: 64KB */
531
+ maxBodySize?: number;
532
+ }
533
+
534
+ type NextApiHandler = (req: IncomingMessage & {
535
+ body?: unknown;
536
+ query?: Record<string, unknown>;
537
+ }, res: ServerResponse) => void | Promise<void>;
538
+ /**
539
+ * Wraps a Next.js Pages API route handler with Limelight request/response capture.
540
+ *
541
+ * NOTE: This works with Next.js Pages Router API routes (`pages/api/`)
542
+ * which use the Node.js `(req, res)` signature. It does NOT work with
543
+ * App Router route handlers (`app/api/`) which use the Web Standard
544
+ * `Request`/`Response` objects. App Router support is planned for a future release.
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * // pages/api/users.ts
549
+ * import { Limelight } from '@getlimelight/sdk';
550
+ *
551
+ * export default Limelight.withLimelight((req, res) => {
552
+ * res.json({ ok: true });
553
+ * });
554
+ * ```
555
+ *
556
+ * @param sendMessage Function to send Limelight messages to the server
557
+ * @param getSessionId Function to retrieve the current Limelight session ID
558
+ * @param getConfig Function to retrieve the current Limelight configuration
559
+ * @param options Optional middleware options (e.g. maxBodySize)
560
+ * @returns A function that wraps a Next.js API route handler with Limelight capture
561
+ */
562
+ declare const createWithLimelight: (sendMessage: (message: LimelightMessage) => void, getSessionId: () => string, getConfig: () => LimelightConfig | null, options?: MiddlewareOptions) => (handler: NextApiHandler) => NextApiHandler;
563
+
523
564
  declare class LimelightClient {
524
565
  private ws;
525
566
  private config;
@@ -532,9 +573,11 @@ declare class LimelightClient {
532
573
  private maxQueueSize;
533
574
  private networkInterceptor;
534
575
  private xhrInterceptor;
576
+ private httpInterceptor;
535
577
  private consoleInterceptor;
536
578
  private renderInterceptor;
537
579
  private stateInterceptor;
580
+ private errorInterceptor;
538
581
  private requestBridge;
539
582
  private commandHandler;
540
583
  constructor();
@@ -620,6 +663,37 @@ declare class LimelightClient {
620
663
  * @param error - The error that occurred
621
664
  */
622
665
  failRequest(requestId: string, error: unknown): void;
666
+ /**
667
+ * Returns an Express/Connect-compatible middleware that captures incoming
668
+ * HTTP requests and responses.
669
+ *
670
+ * Place after body-parser middleware (express.json(), etc.) for request body capture.
671
+ *
672
+ * @example
673
+ * ```ts
674
+ * app.use(express.json());
675
+ * app.use(Limelight.middleware());
676
+ * ```
677
+ */
678
+ middleware(options?: MiddlewareOptions): (req: http.IncomingMessage & {
679
+ body?: unknown;
680
+ }, res: http.ServerResponse, next: () => void) => void;
681
+ /**
682
+ * Wraps a Next.js Pages API route handler with request/response capture.
683
+ * Works with Pages Router (`pages/api/`), not App Router (`app/api/`).
684
+ *
685
+ * @example
686
+ * ```ts
687
+ * // pages/api/users.ts
688
+ * export default Limelight.withLimelight((req, res) => {
689
+ * res.json({ ok: true });
690
+ * });
691
+ * ```
692
+ */
693
+ withLimelight(handler: Parameters<ReturnType<typeof createWithLimelight>>[0]): (req: http.IncomingMessage & {
694
+ body?: unknown;
695
+ query?: Record<string, unknown>;
696
+ }, res: http.ServerResponse) => void | Promise<void>;
623
697
  }
624
698
  declare const Limelight: LimelightClient;
625
699
 
@@ -627,6 +701,7 @@ declare global {
627
701
  interface XMLHttpRequest {
628
702
  _limelightData?: {
629
703
  id: string;
704
+ traceId?: string;
630
705
  method: string;
631
706
  url: string;
632
707
  headers: Record<string, string>;
@@ -637,4 +712,4 @@ declare global {
637
712
  }
638
713
  }
639
714
 
640
- export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type NetworkRequestWithResponse, type NetworkResponse, NetworkType, type ParsedStackTrace, type RequestBridgeConfig, type ResponseBridgeConfig, type SerializedBody, type Session, type StackFrame };
715
+ export { type BaseCommand, type BaseNetworkEvent, BodyFormat, type ClearRendersCommand, type Command, type CommandAckEvent, CommandType, type ConnectEvent, type ConnectionEvent, type ConsoleEvent, ConsoleLevel, ConsoleSource, ConsoleType, EventType, type GraphQLRequest, type GraphQLResponse, GraphqlOprtation, HttpMethod, HttpStatusClass, Limelight, type LimelightConfig, type LimelightEvent, type LimelightMessage, type NetworkErrorEvent, type NetworkEvent, NetworkPhase, type NetworkRequest, type NetworkResponse, NetworkType, type ParsedStackTrace, type RequestBridgeConfig, type ResponseBridgeConfig, type SerializedBody, type StackFrame };