1export type pterrEnvCtx = { 2 gpIsProd?: boolean | null 4 deploymentName?: string 12export type pterrErrCtx = { 17 isRlSilenced?: boolean 18 silencedSamples?: unknown[] 21export type pterrJson = { 23 reqCtx?: Record<string, unknown> 25 uniqDebugH?: Record<string, unknown> 26 dumpDebugH?: Record<string, unknown> 27 clientStackA?: string[] 28 componentStackA?: string[] 29 smResolutionFailed?: boolean 32export const parsePterrJson = (bodyRaw: string): pterrJson | undefined => { 33 const decoded = bodyRaw 34 .replace(/=\r?\n/g, '') 35 .replace(/=([0-9A-F]{2})/gi, (_, hex: string) => String.fromCharCode(parseInt(hex, 16))) 36 const match = decoded.match(/---PTERR-JSON---\r?\n([\s\S]*?)\r?\n---\/PTERR-JSON---/) 37 if (!match) return undefined 39 return JSON.parse(match[1].replace(/\r/g, ''))