Skip to content

Commit 7bc7183

Browse files
authored
ref(core): improve logging for upload stats (#79)
1 parent 37754dd commit 7bc7183

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

.changeset/many-peas-repeat.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@codecov/bundler-plugin-core": patch
3+
"@codecov/rollup-plugin": patch
4+
"@codecov/vite-plugin": patch
5+
"@codecov/webpack-plugin": patch
6+
---
7+
8+
Add more detailed logging for upload stats

packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const bundleAnalysisPluginFactory = ({
7070
try {
7171
await uploadStats({
7272
preSignedUrl: url,
73+
bundleName: output.bundleName,
7374
message: JSON.stringify(output),
7475
retryCount: userOptions?.retryCount,
7576
});

packages/bundler-plugin-core/src/utils/__tests__/uploadStats.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe("uploadStats", () => {
6060
setup({ sendError: false });
6161

6262
const data = await uploadStats({
63+
bundleName: "cool-bundle-cjs",
6364
message: "cool-message",
6465
preSignedUrl: "http://localhost/upload/stats/",
6566
retryCount: 0,
@@ -77,6 +78,7 @@ describe("uploadStats", () => {
7778
let error;
7879
try {
7980
await uploadStats({
81+
bundleName: "cool-bundle-cjs",
8082
message: "cool-message",
8183
preSignedUrl: "",
8284
retryCount: 1,
@@ -96,6 +98,7 @@ describe("uploadStats", () => {
9698
let error;
9799
try {
98100
await uploadStats({
101+
bundleName: "cool-bundle-cjs",
99102
message: "cool-message",
100103
preSignedUrl: "http://localhost/upload/stats/",
101104
retryCount: 0,
@@ -115,6 +118,7 @@ describe("uploadStats", () => {
115118
let error;
116119
try {
117120
await uploadStats({
121+
bundleName: "cool-bundle-cjs",
118122
message: "cool-message",
119123
preSignedUrl: "http://localhost/upload/stats/",
120124
retryCount: 0,

packages/bundler-plugin-core/src/utils/uploadStats.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import { FailedFetchError } from "../errors/FailedFetchError";
99

1010
interface UploadStatsArgs {
1111
message: string;
12+
bundleName: string;
1213
preSignedUrl: string;
1314
retryCount?: number;
1415
}
1516

1617
export async function uploadStats({
1718
message,
19+
bundleName,
1820
preSignedUrl,
1921
retryCount = DEFAULT_RETRY_COUNT,
2022
}: UploadStatsArgs) {
@@ -59,10 +61,12 @@ export async function uploadStats({
5961
}
6062

6163
if (!response.ok) {
62-
red("Failed to upload stats, bad response");
64+
red(
65+
`Failed to upload stats, bad response. Response ${response.status} - ${response.statusText}`,
66+
);
6367
throw new FailedUploadError("Failed to upload stats");
6468
}
6569

66-
green("Successfully uploaded stats");
70+
green(`Successfully uploaded stats for bundle: ${bundleName}`);
6771
return true;
6872
}

0 commit comments

Comments
 (0)