Skip to content

Commit

Permalink
docs: support session replay tunnelling for javascript (#10939)
Browse files Browse the repository at this point in the history
If a session replay is embedded into the envelope, decoding it to text will yield a `400 Bad Request` when tunnelling. So we need to pass the content as bytes into the body in order to work.
  • Loading branch information
rhuanbarreto committed Aug 13, 2024
1 parent a5ac206 commit e7080d6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/platforms/javascript/common/troubleshooting/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ const SENTRY_PROJECT_IDS = ["123456"];

export const postAction = async ({ request }) => {
try {
const envelope = await request.text();
const envelopeBytes = await req.arrayBuffer();
const envelope = new TextDecoder().decode(envelopeBytes);
const piece = envelope.split("\n")[0];
const header = JSON.parse(piece);
const dsn = new URL(header["dsn"]);
Expand All @@ -236,7 +237,7 @@ export const postAction = async ({ request }) => {
}

const upstream_sentry_url = `https://${SENTRY_HOST}/api/${project_id}/envelope/`;
await fetch(upstream_sentry_url, { method: "POST", body: envelope });
await fetch(upstream_sentry_url, { method: "POST", body: envelopeBytes });

return json({}, { status: 200 });
} catch (e) {
Expand Down

0 comments on commit e7080d6

Please sign in to comment.