Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add push notifications #2369

Merged
merged 70 commits into from
Sep 25, 2023
Merged

feat: add push notifications #2369

merged 70 commits into from
Sep 25, 2023

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Aug 8, 2023

What it solves

Implements push notifications for transaction events.

How this PR fixes it

New "Notifications" settings sections have been added per-Safes/all added Safes, as well as a feature banner and associated tracking has been added. Subscribed categories dispatch push notifccations when the Safe UI is either out of focus or closed (but the browser is open).

The per-Safe "Notifications" section allows for notification subscription to all notification types, requiring a confirmatory signature as "Confirmation requests" are included. The global section is similar, subscribing to user selected (added) Safes with n number of signatures per selected chain.

Notifications are grouped into three categories: "Incoming transactions", "Outgoing transactions" and "Confirmation requests" according to our Transaction Service webhooks.

  • Incoming transactions
    • INCOMING_ETHER
    • INCOMING_TOKEN
  • Outgoing transactions
    • MODULE_TRANSACTION
    • EXECUTED_MULTISIG_TRANSACTION
  • Confirmation requests
    • CONFIRMATION_REQUEST

A banner is shown once per chain that has added Safes, subscribing to notifications for all added Safes on that chain.

User interaction within the UI is tracked directly. Due to technical limitations, direct notification interaction events (opening/closing) are cached and tracked when the UI is again opened. Moved to a separate PR #2500.

How to test it

⚠️ Due to the complexity of this feature, I would advise explaining the feature on a call and maybe even testing it together. ⚠️

  1. Registering for notifications should succeed, showing a notification and then displayind them accordingly when the Safe UI is not in focus or is closed (but the browser is open).
  2. Unregistering a Safe should only unregister itself if there are others subscribed to on that chain or the entire device if it is the last Safe subscribed to on that chain.
  3. Tracking of user interaction should happen immediately.
  4. Tacking of notification iteraction should happen when the UI is reopened. (Moved to a separate PR feat: add push notification tracking #2500).
  5. The MacOS info banner should only show on Mac devices.

If you want to reset your current registration, you need to:

  • Reset browser notification permissions
  • Unregister the sw.js service worker
  • Delete all firebase-*/notification-* IndexedDB databases
    image

If you want to show the subscription banner again, you need to delete the SAFE_v2__dismissPushNotifications localStorage key.

Screenshots

image

image

image

image

Please note that these are slightly dated but just demonstrate the notification. See the designs.

notification

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@iamacook iamacook self-assigned this Aug 8, 2023
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Branch preview

✅ Deploy successful!

https://firebase--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@iamacook iamacook marked this pull request as draft August 8, 2023 14:32
@github-actions
Copy link

github-actions bot commented Aug 17, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@iamacook iamacook linked an issue Aug 17, 2023 that may be closed by this pull request
@iamacook iamacook changed the title [PoC] feat: implement Firebase Cloud Messaging feat: implement Firebase Cloud Messaging Aug 22, 2023
package.json Show resolved Hide resolved
})
}, [dismissedBannerPerChain, safe.chainId, setDismissedBannerPerChain])

// Click outside to dismiss banner
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would be in favour of having an explicit "x" Button since pressing outside the banner can happen by accident.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. We're using the same style as the batch banner atm. @liliiaorlenko, what are your thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

As per discussion, I've added a close button to the banner which also negates the above comment regarding the tracking.

image

src/components/settings/PushNotifications/index.tsx Outdated Show resolved Hide resolved
src/components/settings/PushNotifications/logic.ts Outdated Show resolved Hide resolved
src/hooks/useDecodeTx.ts Outdated Show resolved Hide resolved
Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

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

Works great and thanks for implementing the changes 👍

Will discuss the notification dismissal tomorrow but it is non-blocking imo. LGTM 🚀

* feat: add push notification tracking

* fix: address review comments

* fix: error message
@liliya-soroka
Copy link
Member

liliya-soroka commented Sep 18, 2023

  • Feedback: A notification banner is displayed for the safe with enabled notifications through Global settings. It's confusing, as I just enabled and signed notifications enabling for this safe
image Steps: 1. make sure that you have a few safes in the app on different networks 2. run app 3. Select Enable Notifications using Global settings 4. enable notifications for all your safes 5. come back to the safes list and switch to the safe on another network Current result: Notifications banner is displayed

@github-actions
Copy link

github-actions bot commented Sep 25, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@francovenica
Copy link
Contributor

francovenica commented Sep 25, 2023

Looks good.
The ticket was checked by several people, in windows and mac for the different type of notifications.
Checked the notification for incomming tokens, outgoing tx (which is not just tokens, is the execution of any tx) and the confirmation requests.
All the issues reported in the QA document were fixed or discussed: https://www.notion.so/safe-global/QA-Feedback-for-notifications-epic-2391-557125a8a91240a59903655e0cfc3bd3

A few notes for future iterations that we might want to revisit:
You get a notification for every tx executed in a "bulk transaction execution".
The "Confirm request" only works for safes with at least 3 owners and a policy of at least 2. I assume this is cuz for a threshold of 1 you don't need to confirm anymore, and if the safe has 2 owners, the tx 2nd confirmation needed is a "sign and execute" which I believe is different from a "just confirm" type of signing.

@iamacook iamacook merged commit 301facc into dev Sep 25, 2023
9 checks passed
@iamacook iamacook deleted the firebase branch September 25, 2023 16:28
@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Epic] Push notification
6 participants