import { Platform } from 'react-native'; import DeviceInfo from 'react-native-device-info'; type ReportErrorProps = { url: string; token: string; error: unknown; functionName: string; product: string; sdkVersion: string; sdkCodeVersion: string; }; const ReportError = ({ url, token, error, functionName, product, sdkVersion, sdkCodeVersion, }: ReportErrorProps) => { DeviceInfo.getManufacturer().then((manufacturer) => { const body = JSON.stringify({ scope: `${functionName}`, platform: `react-${Platform.OS}`, errorTrace: error, deviceDeatils: { manufacturer: `${manufacturer}`, model: `${DeviceInfo.getModel()}`, brand: `${DeviceInfo.getBrand()}`, device: `${DeviceInfo.getSystemName()}`, product: `${product}`, hardware: `${manufacturer}`, osVersion: `${Platform.Version}`, sdkVersion: `${sdkVersion}`, sdkCodeVersion: `${sdkCodeVersion}`, }, }); console.log('body', body); fetch(url, { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': `${token}`, }, body: body, }) .then((res) => { res.json().then((response) => { console.log('response', response); }); }) .catch((e) => { console.log('API error', e); }); }); }; export default ReportError;