MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / sentryPagesPlugin

Function sentryPagesPlugin

packages/cloudflare/src/pages-plugin.ts:36–60  ·  view source on GitHub ↗
(
  handlerOrOptions:
    | CloudflareOptions
    | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),
)

Source from the content-addressed store, hash-verified

34 * @returns A plugin function that can be used in Cloudflare Pages.
35 */
36export function sentryPagesPlugin<
37 Env = unknown,
38 // eslint-disable-next-line @typescript-eslint/no-explicit-any
39 Params extends string = any,
40 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.
42 // eslint-disable-next-line @typescript-eslint/no-explicit-any
43 PluginParams = any,
44>(
45 handlerOrOptions:
46 | CloudflareOptions
47 | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),
48): PagesPluginFunction<Env, Params, Data, PluginParams> {
49 setAsyncLocalStorageAsyncContextStrategy();
50 return context => {
51 if (context.request.method === 'OPTIONS' || context.request.method === 'HEAD') {
52 return context.next();
53 }
54
55 const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;
56 return wrapRequestHandler({ options, request: context.request, context: { ...context, props: {} } }, () =>
57 context.next(),
58 );
59 };
60}

Callers 2

_middleware.tsFile · 0.90

Calls 3

wrapRequestHandlerFunction · 0.90
nextMethod · 0.80

Tested by

no test coverage detected