chore: track bundle sizes in Amplitude#1762
Conversation
This reverts commit faf2a6a.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for all 4 issues found in the latest run.
- ✅ Fixed: Wrong script path references non-existent
.scriptsdirectory- Updated the workflow to invoke the existing
scripts/report-bundle-size.jspath.
- Updated the workflow to invoke the existing
- ✅ Fixed: Missing
AMPLITUDE_API_KEYenv var in workflow step- Added the
AMPLITUDE_API_KEYsecret mapping to the bundle-size reporting workflow step.
- Added the
- ✅ Fixed: Missing
nameproperty on session-replay size entry- Added the missing session replay bundle
namevalue for consistent reporting.
- Added the missing session replay bundle
- ✅ Fixed: Missing Content-Type header in Amplitude API request
- Added the
Content-Type: application/jsonheader to the Amplitude HTTP V2 request.
- Added the
Or push these changes by commenting:
@cursor push 744dbd9a82
Preview (744dbd9a82)
diff --git a/.github/workflows/publish-v1.yml b/.github/workflows/publish-v1.yml
--- a/.github/workflows/publish-v1.yml
+++ b/.github/workflows/publish-v1.yml
@@ -119,4 +119,6 @@
# Report bundle size to Amplitude
- name: Report bundle size to Amplitude
run: |
- node ./.scripts/report-bundle-size.js
+ node ./scripts/report-bundle-size.js
+ env:
+ AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
diff --git a/.size-limit.js b/.size-limit.js
--- a/.size-limit.js
+++ b/.size-limit.js
@@ -11,6 +11,7 @@
// session-replay standalone bundle
packageJsonPath: './packages/session-replay-browser/package.json',
path: `./packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz`,
+ name: 'session-replay-browser.min.js.gz',
limit: '150kb',
brotli: false,
},
@@ -22,6 +23,6 @@
limit: '225kb',
brotli: false,
},
-]
+];
module.exports = limits;
diff --git a/scripts/report-bundle-size.js b/scripts/report-bundle-size.js
--- a/scripts/report-bundle-size.js
+++ b/scripts/report-bundle-size.js
@@ -18,7 +18,7 @@
};
}
-const events = [];
+const events = [];
for (const limit of sizeLimits) {
const size = fs.statSync(limit.path).size;
events.push(getBundleSizeEvent(limit.path, size, limit.name, limit.packageJsonPath));
@@ -26,17 +26,22 @@
fetch('https://api.amplitude.com/2/httpapi', {
method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
body: JSON.stringify({
api_key: process.env.AMPLITUDE_API_KEY,
events: events,
}),
-}).then(response => {
- console.log(response.status);
- response.json().then(data => {
- console.log(data);
- process.exit(response.status >= 400 ? 1 : 0);
+})
+ .then((response) => {
\ No newline at end of file
+ console.log(response.status);
+ response.json().then((data) => {
+ console.log(data);
+ process.exit(response.status >= 400 ? 1 : 0);
+ });
+ })
+ .catch((error) => {
+ console.error('Error reporting bundle size to Amplitude:', error);
+ process.exit(1);
});
-}).catch(error => {
- console.error('Error reporting bundle size to Amplitude:', error);
- process.exit(1);
-});You can send follow-ups to the cloud agent here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Bundle size reporting missing from the release deploy job
- Added the Amplitude bundle size reporting step to the release deploy job after publishing to NPM.
- ✅ Fixed: Inner promise not returned causes unhandled rejection
- Returned the response.json() promise so JSON parsing failures propagate to the existing catch handler.
Or push these changes by commenting:
@cursor push df81012d4f
Preview (df81012d4f)
diff --git a/.github/workflows/publish-v2.yml b/.github/workflows/publish-v2.yml
--- a/.github/workflows/publish-v2.yml
+++ b/.github/workflows/publish-v2.yml
@@ -177,6 +177,13 @@
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
+ # Report bundle size to Amplitude
+ - name: Report bundle size to Amplitude
+ env:
+ AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
+ run: |
+ node ./scripts/report-bundle-size.js
+
prerelease:
name: Prerelease feature branch
runs-on: ubuntu-latest
diff --git a/scripts/report-bundle-size.js b/scripts/report-bundle-size.js
--- a/scripts/report-bundle-size.js
+++ b/scripts/report-bundle-size.js
@@ -35,7 +35,7 @@
}),
}).then(response => {
console.log(response.status);
- response.json().then(data => {
+ return response.json().then(data => {
console.log(data);
process.exit(response.status >= 400 ? 1 : 0);
});You can send follow-ups to the cloud agent here.
… SDK-14-track-bundle-size-in-amplitude
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Invalid GitHub Actions syntax
allow-failureinstead ofcontinue-on-error- Replaced the invalid workflow step key with
continue-on-error: trueso bundle size reporting remains non-blocking.
- Replaced the invalid workflow step key with
Or push these changes by commenting:
@cursor push 341389638f
Preview (341389638f)
diff --git a/.github/workflows/publish-v2.yml b/.github/workflows/publish-v2.yml
--- a/.github/workflows/publish-v2.yml
+++ b/.github/workflows/publish-v2.yml
@@ -179,7 +179,7 @@
# Report bundle size to Amplitude
- name: Report bundle size to Amplitude
- allow-failure: true
+ continue-on-error: true
env:
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
run: |You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 634b36f. Configure here.


Summary
Track JS bundle sizes in Amplitude after publish
Checklist
Note
Low Risk
Observability-only post-publish step with continue-on-error; no runtime SDK or publish behavior changes beyond optional telemetry.
Overview
After a release publish, the deploy workflow now runs a new script that measures the same gzipped bundles defined in
.size-limit.jsand sendsSDK Bundle Sizeevents to Amplitude (package name/version, path, filename, byte size). That step usesAMPLITUDE_API_KEYand iscontinue-on-error: trueso a telemetry failure does not block shipping..size-limit.jsgainspackageJsonPathandnameon each entry so the reporter can attach npm package metadata without duplicating paths. CI’s check-size-limits job drops the redundant Save Nx cache step (restore + size-limit action remain).Reviewed by Cursor Bugbot for commit 4d90848. Bugbot is set up for automated code reviews on this repo. Configure here.