Files
solelog/apps/mobile/__create/report-error-to-remote.js
Bas van Rossem d94d0b188b Initial commit: code as received (Create/Anything export)
Insole-production time tracker exported from the Create/Anything AI
platform. Baseline snapshot before any reverse-engineering or cleanup.

- apps/mobile: Expo Router app (iOS/Android/web), the only workspace
- publisher/: standalone OpenNext/AWS deploy tooling for the web side
- Backend (/api/tasks, /api/logs + DB) lives remotely, not in this repo
2026-06-17 10:19:33 +02:00

54 lines
1.4 KiB
JavaScript

import { serializeError } from "serialize-error";
export const sendLogsToRemote = async (logs) => {
if (
!process.env.EXPO_PUBLIC_LOGS_ENDPOINT ||
!process.env.EXPO_PUBLIC_PROJECT_GROUP_ID ||
!process.env.EXPO_PUBLIC_CREATE_TEMP_API_KEY
) {
return { success: false };
}
try {
const response = await fetch(process.env.EXPO_PUBLIC_LOGS_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.EXPO_PUBLIC_CREATE_TEMP_API_KEY}`,
},
body: JSON.stringify({
projectGroupId: process.env.EXPO_PUBLIC_PROJECT_GROUP_ID,
logs,
}),
});
if (!response.ok) {
return { success: false };
}
} catch (fetchError) {
return { success: false, error: fetchError };
}
return { success: true };
};
export const reportErrorToRemote = async ({ error }) => {
if (
!process.env.EXPO_PUBLIC_LOGS_ENDPOINT ||
!process.env.EXPO_PUBLIC_PROJECT_GROUP_ID ||
!process.env.EXPO_PUBLIC_CREATE_TEMP_API_KEY
) {
console.debug(
"reportErrorToRemote: Missing environment variables for logging endpoint, project group ID, or API key.",
error,
);
return { success: false };
}
return sendLogsToRemote([
{
message: JSON.stringify(serializeError(error)),
timestamp: new Date().toISOString(),
level: "error",
source: "BUILDER",
devServerId: process.env.EXPO_PUBLIC_DEV_SERVER_ID,
},
]);
};