Skip to content

Commit 5d45dea

Browse files
committed
Added some logging when sending magic link emails
1 parent a25751e commit 5d45dea

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

apps/webapp/app/services/email.server.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { env } from "~/env.server";
66
import type { User } from "~/models/user.server";
77
import type { AuthUser } from "./authUser";
88
import { workerQueue } from "./worker.server";
9+
import { logger } from "./logger.server";
910

1011
const client = new EmailClient({
1112
apikey: env.RESEND_API_KEY,
@@ -20,11 +21,18 @@ export async function sendMagicLinkEmail(options: SendEmailOptions<AuthUser>): P
2021
throw redirect(options.magicLink);
2122
}
2223

23-
return client.send({
24-
email: "magic_link",
25-
to: options.emailAddress,
26-
magicLink: options.magicLink,
27-
});
24+
logger.debug("Sending magic link email", { emailAddress: options.emailAddress });
25+
26+
try {
27+
return await client.send({
28+
email: "magic_link",
29+
to: options.emailAddress,
30+
magicLink: options.magicLink,
31+
});
32+
} catch (error) {
33+
logger.error("Error sending magic link email", { error: JSON.stringify(error) });
34+
throw error;
35+
}
2836
}
2937

3038
export async function sendPlainTextEmail(options: SendPlainTextOptions) {

0 commit comments

Comments
 (0)