@statly/observe 0.1.0

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/dist/index.mjs ADDED
@@ -0,0 +1,50 @@
1
+ import {
2
+ Statly,
3
+ StatlyClient,
4
+ addBreadcrumb,
5
+ captureException,
6
+ captureMessage,
7
+ captureNextJsError,
8
+ close,
9
+ createRequestCapture,
10
+ expressErrorHandler,
11
+ flush,
12
+ getClient,
13
+ init,
14
+ requestHandler,
15
+ setTag,
16
+ setTags,
17
+ setUser,
18
+ statlyFastifyPlugin,
19
+ statlyPlugin,
20
+ withStatly,
21
+ withStatlyGetServerSideProps,
22
+ withStatlyGetStaticProps,
23
+ withStatlyPagesApi,
24
+ withStatlyServerAction
25
+ } from "./chunk-PETWPVHU.mjs";
26
+ export {
27
+ Statly,
28
+ StatlyClient,
29
+ addBreadcrumb,
30
+ captureException,
31
+ captureMessage,
32
+ captureNextJsError,
33
+ close,
34
+ createRequestCapture,
35
+ expressErrorHandler,
36
+ flush,
37
+ getClient,
38
+ init,
39
+ requestHandler,
40
+ setTag,
41
+ setTags,
42
+ setUser,
43
+ statlyFastifyPlugin,
44
+ statlyPlugin,
45
+ withStatly,
46
+ withStatlyGetServerSideProps,
47
+ withStatlyGetStaticProps,
48
+ withStatlyPagesApi,
49
+ withStatlyServerAction
50
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Express.js Integration
3
+ *
4
+ * Provides middleware for error handling in Express applications.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import express from 'express';
9
+ * import { Statly, expressErrorHandler, requestHandler } from '@statly/observe-sdk';
10
+ *
11
+ * const app = express();
12
+ *
13
+ * // Initialize Statly
14
+ * Statly.init({ dsn: 'your-dsn' });
15
+ *
16
+ * // Add request handler first (optional, for request context)
17
+ * app.use(requestHandler());
18
+ *
19
+ * // Your routes here
20
+ * app.get('/', (req, res) => { ... });
21
+ *
22
+ * // Add error handler last
23
+ * app.use(expressErrorHandler());
24
+ * ```
25
+ */
26
+ interface ExpressRequest {
27
+ method: string;
28
+ url: string;
29
+ originalUrl?: string;
30
+ path?: string;
31
+ headers: Record<string, string | string[] | undefined>;
32
+ query?: Record<string, string>;
33
+ params?: Record<string, string>;
34
+ body?: unknown;
35
+ ip?: string;
36
+ user?: {
37
+ id?: string;
38
+ email?: string;
39
+ [key: string]: unknown;
40
+ };
41
+ session?: {
42
+ id?: string;
43
+ [key: string]: unknown;
44
+ };
45
+ statlyContext?: {
46
+ transactionName?: string;
47
+ startTime?: number;
48
+ };
49
+ }
50
+ interface ExpressResponse {
51
+ statusCode: number;
52
+ headersSent: boolean;
53
+ on(event: string, callback: () => void): void;
54
+ }
55
+ type NextFunction = (err?: Error | unknown) => void;
56
+ type RequestHandler = (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => void;
57
+ type ErrorHandler = (err: Error | unknown, req: ExpressRequest, res: ExpressResponse, next: NextFunction) => void;
58
+ /**
59
+ * Request handler middleware
60
+ * Adds request context and timing information
61
+ */
62
+ declare function requestHandler(): RequestHandler;
63
+ /**
64
+ * Error handler middleware
65
+ * Captures errors and sends them to Statly
66
+ */
67
+ declare function expressErrorHandler(options?: {
68
+ shouldHandleError?: (error: Error) => boolean;
69
+ }): ErrorHandler;
70
+
71
+ export { expressErrorHandler, requestHandler };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Express.js Integration
3
+ *
4
+ * Provides middleware for error handling in Express applications.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import express from 'express';
9
+ * import { Statly, expressErrorHandler, requestHandler } from '@statly/observe-sdk';
10
+ *
11
+ * const app = express();
12
+ *
13
+ * // Initialize Statly
14
+ * Statly.init({ dsn: 'your-dsn' });
15
+ *
16
+ * // Add request handler first (optional, for request context)
17
+ * app.use(requestHandler());
18
+ *
19
+ * // Your routes here
20
+ * app.get('/', (req, res) => { ... });
21
+ *
22
+ * // Add error handler last
23
+ * app.use(expressErrorHandler());
24
+ * ```
25
+ */
26
+ interface ExpressRequest {
27
+ method: string;
28
+ url: string;
29
+ originalUrl?: string;
30
+ path?: string;
31
+ headers: Record<string, string | string[] | undefined>;
32
+ query?: Record<string, string>;
33
+ params?: Record<string, string>;
34
+ body?: unknown;
35
+ ip?: string;
36
+ user?: {
37
+ id?: string;
38
+ email?: string;
39
+ [key: string]: unknown;
40
+ };
41
+ session?: {
42
+ id?: string;
43
+ [key: string]: unknown;
44
+ };
45
+ statlyContext?: {
46
+ transactionName?: string;
47
+ startTime?: number;
48
+ };
49
+ }
50
+ interface ExpressResponse {
51
+ statusCode: number;
52
+ headersSent: boolean;
53
+ on(event: string, callback: () => void): void;
54
+ }
55
+ type NextFunction = (err?: Error | unknown) => void;
56
+ type RequestHandler = (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => void;
57
+ type ErrorHandler = (err: Error | unknown, req: ExpressRequest, res: ExpressResponse, next: NextFunction) => void;
58
+ /**
59
+ * Request handler middleware
60
+ * Adds request context and timing information
61
+ */
62
+ declare function requestHandler(): RequestHandler;
63
+ /**
64
+ * Error handler middleware
65
+ * Captures errors and sends them to Statly
66
+ */
67
+ declare function expressErrorHandler(options?: {
68
+ shouldHandleError?: (error: Error) => boolean;
69
+ }): ErrorHandler;
70
+
71
+ export { expressErrorHandler, requestHandler };