fix: add improved logging for contentstack requests
This commit is contained in:
@@ -37,7 +37,7 @@ import {
|
||||
export const loyaltyPageQueryRouter = router({
|
||||
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
||||
const { lang, uid } = ctx
|
||||
|
||||
console.info("contentstack.loyaltyPage.refs start ", { lang, uid })
|
||||
const refsResponse = await request<LoyaltyPageRefsDataRaw>(
|
||||
GetLoyaltyPageRefs,
|
||||
{
|
||||
@@ -50,6 +50,10 @@ export const loyaltyPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
console.error("contentstack.loyaltyPage.refs not found error", {
|
||||
lang,
|
||||
uid,
|
||||
})
|
||||
throw notFound(refsResponse)
|
||||
}
|
||||
|
||||
@@ -59,19 +63,20 @@ export const loyaltyPageQueryRouter = router({
|
||||
validateLoyaltyPageRefsSchema.safeParse(cleanedData)
|
||||
if (!validatedLoyaltyPageRefs.success) {
|
||||
console.error(
|
||||
`Failed to validate Loyaltypage Refs - (lang: ${lang}, uid: ${uid})`
|
||||
"contentstack.loyaltyPage.refs validation error",
|
||||
{ lang, uid },
|
||||
JSON.stringify(validatedLoyaltyPageRefs.error)
|
||||
)
|
||||
console.error(validatedLoyaltyPageRefs.error)
|
||||
return null
|
||||
}
|
||||
|
||||
console.info("contentstack.loyaltyPage.refs success ", { lang, uid })
|
||||
const connections = getConnections(validatedLoyaltyPageRefs.data)
|
||||
|
||||
const tags = [
|
||||
generateTags(lang, connections),
|
||||
generateTag(lang, validatedLoyaltyPageRefs.data.loyalty_page.system.uid),
|
||||
].flat()
|
||||
|
||||
console.info("contentstack.loyaltyPage start ", { lang, uid })
|
||||
const response = await request<any>(
|
||||
GetLoyaltyPage,
|
||||
{
|
||||
@@ -82,6 +87,7 @@ export const loyaltyPageQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
console.error("contentstack.loyaltyPage not found error", { lang, uid })
|
||||
throw notFound(response)
|
||||
}
|
||||
|
||||
@@ -191,9 +197,10 @@ export const loyaltyPageQueryRouter = router({
|
||||
validateLoyaltyPageSchema.safeParse(loyaltyPage)
|
||||
if (!validatedLoyaltyPage.success) {
|
||||
console.error(
|
||||
`Failed to validate Loyaltypage Data - (lang: ${lang}, uid: ${uid})`
|
||||
"contentstack.loyaltyPage validation error",
|
||||
{ lang, uid },
|
||||
JSON.stringify(validatedLoyaltyPage.error)
|
||||
)
|
||||
console.error(validatedLoyaltyPage.error)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -205,7 +212,7 @@ export const loyaltyPageQueryRouter = router({
|
||||
channel: TrackingChannelEnum["scandic-friends"],
|
||||
pageType: "loyaltycontentpage",
|
||||
}
|
||||
|
||||
console.info("contentstack.loyaltyPage success ", { lang, uid })
|
||||
// Assert LoyaltyPage type to get correct typings for RTE fields
|
||||
return {
|
||||
loyaltyPage,
|
||||
|
||||
Reference in New Issue
Block a user