diff --git a/.changeset/perfect-cobras-do.md b/.changeset/perfect-cobras-do.md new file mode 100644 index 000000000..4f3c62e3f --- /dev/null +++ b/.changeset/perfect-cobras-do.md @@ -0,0 +1,5 @@ +--- +"app-avatax": patch +--- + +Debugging: Disable importing dynamodb in checkout_calculate_taxes. This will disable logs feature even if flag is enabled diff --git a/apps/avatax/src/modules/client-logs/dynamo-log-writer.ts b/apps/avatax/src/modules/client-logs/dynamo-log-writer.ts new file mode 100644 index 000000000..e8c1e71ec --- /dev/null +++ b/apps/avatax/src/modules/client-logs/dynamo-log-writer.ts @@ -0,0 +1,22 @@ +import { ClientLogStoreRequest } from "@/modules/client-logs/client-log"; +import { ILogWriter, LogWriterContext } from "@/modules/client-logs/log-writer"; +import { ILogsRepository } from "@/modules/client-logs/logs-repository"; + +export class DynamoDbLogWriter implements ILogWriter { + constructor( + private repo: ILogsRepository, + private context: LogWriterContext, + ) { + if (!repo) { + throw new Error("Repository is nullish"); + } + } + + writeLog = async (log: ClientLogStoreRequest): Promise => { + await this.repo.writeLog({ + appId: this.context.appId, + saleorApiUrl: this.context.saleorApiUrl, + clientLogRequest: log, + }); + }; +} diff --git a/apps/avatax/src/modules/client-logs/log-writer-factory.ts b/apps/avatax/src/modules/client-logs/log-writer-factory.ts index 431616c5c..704e0a48d 100644 --- a/apps/avatax/src/modules/client-logs/log-writer-factory.ts +++ b/apps/avatax/src/modules/client-logs/log-writer-factory.ts @@ -3,14 +3,11 @@ import { createLogsDocumentClient, createLogsDynamoClient, } from "@/modules/client-logs/dynamo-client"; +import { DynamoDbLogWriter } from "@/modules/client-logs/dynamo-log-writer"; import { ClientLogDynamoEntityFactory, LogsTable } from "@/modules/client-logs/dynamo-schema"; -import { - DynamoDbLogWriter, - ILogWriter, - LogWriterContext, - NoopLogWriter, -} from "@/modules/client-logs/log-writer"; +import { ILogWriter, LogWriterContext } from "@/modules/client-logs/log-writer"; import { LogsRepositoryDynamodb } from "@/modules/client-logs/logs-repository"; +import { NoopLogWriter } from "@/modules/client-logs/noop-log-writer"; export interface ILogWriterFactory { createWriter(context: LogWriterContext): ILogWriter; diff --git a/apps/avatax/src/modules/client-logs/log-writer.ts b/apps/avatax/src/modules/client-logs/log-writer.ts index 7290d83ce..b151de2c2 100644 --- a/apps/avatax/src/modules/client-logs/log-writer.ts +++ b/apps/avatax/src/modules/client-logs/log-writer.ts @@ -1,36 +1,7 @@ import { ClientLogStoreRequest } from "@/modules/client-logs/client-log"; -import { ILogsRepository } from "@/modules/client-logs/logs-repository"; export type LogWriterContext = { appId: string; saleorApiUrl: string }; export interface ILogWriter { writeLog(log: ClientLogStoreRequest): Promise; } - -export class DynamoDbLogWriter implements ILogWriter { - constructor( - private repo: ILogsRepository, - private context: LogWriterContext, - ) { - if (!repo) { - throw new Error("Repository is nullish"); - } - } - - writeLog = async (log: ClientLogStoreRequest): Promise => { - await this.repo.writeLog({ - appId: this.context.appId, - saleorApiUrl: this.context.saleorApiUrl, - clientLogRequest: log, - }); - }; -} - -/** - * Just no-op. For testing or if feature is disabled - */ -export class NoopLogWriter implements ILogWriter { - async writeLog(log: ClientLogStoreRequest): Promise { - return; - } -} diff --git a/apps/avatax/src/modules/client-logs/noop-log-writer.ts b/apps/avatax/src/modules/client-logs/noop-log-writer.ts new file mode 100644 index 000000000..e30b8e0fe --- /dev/null +++ b/apps/avatax/src/modules/client-logs/noop-log-writer.ts @@ -0,0 +1,11 @@ +import { ClientLogStoreRequest } from "@/modules/client-logs/client-log"; +import { ILogWriter } from "@/modules/client-logs/log-writer"; + +/** + * Just no-op. For testing or if feature is disabled + */ +export class NoopLogWriter implements ILogWriter { + async writeLog(log: ClientLogStoreRequest): Promise { + return; + } +} diff --git a/apps/avatax/src/pages/api/webhooks/checkout-calculate-taxes.ts b/apps/avatax/src/pages/api/webhooks/checkout-calculate-taxes.ts index 1ec17372d..98cf67511 100644 --- a/apps/avatax/src/pages/api/webhooks/checkout-calculate-taxes.ts +++ b/apps/avatax/src/pages/api/webhooks/checkout-calculate-taxes.ts @@ -11,10 +11,8 @@ import { SubscriptionPayloadErrorChecker } from "@/lib/error-utils"; import { createLogger } from "@/logger"; import { loggerContext } from "@/logger-context"; import { CalculateTaxesUseCase } from "@/modules/calculate-taxes/use-case/calculate-taxes.use-case"; -import { clientLogsFeatureConfig } from "@/modules/client-logs/client-logs-feature-config"; -import { DynamoDbLogWriter, ILogWriter, NoopLogWriter } from "@/modules/client-logs/log-writer"; -import { LogWriterFactory } from "@/modules/client-logs/log-writer-factory"; -import { LogsRepositoryDynamodb } from "@/modules/client-logs/logs-repository"; +import { ILogWriter, LogWriterContext } from "@/modules/client-logs/log-writer"; +import { NoopLogWriter } from "@/modules/client-logs/noop-log-writer"; import { AvataxInvalidAddressError } from "@/modules/taxes/tax-error"; import { checkoutCalculateTaxesSyncWebhook } from "@/modules/webhooks/definitions/checkout-calculate-taxes"; @@ -31,7 +29,12 @@ const withMetadataCache = wrapWithMetadataCache(metadataCache); const subscriptionErrorChecker = new SubscriptionPayloadErrorChecker(logger, captureException); const useCase = new CalculateTaxesUseCase({ configExtractor: new AppConfigExtractor(), - logWriterFactory: new LogWriterFactory(), + logWriterFactory: { + createWriter(context: LogWriterContext): ILogWriter { + // temp - until we fix + return new NoopLogWriter(); + }, + }, }); /**