Skip to content

Commit e10f202

Browse files
committed
fix: logs
1 parent f7facc3 commit e10f202

File tree

2 files changed

+7
-46
lines changed

2 files changed

+7
-46
lines changed

apps/dashboard/next.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const nextConfig: NextConfig = {
3131
},
3232
],
3333
},
34-
serverExternalPackages: ["pg", "pg-pool"],
34+
serverExternalPackages: ["pg", "pg-pool", "pino", "pino-pretty", "@axiomhq/pino", "thread-stream"],
35+
transpilePackages: [],
3536
output: "standalone",
3637
};
3738

packages/auth/src/auth.ts

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
VerificationEmail,
88
} from "@databuddy/email";
99
import { getRedisCache } from "@databuddy/redis";
10-
import { logger } from "@databuddy/shared/logger";
1110
import { betterAuth } from "better-auth";
1211

1312
import { drizzleAdapter } from "better-auth/adapters/drizzle";
@@ -32,15 +31,7 @@ export const auth = betterAuth({
3231
databaseHooks: {
3332
user: {
3433
create: {
35-
after: async (user: { id: string; name: string; email: string }) => {
36-
logger.info(
37-
{
38-
userId: user.id,
39-
userName: user.name,
40-
userEmail: user.email,
41-
},
42-
"User Created"
43-
);
34+
after: async () => {
4435
// const resend = new Resend(process.env.RESEND_API_KEY as string);
4536
// await resend.emails.send({
4637
// from: "Databuddy <[email protected]>",
@@ -56,50 +47,30 @@ export const auth = betterAuth({
5647
deleteUser: {
5748
enabled: true,
5849
beforeDelete: async (user) => {
59-
logger.info(
60-
"User Deletion Started",
61-
`Starting deletion process for user ${user.id}`
62-
);
63-
6450
try {
6551
const userWebsites = await db.query.websites.findMany({
6652
where: eq(websites.userId, user.id),
6753
});
6854

6955
if (userWebsites.length > 0) {
70-
logger.info(
71-
"Deleting Websites",
72-
`Deleting websites for user ${user.id}`
73-
);
7456
await db.delete(websites).where(
7557
inArray(
7658
websites.id,
7759
userWebsites.map((w) => w.id)
7860
)
7961
);
8062
}
81-
logger.info(
82-
"User Deletion Finished",
83-
`Finished deletion process for user ${user.id}`
84-
);
8563
} catch (error) {
86-
logger.exception(error as Error, { user: user.id });
64+
console.error(error);
8765
}
8866
},
8967
},
9068
},
9169
appName: "databuddy.cc",
9270
onAPIError: {
9371
throw: false,
94-
onError: (error, ctx) => {
95-
if (error instanceof Error) {
96-
logger.exception(error, ctx as Record<string, unknown>);
97-
} else {
98-
logger.error("Auth API Error", "An unknown error occurred", {
99-
error,
100-
...(ctx as Record<string, unknown>),
101-
});
102-
}
72+
onError: (error) => {
73+
console.error(error);
10374
},
10475
errorURL: "/auth/error",
10576
},
@@ -153,10 +124,6 @@ export const auth = betterAuth({
153124
user: any;
154125
url: string;
155126
}) => {
156-
logger.info(
157-
"Email Verification",
158-
`Sending verification email to ${user.email}`
159-
);
160127
const resend = new Resend(process.env.RESEND_API_KEY as string);
161128
await resend.emails.send({
162129
@@ -190,8 +157,7 @@ export const auth = betterAuth({
190157
},
191158
plugins: [
192159
emailOTP({
193-
async sendVerificationOTP({ email, otp, type }) {
194-
logger.info("Email OTP", `Sending OTP to ${email} of type ${type}`);
160+
async sendVerificationOTP({ email, otp }) {
195161
const resend = new Resend(process.env.RESEND_API_KEY as string);
196162
await resend.emails.send({
197163
@@ -203,7 +169,6 @@ export const auth = betterAuth({
203169
}),
204170
magicLink({
205171
sendMagicLink: async ({ email, url }) => {
206-
logger.info("Magic Link", `Sending magic link to ${email}`);
207172
const resend = new Resend(process.env.RESEND_API_KEY as string);
208173
await resend.emails.send({
209174
@@ -247,11 +212,6 @@ export const auth = betterAuth({
247212
organization,
248213
invitation,
249214
}) => {
250-
logger.info(
251-
"Organization Invitation",
252-
`Inviting ${email} to ${organization.name}`,
253-
{ inviter: inviter.user.name, organizationId: organization.id }
254-
);
255215
const invitationLink = `https://app.databuddy.cc/invitations/${invitation.id}`;
256216
const resend = new Resend(process.env.RESEND_API_KEY as string);
257217
await resend.emails.send({

0 commit comments

Comments
 (0)