File tree Expand file tree Collapse file tree 3 files changed +22
-13
lines changed Expand file tree Collapse file tree 3 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 55* [ #984 ] ( https://github.com/mozilla/glean.js/pull/984 ) : BUGFIX: Return correct upload result in case an error happens while building a ping request.
66* [ #988 ] ( https://github.com/mozilla/glean.js/pull/988 ) : BUGFIX: Enforce rate limitation at upload time, not at ping submission time.
77 * Note: This change required a big refactoring of the internal uploading logic.
8+ * [ #1015 ] ( https://github.com/mozilla/glean.js/pull/1015 ) : BUGFIX: Make attempting to call the ` setUploadEnabled ` API before initializing Glean a no-op.
89
910# v0.27.0 (2021-11-22)
1011
Original file line number Diff line number Diff line change @@ -355,6 +355,19 @@ class Glean {
355355 * @param flag When true, enable metric collection.
356356 */
357357 static setUploadEnabled ( flag : boolean ) : void {
358+ if ( ! Context . initialized ) {
359+ log (
360+ LOG_TAG ,
361+ [
362+ "Changing upload enabled before Glean is initialized is not supported.\n" ,
363+ "Pass the correct state into `Glean.initialize`.\n" ,
364+ "See documentation at https://mozilla.github.io/glean/book/user/general-api.html#initializing-the-glean-sdk`"
365+ ] ,
366+ LoggingLevel . Error
367+ ) ;
368+ return ;
369+ }
370+
358371 if ( ! isBoolean ( flag ) ) {
359372 log (
360373 LOG_TAG ,
@@ -365,19 +378,6 @@ class Glean {
365378 }
366379
367380 Context . dispatcher . launch ( async ( ) => {
368- if ( ! Context . initialized ) {
369- log (
370- LOG_TAG ,
371- [
372- "Changing upload enabled before Glean is initialized is not supported.\n" ,
373- "Pass the correct state into `Glean.initialize\n`." ,
374- "See documentation at https://mozilla.github.io/glean/book/user/general-api.html#initializing-the-glean-sdk`"
375- ] ,
376- LoggingLevel . Error
377- ) ;
378- return ;
379- }
380-
381381 if ( Context . uploadEnabled !== flag ) {
382382 if ( flag ) {
383383 await Glean . onUploadEnabled ( ) ;
Original file line number Diff line number Diff line change @@ -164,6 +164,14 @@ describe("Glean", function() {
164164 assert . strictEqual ( spy . callCount , 1 ) ;
165165 } ) ;
166166
167+ it ( "attempting to change upload status prior to initialize is a no-op" , async function ( ) {
168+ await Glean . testUninitialize ( ) ;
169+
170+ const launchSpy = sandbox . spy ( Context . dispatcher , "launch" ) ;
171+ Glean . setUploadEnabled ( false ) ;
172+ assert . strictEqual ( launchSpy . callCount , 0 ) ;
173+ } ) ;
174+
167175 it ( "initialization throws if applicationId is an empty string" , async function ( ) {
168176 await Glean . testUninitialize ( ) ;
169177 try {
You can’t perform that action at this time.
0 commit comments