Skip to content

Commit

Permalink
chore: sentry - add tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
ns212 committed Jun 12, 2024
1 parent 6245fca commit f120c12
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/evm/api/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ export const config = {
runtime: 'edge'
};

async function extractBody(request) {
const dec = new TextDecoder();
const reader = request.body.getReader();
let body = ""

while (true) {
const { done, value } = await reader.read();
if (done) return body;

body = body + dec.decode(value)
}
}

export default async (request) => {
try {
const envelope = request.body;
const envelope = await extractBody(request);
const piece = envelope.split('\n')[0];
const header = JSON.parse(piece);
const dsn = new URL(header['dsn']);
Expand Down

0 comments on commit f120c12

Please sign in to comment.