From 4391065030fb38626850376f3d42486b0d8ec458 Mon Sep 17 00:00:00 2001 From: Nicolas Burtey Date: Thu, 21 Sep 2023 11:43:41 +0100 Subject: [PATCH] chore: more debugging for transient_payload --- .gitignore | 1 + .../create-account-from-registration-payload.ts | 9 ++++++++- ...unt-disable-notification-category-for-channel.ts | 2 +- .../account-disable-notification-channel.ts | 2 +- ...ount-enable-notification-category-for-channel.ts | 2 +- .../mutation/account-enable-notification-channel.ts | 2 +- src/servers/event-handlers/kratos.ts | 13 +++++++------ .../get-pending-onchain-balance-for-wallets.spec.ts | 2 +- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index c24385711a..c7c2e22fae 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ junit.xml .next .direnv +.env.local diff --git a/src/app/authentication/create-account-from-registration-payload.ts b/src/app/authentication/create-account-from-registration-payload.ts index f3a9249577..1b0eab5a87 100644 --- a/src/app/authentication/create-account-from-registration-payload.ts +++ b/src/app/authentication/create-account-from-registration-payload.ts @@ -5,7 +5,10 @@ import { RegistrationPayloadValidator } from "@domain/authentication/registratio import { ErrorLevel } from "@domain/shared" import { InvalidPhoneNumber, InvalidUserId } from "@domain/errors" -import { recordExceptionInCurrentSpan } from "@services/tracing" +import { + addAttributesToCurrentSpan, + recordExceptionInCurrentSpan, +} from "@services/tracing" import { SchemaIdType } from "@services/kratos" import { createAccountWithPhoneIdentifier } from "@app/accounts" @@ -21,6 +24,10 @@ export const createAccountFromRegistrationPayload = async ({ schema_id?: string } }): Promise => { + addAttributesToCurrentSpan({ + "registration.body": JSON.stringify(body), + }) + const isValidKey = CallbackSecretValidator(KRATOS_CALLBACK_API_KEY).authorize(secret) if (isValidKey instanceof Error) { return isValidKey diff --git a/src/graphql/public/root/mutation/account-disable-notification-category-for-channel.ts b/src/graphql/public/root/mutation/account-disable-notification-category-for-channel.ts index 0a551e35bd..274faab7c2 100644 --- a/src/graphql/public/root/mutation/account-disable-notification-category-for-channel.ts +++ b/src/graphql/public/root/mutation/account-disable-notification-category-for-channel.ts @@ -1,7 +1,7 @@ import { GT } from "@graphql/index" import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings" -import { Accounts } from "@app/index" +import { Accounts } from "@app" import { mapAndParseErrorForGqlResponse } from "@graphql/error-map" import NotificationChannel from "@graphql/shared/types/scalar/notification-channel" import NotificationCategory from "@graphql/shared/types/scalar/notification-category" diff --git a/src/graphql/public/root/mutation/account-disable-notification-channel.ts b/src/graphql/public/root/mutation/account-disable-notification-channel.ts index 52fcbfc49e..40c06977de 100644 --- a/src/graphql/public/root/mutation/account-disable-notification-channel.ts +++ b/src/graphql/public/root/mutation/account-disable-notification-channel.ts @@ -1,7 +1,7 @@ import { GT } from "@graphql/index" import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings" -import { Accounts } from "@app/index" +import { Accounts } from "@app" import { mapAndParseErrorForGqlResponse } from "@graphql/error-map" import NotificationChannel from "@graphql/shared/types/scalar/notification-channel" diff --git a/src/graphql/public/root/mutation/account-enable-notification-category-for-channel.ts b/src/graphql/public/root/mutation/account-enable-notification-category-for-channel.ts index f0b309e3a4..c52cd3d89c 100644 --- a/src/graphql/public/root/mutation/account-enable-notification-category-for-channel.ts +++ b/src/graphql/public/root/mutation/account-enable-notification-category-for-channel.ts @@ -1,7 +1,7 @@ import { GT } from "@graphql/index" import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings" -import { Accounts } from "@app/index" +import { Accounts } from "@app" import { mapAndParseErrorForGqlResponse } from "@graphql/error-map" import NotificationChannel from "@graphql/shared/types/scalar/notification-channel" import NotificationCategory from "@graphql/shared/types/scalar/notification-category" diff --git a/src/graphql/public/root/mutation/account-enable-notification-channel.ts b/src/graphql/public/root/mutation/account-enable-notification-channel.ts index 3102a2656d..5cd1372054 100644 --- a/src/graphql/public/root/mutation/account-enable-notification-channel.ts +++ b/src/graphql/public/root/mutation/account-enable-notification-channel.ts @@ -1,7 +1,7 @@ import { GT } from "@graphql/index" import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings" -import { Accounts } from "@app/index" +import { Accounts } from "@app" import { mapAndParseErrorForGqlResponse } from "@graphql/error-map" import NotificationChannel from "@graphql/shared/types/scalar/notification-channel" diff --git a/src/servers/event-handlers/kratos.ts b/src/servers/event-handlers/kratos.ts index f115397faf..757856e127 100644 --- a/src/servers/event-handlers/kratos.ts +++ b/src/servers/event-handlers/kratos.ts @@ -1,10 +1,11 @@ import cors from "cors" import express from "express" -import { addAttributesToCurrentSpan, wrapAsyncToRunInSpan } from "@services/tracing" +import { wrapAsyncToRunInSpan } from "@services/tracing" import { baseLogger } from "@services/logger" -import { createAccountFromRegistrationPayload } from "@app/authentication" +import { Authentication } from "@app" + import { SecretForAuthNCallbackError, RegistrationPayloadValidationError, @@ -31,11 +32,11 @@ kratosCallback.post( fn: async (req: express.Request, res: express.Response) => { const secret = req.headers.authorization const body = req.body - addAttributesToCurrentSpan({ - "registration.body": JSON.stringify(body), - }) - const account = await createAccountFromRegistrationPayload({ secret, body }) + const account = await Authentication.createAccountFromRegistrationPayload({ + secret, + body, + }) if (account instanceof Error) { const message = errorResponseMessages[account.name] || "unknown error" switch (true) { diff --git a/test/integration/app/wallets/get-pending-onchain-balance-for-wallets.spec.ts b/test/integration/app/wallets/get-pending-onchain-balance-for-wallets.spec.ts index 086137ba2e..54a877d215 100644 --- a/test/integration/app/wallets/get-pending-onchain-balance-for-wallets.spec.ts +++ b/test/integration/app/wallets/get-pending-onchain-balance-for-wallets.spec.ts @@ -1,4 +1,4 @@ -import { Wallets } from "@app/index" +import { Wallets } from "@app" import { ZERO_SATS } from "@domain/shared" import { MultipleCurrenciesForSingleCurrencyOperationError } from "@domain/errors"