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:
@@ -5,7 +5,7 @@ import { z } from 'zod';
|
||||
|
||||
import { getProductPlanPair } from '@kit/billing';
|
||||
import { getBillingGatewayProvider } from '@kit/billing-gateway';
|
||||
import { Logger } from '@kit/shared/logger';
|
||||
import { getLogger } from '@kit/shared/logger';
|
||||
import { Database } from '@kit/supabase/database';
|
||||
import { requireUser } from '@kit/supabase/require-user';
|
||||
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
||||
@@ -51,8 +51,9 @@ export class UserBillingService {
|
||||
}
|
||||
|
||||
const { plan } = getProductPlanPair(billingConfig, planId);
|
||||
const logger = await getLogger();
|
||||
|
||||
Logger.info(
|
||||
logger.info(
|
||||
{
|
||||
name: `billing.personal-account`,
|
||||
planId,
|
||||
@@ -73,7 +74,7 @@ export class UserBillingService {
|
||||
variantQuantities: [],
|
||||
});
|
||||
|
||||
Logger.info(
|
||||
logger.info(
|
||||
{
|
||||
userId: user.id,
|
||||
},
|
||||
@@ -86,7 +87,7 @@ export class UserBillingService {
|
||||
checkoutToken,
|
||||
};
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
logger.error(
|
||||
{
|
||||
name: `billing.personal-account`,
|
||||
planId,
|
||||
@@ -118,7 +119,9 @@ export class UserBillingService {
|
||||
throw new Error('Customer not found');
|
||||
}
|
||||
|
||||
Logger.info(
|
||||
const logger = await getLogger();
|
||||
|
||||
logger.info(
|
||||
{
|
||||
name: `billing.personal-account`,
|
||||
customerId,
|
||||
@@ -137,7 +140,7 @@ export class UserBillingService {
|
||||
|
||||
url = session.url;
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
logger.error(
|
||||
{
|
||||
error,
|
||||
customerId,
|
||||
@@ -151,7 +154,7 @@ export class UserBillingService {
|
||||
);
|
||||
}
|
||||
|
||||
Logger.info(
|
||||
logger.info(
|
||||
{
|
||||
name: `billing.personal-account`,
|
||||
customerId,
|
||||
@@ -167,6 +170,14 @@ export class UserBillingService {
|
||||
|
||||
async function getCustomerIdFromAccountId(accountId: string) {
|
||||
const client = getSupabaseServerActionClient();
|
||||
const logger = await getLogger();
|
||||
|
||||
logger.info(
|
||||
{
|
||||
accountId,
|
||||
},
|
||||
`Getting customer ID for account ${accountId}...`,
|
||||
);
|
||||
|
||||
const { data, error } = await client
|
||||
.from('billing_customers')
|
||||
@@ -175,6 +186,14 @@ async function getCustomerIdFromAccountId(accountId: string) {
|
||||
.maybeSingle();
|
||||
|
||||
if (error) {
|
||||
logger.error(
|
||||
{
|
||||
accountId,
|
||||
error,
|
||||
},
|
||||
`Failed to get customer ID`,
|
||||
);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { z } from 'zod';
|
||||
|
||||
import { LineItemSchema } from '@kit/billing';
|
||||
import { getBillingGatewayProvider } from '@kit/billing-gateway';
|
||||
import { Logger } from '@kit/shared/logger';
|
||||
import { getLogger } from '@kit/shared/logger';
|
||||
import { Database } from '@kit/supabase/database';
|
||||
import { requireUser } from '@kit/supabase/require-user';
|
||||
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
||||
@@ -35,8 +35,9 @@ export class TeamBillingService {
|
||||
|
||||
const userId = user.id;
|
||||
const accountId = params.accountId;
|
||||
const logger = await getLogger();
|
||||
|
||||
Logger.info(
|
||||
logger.info(
|
||||
{
|
||||
userId,
|
||||
accountId,
|
||||
@@ -54,7 +55,7 @@ export class TeamBillingService {
|
||||
// if the user does not have permission to manage billing for the account
|
||||
// then we should not proceed
|
||||
if (!hasPermission) {
|
||||
Logger.warn(
|
||||
logger.warn(
|
||||
{
|
||||
userId,
|
||||
accountId,
|
||||
@@ -90,7 +91,7 @@ export class TeamBillingService {
|
||||
accountId,
|
||||
);
|
||||
|
||||
Logger.info(
|
||||
logger.info(
|
||||
{
|
||||
userId,
|
||||
accountId,
|
||||
@@ -117,7 +118,7 @@ export class TeamBillingService {
|
||||
checkoutToken,
|
||||
};
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
logger.error(
|
||||
{
|
||||
name: this.namespace,
|
||||
error,
|
||||
@@ -145,8 +146,9 @@ export class TeamBillingService {
|
||||
slug: string;
|
||||
}) {
|
||||
const client = getSupabaseServerActionClient();
|
||||
const logger = await getLogger();
|
||||
|
||||
Logger.info(
|
||||
logger.info(
|
||||
{
|
||||
accountId,
|
||||
name: this.namespace,
|
||||
@@ -171,7 +173,7 @@ export class TeamBillingService {
|
||||
// if the user does not have permission to manage billing for the account
|
||||
// then we should not proceed
|
||||
if (!hasPermission) {
|
||||
Logger.warn(
|
||||
logger.warn(
|
||||
{
|
||||
userId,
|
||||
accountId,
|
||||
@@ -190,7 +192,7 @@ export class TeamBillingService {
|
||||
throw new Error('Customer not found');
|
||||
}
|
||||
|
||||
Logger.info(
|
||||
logger.info(
|
||||
{
|
||||
userId,
|
||||
customerId,
|
||||
@@ -211,7 +213,7 @@ export class TeamBillingService {
|
||||
// redirect the user to the billing portal
|
||||
return url;
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
logger.error(
|
||||
{
|
||||
userId,
|
||||
customerId,
|
||||
@@ -260,7 +262,9 @@ export class TeamBillingService {
|
||||
.eq('account_id', accountId);
|
||||
|
||||
if (error) {
|
||||
Logger.error(
|
||||
const logger = await getLogger();
|
||||
|
||||
logger.error(
|
||||
{
|
||||
accountId,
|
||||
error,
|
||||
|
||||
@@ -68,7 +68,7 @@ async function ReturnCheckoutSessionPage({ searchParams }: SessionPageProps) {
|
||||
|
||||
export default withI18n(ReturnCheckoutSessionPage);
|
||||
|
||||
export async function loadCheckoutSession(sessionId: string) {
|
||||
async function loadCheckoutSession(sessionId: string) {
|
||||
const client = getSupabaseServerComponentClient();
|
||||
const { error } = await requireUser(client);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user