Merged in fix/improve-sas-error-logging (pull request #1854)

Improve SAS flow logging

* Improve logging


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-04-24 12:30:34 +00:00
parent 169094fc37
commit b354398c69
4 changed files with 12 additions and 9 deletions

View File

@@ -73,10 +73,8 @@ export default function OneTimePasswordForm({
switch (requestOtp.data?.status) {
case "ABUSED":
router.push(`/${params.lang}/sas-x-scandic/error?errorCode=tooManyCodes`)
return <Loading />
case "NOTSENT":
router.push(`/${params.lang}/sas-x-scandic/error`)
router.push(`/${params.lang}/sas-x-scandic/error?errorCode=tooManyCodes`)
return <Loading />
case "NULL":
case "RETRY":

View File

@@ -1,3 +1,4 @@
import * as Sentry from "@sentry/nextjs"
import { z } from "zod"
import * as api from "@/lib/api"
@@ -59,9 +60,9 @@ export const linkAccount = protectedProcedure
return { linkingState: "alreadyLinked" }
}
console.log(
`[SAS] link account error with status code ${apiResponse.status} and response ${await apiResponse.text()}`
)
const errorMessage = `[SAS] link account error with status code ${apiResponse.status} and response ${await apiResponse.text()}`
console.warn(errorMessage)
Sentry.captureMessage(errorMessage)
return { linkingState: "error" }
})

View File

@@ -1,3 +1,4 @@
import * as Sentry from "@sentry/nextjs"
import { TRPCError } from "@trpc/server"
import { cookies } from "next/headers"
import { v4 as uuidv4 } from "uuid"
@@ -43,7 +44,6 @@ export const requestOtp = protectedProcedure
const sasAuthToken = getSasToken()
if (!sasAuthToken) {
// TODO: Should we verify that the SAS token isn't expired?
throw createError("AUTH_TOKEN_NOT_FOUND")
}
@@ -67,6 +67,10 @@ export const requestOtp = protectedProcedure
if (parseResult.data.status === "SENT") {
setSASOtpCookie(parseResult.data)
} else {
const sasRequestOtpErrorMessage = `[SAS] requestOtp did not return SENT status with body: ${body}`
console.warn(sasRequestOtpErrorMessage)
Sentry.captureMessage(sasRequestOtpErrorMessage)
}
return parseResult.data

View File

@@ -71,13 +71,13 @@ export const performLevelUpgrade = protectedProcedure
if (notLinked) {
const tierMatchErrorNotLinkedMessage =
"[SAS] tier match error - not linked"
console.log(tierMatchErrorNotLinkedMessage)
console.warn(tierMatchErrorNotLinkedMessage)
Sentry.captureMessage(tierMatchErrorNotLinkedMessage)
return { tierMatchState: "notLinked" }
}
const tierMatchErrorMessage = `[SAS] tier match error with status code ${apiResponse.status} and response ${await apiResponse.text()}`
console.log(tierMatchErrorMessage)
console.error(tierMatchErrorMessage)
Sentry.captureException(new Error(tierMatchErrorMessage))
return { tierMatchState: "error" }
})