From f8d60afb49450e887e1e3604214044c123017bc6 Mon Sep 17 00:00:00 2001 From: Michael Zetterberg Date: Mon, 26 Aug 2024 15:30:27 +0200 Subject: [PATCH] debug: debug profile calls --- server/routers/user/query.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/server/routers/user/query.ts b/server/routers/user/query.ts index 90bae8b0c..b983e8439 100644 --- a/server/routers/user/query.ts +++ b/server/routers/user/query.ts @@ -90,7 +90,7 @@ async function getVerifiedUser({ session }: { session: Session }) { return { error: true, cause: "token_expired" } as const } getVerifiedUserCounter.add(1) - console.info("api.user.profile start", JSON.stringify({})) + console.info("api.user.profile getVerifiedUser start", JSON.stringify({})) const apiResponse = await api.get(api.endpoints.v1.profile, { cache: "no-store", headers: { @@ -109,9 +109,10 @@ async function getVerifiedUser({ session }: { session: Session }) { }), }) console.error( - "api.user.profile error", + "api.user.profile getVerifiedUser error", JSON.stringify({ error: { + token: session.token.access_token, status: apiResponse.status, statusText: apiResponse.statusText, text, @@ -135,7 +136,10 @@ async function getVerifiedUser({ session }: { session: Session }) { const apiJson = await apiResponse.json() if (!apiJson.data?.attributes) { getVerifiedUserFailCounter.add(1, { error_type: "data_error" }) - console.error("api.user.profile data error", JSON.stringify({})) // not passing the data to avoid logging sensitive data + console.error( + "api.user.profile getVerifiedUser data error", + JSON.stringify({}) + ) // not passing the data to avoid logging sensitive data return null } @@ -154,7 +158,7 @@ async function getVerifiedUser({ session }: { session: Session }) { return null } getVerifiedUserSuccessCounter.add(1) - console.info("api.user.profile success", JSON.stringify({})) + console.info("api.user.profile getVerifiedUser success", JSON.stringify({})) return verifiedData } @@ -185,7 +189,7 @@ async function updateStaysBookingUrl( ) { // Tenporary API call needed till we have user name in ctx session data getProfileCounter.add(1) - console.info("api.user.profile start", JSON.stringify({})) + console.info("api.user.profile updatebookingurl start", JSON.stringify({})) const apiResponse = await api.get(api.endpoints.v1.profile, { cache: "no-store", headers: { @@ -223,7 +227,10 @@ async function updateStaysBookingUrl( if (apiResponse.ok) { getProfileSuccessCounter.add(1) - console.info("api.user.profile success", JSON.stringify({})) + console.info( + "api.user.profile updatebookingurl success", + JSON.stringify({}) + ) const apiJson = await apiResponse.json() if (apiJson.data?.attributes) { return data.map((d) => { @@ -250,7 +257,10 @@ async function updateStaysBookingUrl( } } getProfileFailCounter.add(1, { error: JSON.stringify(apiResponse) }) - console.info("api.user.profile error", JSON.stringify({ error: apiResponse })) + console.info( + "api.user.profile updatebookingurl error", + JSON.stringify({ error: apiResponse }) + ) return data }