Sam Hulick
08/19/2021, 3:16 AMlet middyfied = middy(
Sentry.AWSLambda.wrapHandler<
ValidatedAPIGatewayProxyEvent<S>,
APIGatewayProxyResult | undefined
>(async (event, context) => {
let claims: JWTClaims | null = null;
let result: InnerHandlerResult | void;
await initSentry();
in other words, does it make sense to initialize Sentry (with the DSN, etc) inside the Sentry.AWS.wrapHandler
? my thinking is that the initialization doesn’t actually matter until Sentry is about to send off an error. all the code in their wrapHandler
just seems like setup.Sam Hulick
08/19/2021, 3:24 AMSentry.AWS.wrapHandler
Ashishkumar Pandey
08/19/2021, 4:02 AMSam Hulick
08/19/2021, 4:15 AMexport function wrapApiHandler<S>(
schema: S,
handler: HandlerForPrivateEndpoint<S> | HandlerForPublicEndpoint<S>,
publicEndpoint = false
): Handler<
ValidatedAPIGatewayProxyEvent<S>,
APIGatewayProxyResult | undefined
> {
let middyfied = middy(async () => {
await initSentry();
return new Promise(resolve =>
Sentry.AWSLambda.wrapHandler<
ValidatedAPIGatewayProxyEvent<S>,
APIGatewayProxyResult | undefined
// @ts-ignore
>(async (event, context) => {
let claims: JWTClaims | null = null;
let result: InnerHandlerResult | void;
this is getting quite ugly 😬 like.. I can’t wrap my head around this level of functional programmingAshishkumar Pandey
08/19/2021, 4:17 AMSam Hulick
08/19/2021, 4:18 AMawait
at top levelSam Hulick
08/19/2021, 4:19 AMSam Hulick
08/19/2021, 4:19 AMawait initSentry()
inside every single API functionAshishkumar Pandey
08/19/2021, 4:20 AMSam Hulick
08/19/2021, 4:20 AMAshishkumar Pandey
08/19/2021, 4:24 AMFrank
Sam Hulick
08/19/2021, 4:25 AMcallback
in so long, I kinda forgot about it.Sam Hulick
08/19/2021, 4:25 AMAshishkumar Pandey
08/19/2021, 4:27 AMSam Hulick
08/19/2021, 4:39 AMcallback
didn’t work 😕 I suppose I’ll wait till tomorrow on thisSam Hulick
08/19/2021, 4:40 AMAshishkumar Pandey
08/19/2021, 4:40 AMthdxr
08/19/2021, 12:34 PMthdxr
08/19/2021, 12:34 PMSam Hulick
08/19/2021, 2:27 PMawait initSentry()
before returning the Sentry-wrapped handler?Sam Hulick
08/19/2021, 2:30 PMSam Hulick
08/19/2021, 2:31 PMthdxr
08/19/2021, 2:33 PM