-
Notifications
You must be signed in to change notification settings - Fork 885
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
Import Brave Payments data from Muon #736
Conversation
--- a/chrome/common/importer/importer_data_types.h | ||
+++ b/chrome/common/importer/importer_data_types.h | ||
@@ -31,7 +31,8 @@ enum ImportItem { | ||
@@ -31,7 +31,9 @@ enum ImportItem { | ||
SEARCH_ENGINES = 1 << 4, | ||
HOME_PAGE = 1 << 5, | ||
AUTOFILL_FORM_DATA = 1 << 6, | ||
- ALL = (1 << 7) - 1 // All the bits should be 1, hence the -1. | ||
+ STATS = 1 << 7, |
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 think we can replace this with just a generic BRAVE
import type?
@@ -10,23 +10,27 @@ index 625b5ddec268292acf11f3c060c07c336ca1317f..1738d9d68a93ec1940688caa3352d55f | |||
import "url/mojom/url.mojom"; | |||
|
|||
const string kProfileImportServiceName = "profile_import"; | |||
@@ -31,6 +32,9 @@ struct FaviconUsageDataList; | |||
@@ -31,6 +32,12 @@ struct FaviconUsageDataList; | |||
[Native] | |||
struct ImporterIE7PasswordInfo; | |||
|
|||
+[Native] |
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, I think we can combine all Brave-specific data together
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.
@bridiver I think we should keep them separate to allow for user choice when importing from Brave/Muon. For example, what if a user wants to import their stats but not their wallet, or vice versa?
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.
but is this necessary for that to happen? Can't we still group it together even if it isn't all there for any given import?
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.
BraveExternalProcessImporterHost::StartImportSettings still gets the full list of selected items if we keep those split out, so maybe we keep the individual items, but group the import into a single method?
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.
and actually I thought this was a silent automatic import?
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.
and actually I thought this was a silent automatic import?
We need to support both the silent automatic import case and the manual import case (i.e. former browser-laptop user downloads Brave-Core from website and installs it, then decides they want to import their old browser-laptop data). The importer code is identical between the use cases. The specifics of the silent automatic import case are handled in a separate PR (#729); among other things, it assumes the user wants to import all supported importer data types.
|
||
mojom = "//chrome/common/importer/profile_import.mojom" | ||
public_headers = [ | ||
+ "//brave/common/importer/brave_ledger.h", |
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.
and again here, even if we couldn't combine the data, we should certainly combine the header files so we only have to patch once. We should always be looking for places where we can create extension points that allow us to make additional changes without additional patches
patches/chrome-common-importer-profile_import_process_param_traits_macros.h.patch
Outdated
Show resolved
Hide resolved
patches/third_party-blink-renderer-core-layout-intersection_geometry.cc.patch
Outdated
Show resolved
Hide resolved
internally we can split out stats, ledger, etc.., but from an upstream importer perspective I think we should combine it all together |
@@ -16,6 +16,12 @@ index fdd6f9d2265fe069d159ceed6e1e7ec561a2915e..e0dee6f2af7b92dd2b7f88fefbfda92f | |||
+ pref="{{prefs.import_dialog_stats}}" | |||
+ label="$i18n{importStats}"> | |||
+ </settings-checkbox> | |||
+ <settings-checkbox |
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 think there might be a way to do a template include
here that could wrap all of this and move the actual source to brave-core. Not 100% sure though
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.
in either case for this and the one below, do we need separate checkboxes for all of these? If we do that's fine, just seems like it could be consolidated. Also won't this show up for non-Brave imports? That might be a little confusing?
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.
in either case for this and the one below, do we need separate checkboxes for all of these?
I think we do want separate checkboxes, again so users can decide what specific types of data they want to import from Brave. e.g. I can imagine plenty of users might want to keep their stats but their wallet hasn't been working and they'd like to start over fresh there.
Also won't this show up for non-Brave imports?
No, see how services_supported is set for each importer in importer_list.cc
.
patches/chrome-browser-ui-webui-settings-md_settings_ui.cc.patch
Outdated
Show resolved
Hide resolved
@@ -12,16 +12,18 @@ index 864a6951115dda5ed74963f18b35692960397d50..ba056b13fbae07f151286f531e1a8d86 | |||
struct ImportedBookmarkEntry; | |||
class InProcessImporterBridge; | |||
+struct BraveStats; |
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'm not sure that this patch is necessary either because we can cast as mentioned in the other case, but might still be necessary to match up with the mojom file
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.
if we do need to keep these changes, we could combine the patch with a chromium_src override. The override could insert the struct
and I think we could define a macro in the header override that would insert all the methods with a single one-line patch
Will this import Brave Payments information... even if the person disabled Payments? (ex: maybe they turned it off because they were upset)? A use-case for when the person had it disabled (but HAS a wallet with tokens in there) might be that they didn't like auto-contribute. We have the opportunity to import the wallet... but turn ONLY auto-contribute off |
A heads up on a possible edge-case scenario (we'd have to install an old version to verify)... but the first rev of Payments was done using Bitcoin. This also used the ledger-state.json... and is detectable (I think we removed the detection logic though) If the wallet address is a Bitcoin address, we should skip importing the payments (and it might be possible to help those folks recover funds manually) |
I am currently importing whatever payments data I can find, regardless of whether payments was enabled in browser-laptop |
82b12cb
to
a0b077c
Compare
a0b077c
to
7c221a3
Compare
2d23a95
to
11a722b
Compare
fdb898e
to
d034cb6
Compare
09123e2
to
9a479a0
Compare
There are a few TODOs to sort out, but this is basically ready for review Please note: the wallet restore (when compiled locally) will use the staging environment. If you'd like to restore a prod wallet, you need to add the proper command line flag |
…s values from BraveImporter to BraveProfileWriter
- Implements pinned logic captured in brave/brave-browser#1910 - Tip amount in BAT is calculated based on % of monthly contribution. If < 1 BAT, pin is ignored. - Any amounts spent towards tipping are deducted from monthly budget - If monthly budget is below lowest value (15 BAT), auto-contribute is disabled - Log error (and result code) when RestoreWallet is not successful - Set contribution amount (again) after RestoreWallet, since we found this is adjusted - Created new `kBravePaymentsPinnedItemCount` profile preference (present after import) for use with brave/brave-browser#1910 - Remove unused wallet_seed code
- If wallet exists, import will be cancelled - In other failure scenarios, import will be cancelled - Observer is now added (in writer) after validation (to prevent dcheck failure on cancel)
- Create wallet BEFORE restore is done - Call SetUserChangedContribution() before changing contribution amount - Contribution amount is only set AFTER the restore - Handle popular use-case where contribution amount isn't set (ex: Muon would default them; only choosing it would set the value) - Update lines to be 80 chars (or less) per review feedback
- Remove chrome-common-importer-importer_bridge.h.patch - Replace patch with chromium_src override - Replace patches with chromium_src overrides - Remove workaround for DCHECK that appears fixed - Remove patch, register importer prefs in brave_profile_prefs.cc instead - Remove forward declarations in ExternalProcessImporterClient patch
If a Rewards wallet exists prior to import, ledger_state is now backed up before attempting to recover
- Revert "Remove chrome-common-importer-importer_bridge.h.patch" This reverts commit e6706b1. - Use chromium_src to minimize patches - Remove unnecessary include - Fix header include position
- removed un-used `clobber_wallet` param - added validation for previously unvalidated fields - pulled common cancel logic into common method (ProfileWriter) - any parsing attempts are considered fatal; returns immediately - properly handle reference to this when calling PostTaskAndReplyWithResult - add dcheck for bridge_ptr_ - put `importer/brave_ledger.*` under !is_android block - update CHECK to be DCHECK for ProfileWriter destructor - use regular profile (ex: don't call GetOriginalProfile) in ProfileWriter - remove signature from PostTaskAndReplyWithResult call
- Update browser import name from "Brave" to "Brave (old)" - Updated import type name from "Ledger" to "Brave Payments" - Removed debug log statement - Removed explicit call to `SetUserChangedContribution` (call instead made inside RewardsServiceImpl)
90a1b3b
to
5aff1eb
Compare
Great catch @LaurenWags - I captured brave/brave-browser#2265 for the issue you saw and have already started to work on a fix. The values ARE being set properly, however the UI is not respecting 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.
👍 from me
Import Brave Payments data from Muon
Import Brave Payments data from Muon
Import Brave Payments data from Muon
Test plan
Happy path
~/Library/Application Support/BraveSoftware/Brave-Browser-Development
or%USERPROFILE%\AppData\Local\BraveSoftware\Brave-Browser-Development
)npm start
). If you chose a production profile for step 4, then you'll want to start like:npm run start -- --rewards=staging=false --vmodule=*rewards*=6
(local builds default to STAGING)chrome://settings/importData
Brave
Ledger
shows upImport
npm start
)Allow contribution to non-verified sites
Allow contribution to videos
Monthly Payment
- The actual contribution amount (see testing notes)Minimum visits for publisher relevancy
Minimum page time before logging a visit
Tips
- recurring. these are sites which were Pinned in Muon (see testing notes)When Muon Brave does not have rewards enabled
When user doesn't have rewards enabled in Muon Brave, the ledger import should basically do nothing. Ideally, it wouldn't show as an option in the import list.
Testing notes
There are some important considerations when verifying the preferences and amounts carried over 😄
Auto-Contribute
is decreased by the amount of recurring tips. For example, if user has monthly contribution of 20 BAT and they end up with 5 BAT in recurring tips, the auto-contribute amount would then be 15 BAT.Original description
Looking for feedback on this WIP PR for brave/brave-browser#1215. This PR currently handles the plumbing for a new importer data type—currently called "ledger", though I expect we may want to change that to "Brave Payments" throughout—and has an example of importing data from Muon's user data directory in the utility process and passing it over IPC to the browser process.
The most pertinent remaining questions are:
Since these are broad and open questions, the best place for feedback is in the following design docs: