From 853eb3c623dacd6bd1c8de7ed055d16587d6f2d0 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 23 Dec 2023 19:34:26 -0700 Subject: [PATCH] include the data in the logged info for a service worker "push" --- sw_scripts/additional-scripts.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sw_scripts/additional-scripts.js b/sw_scripts/additional-scripts.js index 3582bfc..0e2d326 100644 --- a/sw_scripts/additional-scripts.js +++ b/sw_scripts/additional-scripts.js @@ -28,13 +28,17 @@ function logConsoleAndDb(message, arg1, arg2) { } self.addEventListener("push", function (event) { - logConsoleAndDb("Service worker received a push event.", event); + let text = null; + if (event.data) { + text = event.data.text(); + } + logConsoleAndDb("Service worker received a push event.", text, event); event.waitUntil( (async () => { try { let payload; - if (event.data) { - payload = JSON.parse(event.data.text()); + if (text) { + payload = JSON.parse(text); } const message = await self.getNotificationCount(); if (message) {