Replace Logger with getLogger and update next version

This commit replaces the use of Logger with getLogger in various parts of the code to handle logging. The Logger has been replaced with getLogger, which assists in getting logs in an asynchronous manner. In addition to this, it updates the next version in pnpm-lock.yaml from next@14.2.0-canary.61 to next@14.2.0-canary.62 and various other dependencies. Also made minor annotations and comments to the function 'isBrowser' and 'formatCurrency' in the 'utils.ts' file.
This commit is contained in:
giancarlo
2024-04-08 12:23:15 +08:00
parent 2b447167f7
commit 9fca45c2de
33 changed files with 369 additions and 250 deletions

View File

@@ -4,7 +4,7 @@ import { RedirectType, redirect } from 'next/navigation';
import { z } from 'zod';
import { Logger } from '@kit/shared/logger';
import { getLogger } from '@kit/shared/logger';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
@@ -31,7 +31,8 @@ export async function deletePersonalAccountAction(formData: FormData) {
const auth = await requireUser(client);
if (auth.error) {
Logger.error(`User is not authenticated. Redirecting to login page`);
const logger = await getLogger();
logger.error(`User is not authenticated. Redirecting to login page`);
redirect(auth.redirectTo);
}

View File

@@ -1,7 +1,6 @@
import { SupabaseClient } from '@supabase/supabase-js';
import { Mailer } from '@kit/mailers';
import { Logger } from '@kit/shared/logger';
import { getLogger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database';
/**
@@ -35,8 +34,9 @@ export class DeletePersonalAccountService {
};
}) {
const userId = params.userId;
const logger = await getLogger();
Logger.info(
logger.info(
{ name: this.namespace, userId },
'User requested deletion. Processing...',
);
@@ -45,7 +45,7 @@ export class DeletePersonalAccountService {
try {
await params.adminClient.auth.admin.deleteUser(userId);
} catch (error) {
Logger.error(
logger.error(
{
name: this.namespace,
userId,
@@ -60,7 +60,7 @@ export class DeletePersonalAccountService {
// Send account deletion email
if (params.userEmail) {
try {
Logger.info(
logger.info(
{
name: this.namespace,
userId,
@@ -74,8 +74,16 @@ export class DeletePersonalAccountService {
userDisplayName: params.userEmail,
userEmail: params.userEmail,
});
logger.info(
{
name: this.namespace,
userId,
},
`Account deletion email sent`,
);
} catch (error) {
Logger.error(
logger.error(
{
name: this.namespace,
userId,
@@ -94,13 +102,15 @@ export class DeletePersonalAccountService {
productName: string;
}) {
const { renderAccountDeleteEmail } = await import('@kit/email-templates');
const { getMailer } = await import('@kit/mailers');
const mailer = await getMailer();
const html = renderAccountDeleteEmail({
userDisplayName: params.userDisplayName,
productName: params.productName,
});
await Mailer.sendEmail({
return mailer.sendEmail({
to: params.userEmail,
from: params.fromEmail,
subject: 'Account Deletion Request',