-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(cloudflare): Allow users to pass handler to sentryPagesPlugin #13192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -23,7 +23,16 @@ export function sentryPagesPlugin< | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
Params extends string = any, | |||
Data extends Record<string, unknown> = Record<string, unknown>, | |||
>(options: CloudflareOptions): PagesPluginFunction<Env, Params, Data, CloudflareOptions> { | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
PluginParams = any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weakening the type, but it's on purpose - constraining the PluginParams
to be both an object and function doesn't work really well 😬.
@@ -23,7 +23,16 @@ export function sentryPagesPlugin< | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
Params extends string = any, | |||
Data extends Record<string, unknown> = Record<string, unknown>, | |||
>(options: CloudflareOptions): PagesPluginFunction<Env, Params, Data, CloudflareOptions> { | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: If one can only access env variables in the function, should we update the JSDoc of this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes for sure, good call
307d7ef
to
cbe6d17
Compare
While working on adding the cloudflare sdk to some open source projects, I noticed that setup for the cloudflare plugin was a bit of a hassle when you needed access to environmental variables.
This PR allows users to pass a function to
sentryPagesPlugin
that looks like so:This means that users can access the cloudflare
context
(which only exists at the request level) to get environmental variables.To make some other use cases easier, this PR also exposes the
wrapRequestHandler
API to users.