fix: structure logged data
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { error } from "console"
|
||||
|
||||
import {
|
||||
GetNavigationMyPages,
|
||||
GetNavigationMyPagesRefs,
|
||||
@@ -61,7 +63,10 @@ export function mapMenuItems(menuItems: MenuItems) {
|
||||
export const navigationQueryRouter = router({
|
||||
get: contentstackBaseProcedure.query(async function ({ ctx }) {
|
||||
const { lang } = ctx
|
||||
console.info("contentstack.myPages.navigation.ref start ", { lang })
|
||||
console.info(
|
||||
"contentstack.myPages.navigation.refs start",
|
||||
JSON.stringify({ query: { lang } })
|
||||
)
|
||||
const refsResponse = await request<GetNavigationMyPagesRefsData>(
|
||||
GetNavigationMyPagesRefs,
|
||||
{ locale: lang },
|
||||
@@ -71,21 +76,36 @@ export const navigationQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
console.error("contentstack.myPages.navigation.ref not found error ", {
|
||||
lang,
|
||||
})
|
||||
console.error(
|
||||
"contentstack.myPages.navigation.refs not found error",
|
||||
JSON.stringify({
|
||||
query: {
|
||||
lang,
|
||||
},
|
||||
error: refsResponse,
|
||||
})
|
||||
)
|
||||
throw notFound(refsResponse)
|
||||
}
|
||||
|
||||
const validatedMyPagesNavigationRefs =
|
||||
navigationRefsPayloadSchema.safeParse(refsResponse.data)
|
||||
if (!validatedMyPagesNavigationRefs.success) {
|
||||
console.error("contentstack.myPages.navigation.ref validation error ", {
|
||||
lang,
|
||||
})
|
||||
console.error(
|
||||
"contentstack.myPages.navigation.refs validation error",
|
||||
JSON.stringify({
|
||||
query: {
|
||||
lang,
|
||||
},
|
||||
error: validatedMyPagesNavigationRefs.error,
|
||||
})
|
||||
)
|
||||
return null
|
||||
}
|
||||
console.info("contentstack.myPages.navigation.ref success ", { lang })
|
||||
console.info(
|
||||
"contentstack.myPages.navigation.refs success",
|
||||
JSON.stringify({ query: { lang } })
|
||||
)
|
||||
const connections = getConnections(validatedMyPagesNavigationRefs.data)
|
||||
|
||||
const tags = [
|
||||
@@ -96,7 +116,10 @@ export const navigationQueryRouter = router({
|
||||
.system.uid
|
||||
),
|
||||
].flat()
|
||||
console.info("contentstack.myPages.navigation start ", { lang })
|
||||
console.info(
|
||||
"contentstack.myPages.navigation start",
|
||||
JSON.stringify({ query: { lang } })
|
||||
)
|
||||
const response = await request<GetNavigationMyPagesData>(
|
||||
GetNavigationMyPages,
|
||||
{ locale: lang },
|
||||
@@ -104,8 +127,11 @@ export const navigationQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
console.error("contentstack.myPages.navigation not found error ", {
|
||||
lang,
|
||||
console.error("contentstack.myPages.navigation not found error", {
|
||||
query: {
|
||||
lang,
|
||||
},
|
||||
error: response,
|
||||
})
|
||||
throw notFound(response)
|
||||
}
|
||||
@@ -115,9 +141,11 @@ export const navigationQueryRouter = router({
|
||||
)
|
||||
if (!validatedMyPagesNavigation.success) {
|
||||
console.error(
|
||||
"contentstack.myPages.navigation validation error ",
|
||||
JSON.stringify({ lang }),
|
||||
JSON.stringify(validatedMyPagesNavigation.error)
|
||||
"contentstack.myPages.navigation.payload validation error",
|
||||
JSON.stringify({
|
||||
query: { lang },
|
||||
error: validatedMyPagesNavigation.error,
|
||||
})
|
||||
)
|
||||
return null
|
||||
}
|
||||
@@ -133,12 +161,20 @@ export const navigationQueryRouter = router({
|
||||
const validatedNav = getNavigationSchema.safeParse(nav)
|
||||
if (!validatedNav.success) {
|
||||
console.error(
|
||||
`Failed to validate My Pages Navigation Return Data - (lang: ${lang}`
|
||||
"contentstack.myPages.navigation validation error",
|
||||
JSON.stringify({
|
||||
query: { lang },
|
||||
error: validatedNav.error,
|
||||
})
|
||||
)
|
||||
|
||||
console.error(validatedNav.error)
|
||||
return null
|
||||
}
|
||||
|
||||
console.info(
|
||||
"contentstack.myPages.navigation success",
|
||||
JSON.stringify({ query: { lang } })
|
||||
)
|
||||
return validatedNav.data
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user