From 045ba28c412ed5ea0b951cc2c94c138da63de8e6 Mon Sep 17 00:00:00 2001 From: ekzyis <27162016+ekzyis@users.noreply.github.com> Date: Thu, 4 Jan 2024 20:53:52 +0100 Subject: [PATCH] Remove logging to browser (#733) * Don't log to browser console * Don't log options (too verbose) --------- Co-authored-by: ekzyis --- sw/eventListener.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sw/eventListener.js b/sw/eventListener.js index 25d5541e..d40dafca 100644 --- a/sw/eventListener.js +++ b/sw/eventListener.js @@ -20,8 +20,6 @@ let activeCount = 0 const log = (message, level = 'info', context) => { messageChannelPort?.postMessage({ level, message, context }) - if (level === 'error') console.error(message) - else console.log(message) } export function onPush (sw) { @@ -62,7 +60,7 @@ export function onPush (sw) { log(`[sw:push] ${nid} - closing existing notifications`) notifications.filter(({ tag: nTag }) => nTag === tag).forEach(n => n.close()) } - log(`[sw:push] ${nid} - show notification: ${payload.title} ${JSON.stringify(payload.options)}`) + log(`[sw:push] ${nid} - show notification with title "${payload.title}"`) return await sw.registration.showNotification(payload.title, payload.options) } @@ -72,7 +70,7 @@ export function onPush (sw) { // incoming notification is first notification with this tag log(`[sw:push] ${nid} - no existing ${tag} notifications found`) setAppBadge(sw, ++activeCount) - log(`[sw:push] ${nid} - show notification: ${payload.title} ${JSON.stringify(payload.options)}`) + log(`[sw:push] ${nid} - show notification with title "${payload.title}"`) return await sw.registration.showNotification(payload.title, payload.options) } @@ -164,7 +162,7 @@ const mergeAndShowNotification = async (sw, payload, currentNotifications, tag, } const options = { icon: payload.options?.icon, tag, data: { url: '/notifications', ...mergedPayload } } - log(`[sw:push] ${nid} - show notification: ${title} ${JSON.stringify(options)}`) + log(`[sw:push] ${nid} - show notification with title "${payload.title}"`) return await sw.registration.showNotification(title, options) }