Skip to content

Commit cbe6d17

Browse files
committed
add comment to pages plugin
1 parent 200939e commit cbe6d17

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

packages/cloudflare/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const handle = ({ event, resolve }) => {
9898
},
9999
request: event.request,
100100
context: event.platform.ctx,
101-
}
101+
};
102102
return Sentry.wrapRequestHandler(requestHandlerOptions, () => resolve(event));
103103
};
104104
```

packages/cloudflare/src/pages-plugin.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,38 @@ import { wrapRequestHandler } from './request';
77
*
88
* Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.
99
*
10-
* @example
10+
* @example Simple usage
11+
*
1112
* ```javascript
1213
* // functions/_middleware.js
1314
* import * as Sentry from '@sentry/cloudflare';
1415
*
1516
* export const onRequest = Sentry.sentryPagesPlugin({
16-
* dsn: process.env.SENTRY_DSN,
17-
* tracesSampleRate: 1.0,
17+
* dsn: process.env.SENTRY_DSN,
18+
* tracesSampleRate: 1.0,
1819
* });
1920
* ```
21+
*
22+
* @example Usage with handler function to access context for environmental variables
23+
*
24+
* ```javascript
25+
* import * as Sentry from '@sentry/cloudflare';
26+
*
27+
* const const onRequest = Sentry.sentryPagesPlugin((context) => ({
28+
* dsn: context.env.SENTRY_DSN,
29+
* tracesSampleRate: 1.0,
30+
* })
31+
* ```
32+
*
33+
* @param handlerOrOptions Configuration options or a function that returns configuration options.
34+
* @returns A plugin function that can be used in Cloudflare Pages.
2035
*/
2136
export function sentryPagesPlugin<
2237
Env = unknown,
2338
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2439
Params extends string = any,
2540
Data extends Record<string, unknown> = Record<string, unknown>,
41+
// Although it is not ideal to use `any` here, it makes usage more flexible for different setups.
2642
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2743
PluginParams = any,
2844
>(

0 commit comments

Comments
 (0)