mozilla-rally / web-science

INACTIVE - WebScience is an open-source library for building browser-based research studies, including on Rally.
https://www.npmjs.com/package/@mozilla/web-science
Apache License 2.0
23 stars 6 forks source link

Suppress "unable to send message to tab" for protected pages #79

Closed rhelmer closed 1 month ago

rhelmer commented 3 years ago

The Mozilla Rally 01 study (aka RS01, aka "Doomscrolling and Your Time Online") logs the following sort of message very frequently:

WebScience.Utilities.Messaging: Unable to send message to tab: {"type":"WebScience.Utilities.PageManager.pageAttentionUpdate","pageHasAttention":false,"timeStamp":1620412253678,"reason":"window-focus-lost"}

I think this happens because of pages that the extension is not allowed to run on (about: pages, protected web pages, and those not granted access in the manifest). If this is true, then we should suppress this message in those cases. I think it might be reasonable to just suppress it generally, but if we can have it log actual failures only that'd be ideal.

RS01 a slightly older fork of a few WebScience modules, but I'm pretty sure the code is basically the same https://github.com/mozilla-rally/web-science/blob/93dd93197f149b1073b1902906f94c56721cbfd3/src/messaging.js#L286 here.

cpeterso commented 3 years ago

I reported these Unable to send message to tab log messages because I wasn't sure if they indicated a bug in the Rally extension.

If you are going to suppress log messages to make the extension quieter, there are other WebScience log messages that are even more noiser, such as:

WebScience.Utilities.PageManager (Content Script): Page attention update: {"onPageVisitStart":{"addListenerCallback":null,"removeListenerCallback":null,"notifyListenersCallback":null,"listeners":{}},"onPageVisitStop":{"addListenerCallback":null,"removeListenerCallback":null,"notifyListenersCallback":null,"listeners":{}},"onPageAttentionUpdate":{"addListenerCallback":null,"removeListenerCallback":null,"notifyListenersCallback":null,"listeners":{}},"onPageAudioUpdate":{"addListenerCallback":null,"removeListenerCallback":null,"notifyListenersCallback":null,"listeners":{}},"pageId":"151937d84007338143395860c4152e71","url":"https://github.com/mozilla-rally/web-science/issues/79","referrer":"https://github.com/mozilla-rally/rally-study-01/issues/104","pageVisitStartTime":1620417040220,"pageHasAttention":true,"pageHasAudio":false,"pageVisitStarted":true}

DataCollection.sendPing - options: {"studyName":"rally-zero-one","addPioneerId":true,"overridePioneerId":"f6b4fbd8-9caf-422a-b79a-35115647da08","encryptionKeyId":"zero-one","publicKey":{"crv":"P-256","kid":"zero-one","kty":"EC","x":"edhPpqhgK9dD7NaqhQ7Ckw9sU6b39X7XB8HnA366Rjs","y":"GzsfM19n-iH-DVR0iKEoA8BE2CFF46wR__siJ3SdiNs"},"schemaName":"measurements","schemaVersion":1,"schemaNamespace":"rally-zero-one"} payload: {"pageId":"e22a87d715d02e4f47422d1cf43d4797","origin":"https://www.cnn.com","referrerOrigin":"","pageVisitStartTime":1620417062877,"pageVisitStopTime":1620417067890,"duration":403,"maxRelativeScrollDepth":0,"maxPixelScrollDepth":0,"scrollHeight":0,"eventTerminationReason":"window-focus-lost","title":"CNN - Breaking News, Latest News and Videos","ogType":"website","description":"View the latest news and breaking news today for U.S., world, weather, entertainment, politics and health at CNN.com.","eventStartTime":1620417067487,"eventStopTime":1620417067890,"eventType":"attention"}

rhelmer commented 3 years ago

If you are going to suppress log messages to make the extension quieter, there are other WebScience log messages that are even more noiser, such as:

Thanks! That is coming from the core add-on, I filed https://github.com/mozilla-rally/rally-core-addon/issues/582 for this.