MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / uploadBundles

Function uploadBundles

scripts/lighthouse-bundle-and-upload.mjs:131–159  ·  view source on GitHub ↗

* POST the multipart form. Returns the parsed 202 response body.

(bundles)

Source from the content-addressed store, hash-verified

129 * POST the multipart form. Returns the parsed 202 response body.
130 */
131async function uploadBundles(bundles) {
132 const metadata = {
133 commit: process.env.GITHUB_SHA ?? 'unknown',
134 branch: process.env.GITHUB_REF_NAME ?? 'unknown',
135 triggeredBy: 'github-actions',
136 workflowRunUrl:
137 process.env.GITHUB_SERVER_URL && process.env.GITHUB_REPOSITORY && process.env.GITHUB_RUN_ID
138 ? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
139 : undefined,
140 cells: bundles.map(b => b.cell),
141 };
142
143 const form = new FormData();
144 form.append('metadata', JSON.stringify(metadata));
145 for (const b of bundles) {
146 const buf = await readFile(b.tarPath);
147 form.append(b.fieldName, new Blob([buf], { type: 'application/gzip' }), path.basename(b.tarPath));
148 }
149
150 const res = await fetch(`${LAB_URL}/api/builds`, {
151 method: 'POST',
152 headers: { Authorization: `Bearer ${TOKEN}` },
153 body: form,
154 });
155 if (!res.ok) {
156 throw new Error(`Upload failed: ${res.status} ${await res.text()}`);
157 }
158 return res.json();
159}
160
161async function formatSize(filePath) {
162 const { size } = await stat(filePath);

Callers 1

runFunction · 0.85

Calls 4

appendMethod · 0.95
textMethod · 0.65
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected