UNPKG

@sparse-bug/nextjs

Version:

Official Next.js SDK for Sparse Bug, providing seamless integration for both App and Pages routers.

26 lines (25 loc) 648 B
// src/server/index.ts function reportErrorToServer(error, config, context = {}) { const payload = { errorMessage: error.message, stackTrace: error.stack || "No stack trace available", context: { ...context, environment: "server", timestamp: (/* @__PURE__ */ new Date()).toISOString() } }; fetch(`${config.endpoint}/report`, { method: "POST", headers: { "Content-Type": "application/json", "X-API-Key": config.apiKey }, body: JSON.stringify(payload) }).catch((e) => { console.error("[SparseBug Server] Failed to report error:", e); }); } export { reportErrorToServer };