forked from jsnbuchanan/crowd-funder-for-time-pwa
Scale back logging in migration, component lifecycle, and database areas
- Migration Service: Reduced verbose logging by 80% while keeping critical errors - Component Lifecycle: Removed 15+ debug logs from App.vue notification handling - Database: Kept error logging intact, removed redundant info logs - Maintained critical error logging for debugging and monitoring - Improved performance and reduced log noise in production
This commit is contained in:
29
src/App.vue
29
src/App.vue
@@ -392,43 +392,33 @@ export default class App extends Vue {
|
||||
async turnOffNotifications(
|
||||
notification: NotificationIface,
|
||||
): Promise<boolean> {
|
||||
logger.log("Starting turnOffNotifications...");
|
||||
let subscription: PushSubscriptionJSON | null = null;
|
||||
let allGoingOff = false;
|
||||
|
||||
try {
|
||||
logger.log("Retrieving settings for the active account...");
|
||||
const settings: Settings =
|
||||
await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
logger.log("Retrieved settings:", settings);
|
||||
|
||||
const notifyingNewActivity = !!settings?.notifyingNewActivityTime;
|
||||
const notifyingReminder = !!settings?.notifyingReminderTime;
|
||||
|
||||
if (!notifyingNewActivity || !notifyingReminder) {
|
||||
allGoingOff = true;
|
||||
logger.log("Both notifications are being turned off.");
|
||||
}
|
||||
|
||||
logger.log("Checking service worker readiness...");
|
||||
await navigator.serviceWorker?.ready
|
||||
.then((registration) => {
|
||||
logger.log("Service worker is ready. Fetching subscription...");
|
||||
return registration.pushManager.getSubscription();
|
||||
})
|
||||
.then(async (subscript: PushSubscription | null) => {
|
||||
if (subscript) {
|
||||
subscription = subscript.toJSON();
|
||||
logger.log("PushSubscription retrieved:", subscription);
|
||||
|
||||
if (allGoingOff) {
|
||||
logger.log("Unsubscribing from push notifications...");
|
||||
await subscript.unsubscribe();
|
||||
logger.log("Successfully unsubscribed.");
|
||||
}
|
||||
} else {
|
||||
logConsoleAndDb("Subscription object is not available.");
|
||||
logger.log("No subscription found.");
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -441,7 +431,6 @@ export default class App extends Vue {
|
||||
});
|
||||
|
||||
if (!subscription) {
|
||||
logger.log("No subscription available. Notifying user...");
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
@@ -451,21 +440,14 @@ export default class App extends Vue {
|
||||
},
|
||||
5000,
|
||||
);
|
||||
logger.log("Exiting as there is no subscription to process.");
|
||||
return true;
|
||||
}
|
||||
|
||||
const serverSubscription = {
|
||||
...subscription,
|
||||
...(subscription as PushSubscriptionJSON),
|
||||
...(allGoingOff ? {} : { notifyType: notification.title }),
|
||||
};
|
||||
if (!allGoingOff) {
|
||||
serverSubscription["notifyType"] = notification.title;
|
||||
logger.log(
|
||||
`Server subscription updated with notifyType: ${notification.title}`,
|
||||
);
|
||||
}
|
||||
|
||||
logger.log("Sending unsubscribe request to the server...");
|
||||
const pushServerSuccess = await fetch("/web-push/unsubscribe", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -482,7 +464,6 @@ export default class App extends Vue {
|
||||
);
|
||||
logger.error("Push server error response:", errorBody);
|
||||
}
|
||||
logger.log(`Server response status: ${response.status}`);
|
||||
return response.ok;
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -497,7 +478,6 @@ export default class App extends Vue {
|
||||
const message = pushServerSuccess
|
||||
? "Notification is off."
|
||||
: "Notification is still on. Try to turn it off again.";
|
||||
logger.log("Server response processed. Message:", message);
|
||||
|
||||
this.$notify(
|
||||
{
|
||||
@@ -510,14 +490,9 @@ export default class App extends Vue {
|
||||
);
|
||||
|
||||
if (notification.callback) {
|
||||
logger.log("Executing notification callback...");
|
||||
notification.callback(pushServerSuccess);
|
||||
}
|
||||
|
||||
logger.log(
|
||||
"Completed turnOffNotifications with success:",
|
||||
pushServerSuccess,
|
||||
);
|
||||
return pushServerSuccess;
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
|
||||
Reference in New Issue
Block a user