Skip to content

Commit 484b72b

Browse files
committed
Modify the CHANGELOG
1 parent 4f87cc2 commit 484b72b

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[Full changelog](https://github.com/mozilla/glean.js/compare/v0.17.0...main)
44

5-
* [#534](https://github.com/mozilla/glean.js/pull/534): Refactor Uploader into abstract class for external use
5+
* [#534](https://github.com/mozilla/glean.js/pull/534): Expose `Uploader` base class through `@mozilla/glean/<platform>/uploader` entry point.
66

77
# v0.17.0 (2021-07-16)
88

glean/src/core/upload/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class PingUploader implements PingsDatabaseObserver {
9090
this.queue = [];
9191
this.status = PingUploaderStatus.Idle;
9292
// Initialize the ping uploader with either the platform defaults or a custom
93-
// provided uploader from the configuration object.npm
93+
// provided uploader from the configuration object.
9494
this.uploader = config.httpClient ? config.httpClient : platform.uploader;
9595
this.platformInfo = platform.info;
9696
this.serverEndpoint = config.serverEndpoint;
@@ -251,16 +251,17 @@ class PingUploader implements PingsDatabaseObserver {
251251
* @returns Whether or not to retry the upload attempt.
252252
*/
253253
private async processPingUploadResponse(identifier: string, response: UploadResult): Promise<boolean> {
254-
if (response.status && response.status >= 200 && response.status < 300) {
255-
log(LOG_TAG, `Ping ${identifier} succesfully sent ${response.status}.`, LoggingLevel.Info);
254+
const { status, result } = response;
255+
if (status && status >= 200 && status < 300) {
256+
log(LOG_TAG, `Ping ${identifier} succesfully sent ${status}.`, LoggingLevel.Info);
256257
await this.pingsDatabase.deletePing(identifier);
257258
return false;
258259
}
259260

260-
if (response.result === UploadResultStatus.UnrecoverableFailure || (response.status && response.status >= 400 && response.status < 500)) {
261+
if (result === UploadResultStatus.UnrecoverableFailure || (status && status >= 400 && status < 500)) {
261262
log(
262263
LOG_TAG,
263-
`Unrecoverable upload failure while attempting to send ping ${identifier}. Error was: ${response.status ?? "no status"}.`,
264+
`Unrecoverable upload failure while attempting to send ping ${identifier}. Error was: ${status ?? "no status"}.`,
264265
LoggingLevel.Warn
265266
);
266267
await this.pingsDatabase.deletePing(identifier);
@@ -271,7 +272,7 @@ class PingUploader implements PingsDatabaseObserver {
271272
LOG_TAG,
272273
[
273274
`Recoverable upload failure while attempting to send ping ${identifier}, will retry.`,
274-
`Error was ${response.status ?? "no status"}.`
275+
`Error was ${status ?? "no status"}.`
275276
],
276277
LoggingLevel.Warn
277278
);

glean/src/core/upload/uploader.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ export const enum UploadResultStatus {
2929
* The result of an attempted ping upload.
3030
*/
3131
export class UploadResult {
32-
// The status is only present if `result` is UploadResultStatus.Success
33-
readonly status?: number;
34-
// The status of an upload attempt
35-
readonly result: UploadResultStatus;
36-
37-
constructor(result: UploadResultStatus, status?: number) {
38-
this.result = result;
39-
this.status = status;
40-
}
32+
constructor(
33+
// The status of an upload attempt
34+
readonly result: UploadResultStatus,
35+
// The status is only present if `result` is UploadResultStatus.Success
36+
readonly status?: number
37+
) {}
4138
}
4239

4340
/**

glean/tests/unit/platform/qt/uploader.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import assert from "assert";
77
import sinon from "sinon";
88

99
import QtUploader from "../../../../src/platform/qt/uploader";
10-
import {DEFAULT_UPLOAD_TIMEOUT_MS, UploadResult, UploadResultStatus} from "../../../../src/core/upload/uploader";
10+
import { DEFAULT_UPLOAD_TIMEOUT_MS, UploadResult, UploadResultStatus } from "../../../../src/core/upload/uploader";
1111

1212
describe("Uploader/Qt", function () {
1313
let server: sinon.SinonFakeServer;

glean/tests/unit/platform/webext/uploader.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import sinon from "sinon";
88

99
import BrowserUploader from "../../../../src/platform/webext/uploader";
1010
import type { JSONObject } from "../../../../src/core/utils";
11-
import {UploadResult, UploadResultStatus} from "../../../../src/core/upload/uploader";
11+
import { UploadResult, UploadResultStatus } from "../../../../src/core/upload/uploader";
1212

1313
const sandbox = sinon.createSandbox();
1414

samples/web-extension/typescript/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"@types/mocha": "^8.2.3",
2222
"@types/node": "^16.3.2",
2323
"mocha": "^9.0.2",
24-
"strip-ansi": "^7.0.0",
2524
"ts-loader": "^9.2.3",
26-
"ts-node": "^10.1.0",
2725
"typescript": "^4.3.5",
2826
"web-ext-types": "^3.2.1",
2927
"webpack": "^5.44.0",
30-
"webpack-cli": "^4.7.2"
28+
"webpack-cli": "^4.7.2",
29+
"ts-node": "^10.1.0",
30+
"strip-ansi": "^7.0.0"
3131
}
3232
}

0 commit comments

Comments
 (0)