Skip to content

Commit

Permalink
feat(tjs): add more logging for undefined event
Browse files Browse the repository at this point in the history
  • Loading branch information
jbranchaud authored and kodiakhq[bot] committed Mar 13, 2024
1 parent a98bbf3 commit a8089e8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 30 deletions.
12 changes: 10 additions & 2 deletions packages/skill-api/src/core/services/process-stripe-webhook.ts
Expand Up @@ -34,6 +34,9 @@ export async function receiveInternalStripeWebhooks({
params: SkillRecordingsHandlerParams
paymentOptions: PaymentOptions | undefined
}): Promise<OutgoingResponse> {
let event: any
let body: any

try {
const {
req,
Expand All @@ -56,14 +59,19 @@ export async function receiveInternalStripeWebhooks({
}
const stripe = paymentOptions?.stripeCtx.stripe || defaultStripe

const event: any = req.body.event
body = req.body
event = req.body.event

return await processStripeWebhook(event, {
nextAuthOptions,
paymentOptions: _paymentOptions,
})
} catch (error: any) {
console.log(`webhook/stripe-internal error: ${error.message}`)
console.log(
`webhook/stripe-internal error: ${
(error.message, JSON.stringify(event), JSON.stringify(body))
}`,
)

return {
status: 500,
Expand Down
62 changes: 34 additions & 28 deletions packages/skill-api/src/server/send-server-email.ts
Expand Up @@ -78,32 +78,38 @@ export async function sendServerEmail({
text?: (options: TextEmailParams) => string
expiresAt?: Date | null
}) {
const verificationDetails = await createVerificationUrl({
email,
nextAuthOptions,
callbackUrl,
expiresAt: expiresAt || undefined,
})

if (!verificationDetails) return

const {url, token, expires} = verificationDetails

const emailProvider: any = nextAuthOptions.providers.find(
(provider) => provider.id === 'email',
)

console.log('%%% about to sendVerificationRequest %%%')

await sendVerificationRequest({
identifier: email,
url,
theme: nextAuthOptions.theme || {colorScheme: 'auto'},
provider: emailProvider.options,
token: token as string,
expires,
type,
html,
text,
})
try {
const verificationDetails = await createVerificationUrl({
email,
nextAuthOptions,
callbackUrl,
expiresAt: expiresAt || undefined,
})

if (!verificationDetails) return

const {url, token, expires} = verificationDetails

const emailProvider: any = nextAuthOptions.providers.find(
(provider) => provider.id === 'email',
)

console.log('%%% about to sendVerificationRequest %%%')

await sendVerificationRequest({
identifier: email,
url,
theme: nextAuthOptions.theme || {colorScheme: 'auto'},
provider: emailProvider.options,
token: token as string,
expires,
type,
html,
text,
})
} catch (error: any) {
console.log({location: 'sendServerEmail', error})

throw new Error('Unable to sendVerificationRequest')
}
}

0 comments on commit a8089e8

Please sign in to comment.