Skip to content

Commit

Permalink
add comment to pages plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Aug 2, 2024
1 parent 200939e commit cbe6d17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const handle = ({ event, resolve }) => {
},
request: event.request,
context: event.platform.ctx,
}
};
return Sentry.wrapRequestHandler(requestHandlerOptions, () => resolve(event));
};
```
Expand Down
22 changes: 19 additions & 3 deletions packages/cloudflare/src/pages-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,38 @@ import { wrapRequestHandler } from './request';
*
* Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.
*
* @example
* @example Simple usage
*
* ```javascript
* // functions/_middleware.js
* import * as Sentry from '@sentry/cloudflare';
*
* export const onRequest = Sentry.sentryPagesPlugin({
* dsn: process.env.SENTRY_DSN,
* tracesSampleRate: 1.0,
* dsn: process.env.SENTRY_DSN,
* tracesSampleRate: 1.0,
* });
* ```
*
* @example Usage with handler function to access context for environmental variables
*
* ```javascript
* import * as Sentry from '@sentry/cloudflare';
*
* const const onRequest = Sentry.sentryPagesPlugin((context) => ({
* dsn: context.env.SENTRY_DSN,
* tracesSampleRate: 1.0,
* })
* ```
*
* @param handlerOrOptions Configuration options or a function that returns configuration options.
* @returns A plugin function that can be used in Cloudflare Pages.
*/
export function sentryPagesPlugin<
Env = unknown,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Params extends string = any,
Data extends Record<string, unknown> = Record<string, unknown>,
// Although it is not ideal to use `any` here, it makes usage more flexible for different setups.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
PluginParams = any,
>(
Expand Down

0 comments on commit cbe6d17

Please sign in to comment.