-
Notifications
You must be signed in to change notification settings - Fork 971
Implemented notification for user to backup Brave wallet #13504
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13504 +/- ##
==========================================
+ Coverage 56.54% 56.57% +0.02%
==========================================
Files 283 284 +1
Lines 29036 29100 +64
Branches 4824 4845 +21
==========================================
+ Hits 16419 16463 +44
- Misses 12617 12637 +20
|
app/browser/api/ledger.js
Outdated
@@ -1063,6 +1063,9 @@ const backupKeys = (state, backupAction) => { | |||
|
|||
if (backupAction === 'print') { | |||
tabs.create({url: appUrlUtil.aboutUrls.get('about:printkeys')}) | |||
|
|||
// we do not check whether the user actually printed the backup word list | |||
ledgerState.setBackupStatus(state, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to assign this call to the state, so that we actually save this change:
ledgerState.setBackupStatus(state, true)
-> state = ledgerState.setBackupStatus(state, true)
app/browser/api/ledger.js
Outdated
@@ -1079,8 +1082,10 @@ const backupKeys = (state, backupAction) => { | |||
if (file) { | |||
try { | |||
fs.writeFileSync(file, message) | |||
ledgerState.setBackupStatus(state, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
app/browser/api/ledger.js
Outdated
} catch (e) { | ||
console.error('Problem saving backup keys') | ||
ledgerState.setBackupStatus(state, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@NejcZdovc , how can I trigger notifications in development? |
@jasonrsadler which notifications? |
Oh I know which one. You can do it like this
Where xx is current window ID |
Yep. Got that. I meant the notification bar that comes down at the top of the webview? |
@jasonrsadler check out |
Got it! Thanks @NejcZdovc |
@@ -230,7 +230,7 @@ const showEnabledNotifications = (state) => { | |||
showReviewPublishers(now + ledgerUtil.milliseconds.day) | |||
} | |||
} else if (now - bootStamp > 7 * ledgerUtil.milliseconds.day) { | |||
if (noBackupKeys(state) && shouldShowNotificationBackupKeys()) { | |||
if (noBackupKeys(state) && shouldShowNotificationBackupKeys() && hasFunds(state)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrose17, during our coding session, we created hasFunds but the linter picked it up as unused. My assumption was the notification should be shown based on the original criteria and also (added above) if the user has actual funds in the wallet. Can you confirm this? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an interesting question: my thinking is that we don't need hasFunds
, it's a good idea for folks to keep a balance, regardless. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for including the security review issue. looks good to me. let's see what the security folks say.
@@ -230,7 +230,7 @@ const showEnabledNotifications = (state) => { | |||
showReviewPublishers(now + ledgerUtil.milliseconds.day) | |||
} | |||
} else if (now - bootStamp > 7 * ledgerUtil.milliseconds.day) { | |||
if (noBackupKeys(state) && shouldShowNotificationBackupKeys()) { | |||
if (noBackupKeys(state) && shouldShowNotificationBackupKeys() && hasFunds(state)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an interesting question: my thinking is that we don't need hasFunds
, it's a good idea for folks to keep a balance, regardless. wdyt?
"this is an interesting question: my thinking is that we don't need hasFunds, it's a good idea for folks to keep a balance, regardless. wdyt?" I could go either way. My initial thinking: |
@jasonrsadler - agreed. why not DM mandar and get his take on it? |
Per @mandar-brave - if the user has never added funds then don't show. Once the user has funds or has a zero balance but has added funds in the past then show. The question from the linked issue: |
great! please make it so! |
can we make sure brave-intl/bat-client#52 gets merged before this so that the backup notification shows the new code words? otherwise users may see some offensive words. |
Dismissing approval, per Jason's comment in https://github.com/brave/internal/issues/266#issue-313154893
@diracdeltas @NejcZdovc @mrose17 Blocked on brave-intl/bat-client#52 |
@NejcZdovc, is ledger.js -> onWalletProperties a good place to set a flag to tell us if the user has ever funded the wallet? |
js/constants/appConfig.js
Outdated
'payments.notification-backup-keys-count': 0, // number of times user has been notified to backup wallet | ||
// the intervals in days that the user should be reminded to backup wallet | ||
// if an out of bounds index is selected, it should default to monthly | ||
'payments.notification-backup-keys-interval': [7, 14], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the settings
/ defaultSettings
object is supposed to only be used for settings that are exposed in about:preferences such that the user can modify them.
can we avoid adding more non-user-exposed payments flags/timestamps to settings? unless i'm misunderstanding why they were added here in the first place.
seems like they should go in appState.ledger.about or appState.ledger.info (https://github.com/brave/browser-laptop/pull/13504/files#diff-b4e400e260f324745d12616a8c9c1fc6R185)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered about that myself. @mrose17 or @NejcZdovc would have to reply on that but I can move them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, let's move this into the state
@diracdeltas, would you give this another look? |
state = aboutPreferencesState.setPreferencesProp(state, 'backupNotifyTimestamp', nextTime) | ||
module.exports.showBackupKeys(nextTime) | ||
} | ||
if (process.env.LEDGER_NOTIFICATION) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.env.LEDGER_NOTIFICATION
-> process.env.LEDGER_VERBOSE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to put this under verbose? It would be nice if QA saw just the time passed rather than filter through all the other messages. Also, when run in the future, you'll get the time thrown out to the console every 5 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good point. Let's keep it like it is now
@@ -63,9 +72,12 @@ const init = () => { | |||
} | |||
|
|||
const onInterval = (state) => { | |||
if (process.env.LEDGER_NOTIFICATION) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.env.LEDGER_NOTIFICATION
-> process.env.LEDGER_VERBOSE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
js/actions/appActions.js
Outdated
@@ -1967,6 +1967,13 @@ const appActions = { | |||
duration, | |||
revisited | |||
}) | |||
}, | |||
|
|||
onLedgerBackupSuccess: function (success) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to pass variable in, where in reducer we just set true
and not use this variable?
app/common/state/ledgerState.js
Outdated
@@ -360,6 +360,11 @@ const ledgerState = { | |||
return state.setIn(['about', 'preferences', 'updatedStamp'], date) | |||
}, | |||
|
|||
getRecoveryStatus: (state) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used?
@jasonrsadler WDYT? [Turn Off Notifications] [Later] [Back Up Now] |
@bradleyrichter I'm good with that. Thanks. |
|
||
class LedgerBackupContent extends ImmutableComponent { | ||
copyToClipboard (text) { | ||
aboutActions.setClipboard(text) | ||
appActions.onLedgerBackupSuccess(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasonrsadler this is the only thing that I found, so I will just fix it and then I will merge this PR
WIP -- ensure backup status is assigned to the state WIP -- merging sync Added appAction to show backup keys Updated notifications text Added condition for backup notification only if the user has funds WIP -- Notification tests WIP -- notification tests wip WIP -- wip on tests WIP -- added constants to appConfig and completed unittests Fixed linting Removed notification trigger from debug menu WIP -- Updating wallet backup notification per criteria Added tests. Removed redundant function. spacing clean up Moved payments settings from defaultSettings to payments field Created aboutPreferencesState and moved ledger functions. Added Preferences Prop helpers to aboutPreferencesState Moved configs to state. bumped bat-client version merge fix Updated state.md Remove redundant function and usage Removed notification interval from state. minor code corrections lint Updated for null checks and updated tests Modifications for testing Removed unused methods Fixed spacing and reverted launch.json. Implemented process var for test Updating for test plan. Corrected backup and recovery timestamp writes Set clipboard action backup to set backup flag Updated to use updatedStamp vice recoverySucceeded lint Updated tests to reflect state passing Updated text for notification Updated QA interval lint Adding context menu option to bookmark/history entries to add their respective sites to the ledger Changes per CR, hiding context menu item when not applicable Exposing addSiteVisit and shouldTrackTab for unit testing, add initial manual addition unit tests Adding more tests for addSiteVisit/addNewLocation under manual addition Updated text for dismiss button on notification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ code looks good and works great. Thank you
Implemented notification for user to backup Brave wallet
Implemented notification for user to backup Brave wallet
Will work on reverting this- we decided to not include this in the 0.22.x-release3 build |
This reverts commit 99711a9. Auditors: @jasonrsadler
This reverts commit 99711a9. Auditors: @jasonrsadler
…p-remind"" This reverts commit b74e887.
Reverted the reverts after discussion and closed the PR to master which had the revert |
Resolves #13425
Unblocks #4847
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
FOR QA ONLY:
LEDGER_ENVIRONMENT=staging LEDGER_NOTIFICATION=true npm start
IN PRODUCTION:
Notifications will be displayed if the user has not backed up their keys and has not opted out:
after 7 days,
after another 14 days,
once a month thereafter
If user turns off ledger notifications or backs up their wallet (or recovers a wallet) then this notification will not show.
Backup or Recovery action consists of:
Preferences->Payments->Advanced Settings
unittest -- --grep="showBackupKeys" for simulated
Reviewer Checklist:
Tests