1/** 2 * Copyright (c) 650 Industries. 3 * Copyright (c) Meta Platforms, Inc. and affiliates. 4 * 5 * This source code is licensed under the MIT license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9import { StackFrame } from 'stacktrace-parser'; 10 11export type CodeFrame = { 12 content: string; 13 location?: { 14 row: number; 15 column: number; 16 [key: string]: any; 17 }; 18 fileName: string; 19}; 20 21export type SymbolicatedStackTrace = { 22 stack: StackFrame[]; 23 codeFrame?: CodeFrame; 24}; 25 26async function symbolicateStackTrace(stack: StackFrame[]): Promise<SymbolicatedStackTrace> { 27 const baseUrl = 28 typeof window === 'undefined' 29 ? process.env.EXPO_DEV_SERVER_ORIGIN 30 : window.location.protocol + '//' + window.location.host; 31 32 const response = await fetch(baseUrl + '/symbolicate', { 33 method: 'POST', 34 body: JSON.stringify({ stack }), 35 }); 36 return await response.json(); 37} 38 39export default symbolicateStackTrace; 40