Skip to content

refactor: improve push notification received utils#7275

Merged
Prithpal-Sooriya merged 4 commits intomainfrom
refactor/improve-push-notification-handling-utils
Dec 1, 2025
Merged

refactor: improve push notification received utils#7275
Prithpal-Sooriya merged 4 commits intomainfrom
refactor/improve-push-notification-handling-utils

Conversation

@Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Dec 1, 2025

Explanation

We are throwing an error when subscribing the the push notification background listener. Instead we shall fail silently.
I've also added TODOs for areas to improve for push notifications

  1. Using an open-api typed end-to-end schema shared with backend and frontend. Should sync what marshalled data our backend is pushing to clients in the data payload.
  2. Migrate the handler and push notification logic to use the shared Notification push payload used in mobile. This handler can then just be responsible for analytics and not actual push logic.

References

https://consensyssoftware.atlassian.net/browse/ASSETS-1857

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Harden web push notification utilities with defensive parsing and silent failure, remove legacy service-worker module, and update tests and changelog.

  • Web push utilities (web/push-utils.ts):
    • Make listenToPushNotificationsReceived handler optional and guard against unsupported Firebase.
    • Parse payload defensively (JSON.parse(... ?? 'null')), validate with isOnChainRawNotification, and process via safeProcessNotification with early returns on invalid data.
    • Stop throwing on errors; log via log.error instead.
    • Keep click handling and subscription creator, publishing messenger events as before.
  • Removals:
    • Delete legacy service worker implementation and tests: services/push/push-web.ts and services/push/push-web.test.ts.
  • Tests:
    • Update web/push-utils.test.ts to cover invalid payload cases and adjusted handler behavior; remove error-throw assertions.
  • Docs/Meta:
    • Update CHANGELOG.md to note background push utilities now handle more edge cases without throwing.

Written by Cursor Bugbot for commit f2f8890. This will update automatically on new commits. Configure here.

@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner December 1, 2025 10:57
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing as these are never used or ever exported. It is safe to remove without introducing a breaking change.

@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner December 1, 2025 11:01
Comment on lines +135 to +136
// TODO - provide open-api unfied backend/frontend types
// TODO - we will replace the underlying Data payload with the same Notification payload used by mobile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Dec 1, 2025
Merged via the queue into main with commit 4033325 Dec 1, 2025
281 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the refactor/improve-push-notification-handling-utils branch December 1, 2025 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants