feat: OneSignal.setSWLogging; improved testability #999
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Adds inability to turn on/off SW logging from page without directly using internals (#992).
Details
This PR:
SWLog
, previously sharing the name of PageLog
but not its implementation.SWLog
:SWLog
is now unambiguous vs PageLog
use--lower cognitive overheadOneSignal.setSWLogging(enabled: boolean)
:WorkerMessengerCommandHandlers
fromServiceWorker
for testing surface area, used in this PRworkerMessenger
API to send aSetLogging
message to SWworkerMessenger
now logs whether message receipt enables or disablesSWLog
Because Service Workers are persistent, SW logging is unaffected by page refresh. This isn't new, but it behaves like
setLevel
(which is persisted inDatabase
). Happy coincidence. :)Associated documentation would need updating.
Systems Affected
Validation
See screenshots.
Tests
SWLog
now possible with singleton patternSetLogging
message handling testsChecklist
Programming Checklist
Interfaces:
note: I did leave it in place on
SWLog
please confirm interfaces are in right place
Functions:
Typescript:
Other:
elem of array
syntax. PreferforEach
or usemap
context
if possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.context
Screenshots
Note that
workerMessenger
, which I this is shared between page and sw browser contexts, uses the Page log and always logs. The Service Worker logs more, pictured below, only if activated.Disabling:
Enabling:
Checklist
Related Tickets
#992
This change is