Skip to content
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

feat(tjs): add more logging for undefined event #1442

Merged
merged 1 commit into from Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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')
}
}