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