diff --git a/.gitignore b/.gitignore index 0bd4a1372..f99f2decb 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,6 @@ apps/**/generated # bruno cloud.bru + + +analyze \ No newline at end of file diff --git a/apps/avatax/package.json b/apps/avatax/package.json index ffa678582..c7aa4c635 100644 --- a/apps/avatax/package.json +++ b/apps/avatax/package.json @@ -52,6 +52,7 @@ "@trpc/react-query": "10.43.1", "@trpc/server": "10.43.1", "@urql/exchange-auth": "^2.1.4", + "@vercel/functions": "1.0.2", "avatax": "^23.7.0", "dotenv": "^16.3.1", "graphql": "16.7.1", diff --git a/apps/avatax/src/lib/app-config.test.ts b/apps/avatax/src/lib/app-config.test.ts index c1b6dfda1..aeb9dbc10 100644 --- a/apps/avatax/src/lib/app-config.test.ts +++ b/apps/avatax/src/lib/app-config.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from "vitest"; +import { describe, expect, it } from "vitest"; import { AppConfig } from "./app-config"; describe("AppConfig", () => { @@ -50,6 +50,10 @@ describe("AppConfig", () => { isAutocommit: false, isDocumentRecordingEnabled: false, shippingTaxCode: "123", + logsSettings: { + otel: {}, + json: {}, + }, }, }, ], @@ -118,6 +122,10 @@ describe("AppConfig", () => { isAutocommit: false, isDocumentRecordingEnabled: false, shippingTaxCode: "123", + logsSettings: { + otel: {}, + json: {}, + }, }, }, ], diff --git a/apps/avatax/src/lib/app-configuration-logger.test.ts b/apps/avatax/src/lib/app-configuration-logger.test.ts index 4eaca4691..293342b8b 100644 --- a/apps/avatax/src/lib/app-configuration-logger.test.ts +++ b/apps/avatax/src/lib/app-configuration-logger.test.ts @@ -1,7 +1,7 @@ -import { describe, it, expect, vi, beforeEach } from "vitest"; -import { AppConfigurationLogger } from "./app-configuration-logger"; -import { AppConfig } from "./app-config"; import { ObservabilityAttributes } from "@saleor/apps-otel/src/lib/observability-attributes"; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { AppConfig } from "./app-config"; +import { AppConfigurationLogger } from "./app-configuration-logger"; describe("AppConfigurationLogger", () => { const mockWarn = vi.fn(); @@ -72,6 +72,10 @@ describe("AppConfigurationLogger", () => { isAutocommit: false, isDocumentRecordingEnabled: false, shippingTaxCode: "123", + logsSettings: { + otel: {}, + json: {}, + }, }, }, ], diff --git a/apps/avatax/src/modules/app/get-app-config.test.ts b/apps/avatax/src/modules/app/get-app-config.test.ts index 47443f5e4..ff460c342 100644 --- a/apps/avatax/src/modules/app/get-app-config.test.ts +++ b/apps/avatax/src/modules/app/get-app-config.test.ts @@ -1,9 +1,9 @@ import { encrypt } from "@saleor/app-sdk/settings-manager"; -import { getAppConfig } from "./get-app-config"; import { describe, expect, it, vi } from "vitest"; -import { ProviderConnections } from "../provider-connections/provider-connections"; import { MetadataItem } from "../../../generated/graphql"; import { ChannelsConfig } from "../channel-configuration/channel-config"; +import { ProviderConnections } from "../provider-connections/provider-connections"; +import { getAppConfig } from "./get-app-config"; const mockedSecretKey = "test_secret_key"; const mockedProviders: ProviderConnections = [ @@ -28,6 +28,10 @@ const mockedProviders: ProviderConnections = [ street: "123 Main St", zip: "10001", }, + logsSettings: { + otel: {}, + json: {}, + }, }, }, ]; diff --git a/apps/avatax/src/modules/avatax/avatax-config-mock-generator.ts b/apps/avatax/src/modules/avatax/avatax-config-mock-generator.ts index 934a5bdb0..7f38383e5 100644 --- a/apps/avatax/src/modules/avatax/avatax-config-mock-generator.ts +++ b/apps/avatax/src/modules/avatax/avatax-config-mock-generator.ts @@ -18,6 +18,10 @@ const defaultAvataxConfig: AvataxConfig = { password: "password", username: "username", }, + logsSettings: { + otel: {}, + json: {}, + }, }; const testingScenariosMap = { diff --git a/apps/avatax/src/modules/avatax/avatax-connection-schema.ts b/apps/avatax/src/modules/avatax/avatax-connection-schema.ts index 3583c4880..c5013c501 100644 --- a/apps/avatax/src/modules/avatax/avatax-connection-schema.ts +++ b/apps/avatax/src/modules/avatax/avatax-connection-schema.ts @@ -29,6 +29,18 @@ export const avataxConfigSchema = z shippingTaxCode: z.string().optional(), isDocumentRecordingEnabled: z.boolean().default(true), address: addressSchema, + logsSettings: z.object({ + otel: z.object({ + enabled: z.boolean().optional(), + url: z.string().optional(), + headers: z.string().optional(), + }), + json: z.object({ + enabled: z.boolean().optional(), + url: z.string().optional(), + headers: z.string().optional(), + }), + }), }) .merge(baseAvataxConfigSchema); @@ -52,6 +64,18 @@ export const defaultAvataxConfig: AvataxConfig = { street: "", zip: "", }, + logsSettings: { + otel: { + enabled: false, + url: "", + headers: "", + }, + json: { + enabled: false, + url: "", + headers: "", + }, + }, }; export const avataxConnectionSchema = z.object({ diff --git a/apps/avatax/src/modules/avatax/configuration/avatax-connection.service.ts b/apps/avatax/src/modules/avatax/configuration/avatax-connection.service.ts index d6d3cf3f2..48c586f53 100644 --- a/apps/avatax/src/modules/avatax/configuration/avatax-connection.service.ts +++ b/apps/avatax/src/modules/avatax/configuration/avatax-connection.service.ts @@ -78,6 +78,10 @@ export class AvataxConnectionService { ...prevConfig.address, ...nextConfigPartial.address, }, + logsSettings: { + ...prevConfig.logsSettings, + ...nextConfigPartial.logsSettings, + }, }; await this.checkIfAuthorized(input); diff --git a/apps/avatax/src/modules/avatax/ui/avatax-configuration-form.tsx b/apps/avatax/src/modules/avatax/ui/avatax-configuration-form.tsx index 35f5a4e6a..4208a1b04 100644 --- a/apps/avatax/src/modules/avatax/ui/avatax-configuration-form.tsx +++ b/apps/avatax/src/modules/avatax/ui/avatax-configuration-form.tsx @@ -17,6 +17,7 @@ import { AvataxConfigurationCredentialsFragment } from "./avatax-configuration-c import { AvataxConfigurationSettingsFragment } from "./avatax-configuration-settings-fragment"; import { useAvataxConfigurationStatus } from "./configuration-status"; import { HelperText } from "./form-helper-text"; +import { LogsSettingsFragment } from "./logs-settings-fragment"; type AvataxConfigurationFormProps = { submit: { @@ -83,6 +84,8 @@ export const AvataxConfigurationForm = (props: AvataxConfigurationFormProps) => isLoading={props.validateAddress.isLoading} /> + + {props.leftButton} diff --git a/apps/avatax/src/modules/avatax/ui/edit-avatax-configuration.tsx b/apps/avatax/src/modules/avatax/ui/edit-avatax-configuration.tsx index 429109230..8bd048507 100644 --- a/apps/avatax/src/modules/avatax/ui/edit-avatax-configuration.tsx +++ b/apps/avatax/src/modules/avatax/ui/edit-avatax-configuration.tsx @@ -4,8 +4,8 @@ import { useRouter } from "next/router"; import React from "react"; import { z } from "zod"; import { trpcClient } from "../../trpc/trpc-client"; -import { AvataxObfuscator } from "../avatax-obfuscator"; import { AvataxConfig, BaseAvataxConfig } from "../avatax-connection-schema"; +import { AvataxObfuscator } from "../avatax-obfuscator"; import { AvataxConfigurationForm } from "./avatax-configuration-form"; import { useAvataxConfigurationStatus } from "./configuration-status"; @@ -141,6 +141,8 @@ export const EditAvataxConfiguration = () => { ); } + console.log("config", data.config); + return ( { + const { control, formState } = useFormContext(); + const isOtelTogleEnabled = useWatch({ + control, + name: "logsSettings.otel.enabled", + }); + const isJSONTogleEnabled = useWatch({ + control, + name: "logsSettings.json.enabled", + }); + + return ( + <> + + + Logs settings + + + + Configure where AvaTax should emit logs. This is useful for debugging and + troubleshooting connection issues. + + Enable sending logs using OpenTelemetry protocol.} + /> + + + ( +