diff --git a/packages/services/api/src/modules/billing/providers/billing.provider.ts b/packages/services/api/src/modules/billing/providers/billing.provider.ts index 8fbdbe728..62c0de2ae 100644 --- a/packages/services/api/src/modules/billing/providers/billing.provider.ts +++ b/packages/services/api/src/modules/billing/providers/billing.provider.ts @@ -37,6 +37,7 @@ export class BillingProvider { } upgradeToPro(input: StripeBillingApiInput['createSubscriptionForOrganization']) { + this.logger.debug('Upgrading to PRO (input=%o)', input); if (!this.billingService) { throw new Error(`Billing service is not configured!`); } @@ -53,6 +54,7 @@ export class BillingProvider { } async getAvailablePrices() { + this.logger.debug('Getting available prices'); if (!this.billingService) { return null; } @@ -71,6 +73,7 @@ export class BillingProvider { } getActiveSubscription(input: StripeBillingApiInput['activeSubscription']) { + this.logger.debug('Fetching active subscription (input=%o)', input); if (!this.billingService) { throw new Error(`Billing service is not configured!`); } @@ -79,6 +82,7 @@ export class BillingProvider { } invoices(input: StripeBillingApiInput['invoices']) { + this.logger.debug('Fetching invoices (input=%o)', input); if (!this.billingService) { throw new Error(`Billing service is not configured!`); } @@ -87,6 +91,7 @@ export class BillingProvider { } upcomingInvoice(input: StripeBillingApiInput['upcomingInvoice']) { + this.logger.debug('Fetching upcoming invoices (input=%o)', input); if (!this.billingService) { throw new Error(`Billing service is not configured!`); } @@ -95,6 +100,7 @@ export class BillingProvider { } async downgradeToHobby(input: StripeBillingApiInput['cancelSubscriptionForOrganization']) { + this.logger.debug('Downgrading to Hobby (input=%o)', input); if (!this.billingService) { throw new Error(`Billing service is not configured!`); } diff --git a/packages/services/api/src/modules/rate-limit/resolvers.ts b/packages/services/api/src/modules/rate-limit/resolvers.ts index 3bdaa7b7a..e3b443c22 100644 --- a/packages/services/api/src/modules/rate-limit/resolvers.ts +++ b/packages/services/api/src/modules/rate-limit/resolvers.ts @@ -1,10 +1,12 @@ import { RateLimitProvider } from './providers/rate-limit.provider'; +import { Logger } from './../shared/providers/logger'; import { RateLimitModule } from './__generated__/types'; export const resolvers: RateLimitModule.Resolvers = { Organization: { - rateLimit: async (org, args, { injector }) => { + rateLimit: async (org, _args, { injector }) => { let limitedForOperations = false; + const logger = injector.get(Logger); try { const operationsRateLimit = await injector.get(RateLimitProvider).checkRateLimit({ @@ -13,10 +15,10 @@ export const resolvers: RateLimitModule.Resolvers = { type: 'operations-reporting', }); - console.info('Fetched rate-limit info:', { orgId: org.id, operationsRateLimit }); + logger.debug('Fetched rate-limit info:', { orgId: org.id, operationsRateLimit }); limitedForOperations = operationsRateLimit.limited; } catch (e) { - console.warn('Failed to fetch rate-limit info:', org.id, e); + logger.error('Failed to fetch rate-limit info:', org.id, e); } return { diff --git a/packages/services/server/src/graphql-handler.ts b/packages/services/server/src/graphql-handler.ts index 81bba65da..5aec2b7da 100644 --- a/packages/services/server/src/graphql-handler.ts +++ b/packages/services/server/src/graphql-handler.ts @@ -1,4 +1,9 @@ -import type { RouteHandlerMethod, FastifyRequest, FastifyReply } from 'fastify'; +import type { + RouteHandlerMethod, + FastifyRequest, + FastifyReply, + FastifyLoggerInstance, +} from 'fastify'; import { Registry } from '@hive/api'; import { cleanRequestId } from '@hive/service-common'; import { createYoga, useErrorHandler, Plugin } from 'graphql-yoga'; @@ -46,6 +51,7 @@ export interface GraphQLHandlerOptions { isProduction: boolean; hiveConfig: HiveConfig; release: string; + logger: FastifyLoggerInstance; } export type SuperTokenSessionPayload = zod.TypeOf; @@ -89,6 +95,7 @@ function useNoIntrospection(params: { export const graphqlHandler = (options: GraphQLHandlerOptions): RouteHandlerMethod => { const server = createYoga({ + logging: options.logger, plugins: [ useSentry({ startTransaction: false, diff --git a/packages/services/server/src/index.ts b/packages/services/server/src/index.ts index 7850bf81a..336d0f4ed 100644 --- a/packages/services/server/src/index.ts +++ b/packages/services/server/src/index.ts @@ -241,6 +241,7 @@ export async function main() { isProduction: env.environment === 'prod', release: env.release, hiveConfig: env.hive, + logger: graphqlLogger as any, }); server.route({