/* * Crashes and errors reported must respect this interface (contract) for * backend to accept the message. */ interface CrashReport { rst: string; crt: number; env: 'React Native'; em: string; adi?: object; } function createCrashReport(error: Error): CrashReport { const stackTraceRegex = /Error:.*\n([\s\S]*)/; //CDM-10361: this is not correct, the stack structure changes with js compiler and dont need to follow this regex const stackTraceMatch = error.stack?.match(stackTraceRegex); const stackTrace = stackTraceMatch && stackTraceMatch[1] ? stackTraceMatch[1].trim() : ''; return { rst: stackTrace, crt: Date.now(), env: 'React Native', em: error.message, }; } export {type CrashReport, createCrashReport};