Skip to content

feat: track coinbase buy events - #879

Merged
HashEngineering merged 95 commits into
feature-coinbase-integrationfrom
feature-coinbase-buy-events
Feb 15, 2022
Merged

HashEngineering merged 95 commits into
feature-coinbase-integrationfrom
feature-coinbase-buy-events

Conversation

@ClaudeHangui

@ClaudeHangui ClaudeHangui commented Jan 26, 2022 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

This PR focuses on tracking buy events related to a Coinbase user

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Syn-McJ and others added 30 commits December 14, 2021 13:00
…itory and an implementation for the interface

- set up web services for payment_methods, place_buy_order, commit_order and send_funds_to_wallet
…to feature-buy-dash-data

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
…_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
…r_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
…_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
…1131_Buy_Dash_UI_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
…i models

- update implementation in CoinBaseRepository.kt and CoinbaseServicesViewModel.kt to for buy/commit/send flows
…to feature-buy-dash-data

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
…t.kt

- change user authorization scope for coinbase in CoinBaseWebClientActivity.kt
- inject wallet data provider in WalletDataProviderModule.kt
- update calls to get payment methods, place/commit buy orders and send funds to dash wallet
…1131_Buy_Dash_UI_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseBuyDashFragment.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
#	wallet/src/de/schildbach/wallet/ui/coinbase/CoinBaseWebClientActivity.kt
- observe coinbase logout with livedata
- update implementation to open Coinbase portal upon coinbase authentication
…to bugfix-refresh-buy-sell-ui

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/Constants.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/repository/CoinBaseRepository.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
#	wallet/src/de/schildbach/wallet/ui/BuyAndSellLiquidUpholdActivity.kt
#	wallet/src/de/schildbach/wallet/ui/BuyAndSellViewModel.kt
- use lamdas to handle click on Buy & Sell dash items
…to feature-coinbase-buy-events

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
#	wallet/src/de/schildbach/wallet/ui/BuyAndSellLiquidUpholdActivity.kt
…to feature-coinbase-buy-events

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/dialogs/CancelTransactionDialog.kt
.noCode().minDecimals(2).optionalDecimals()

private var onCurrencyToggleClicked: (() -> Unit)? = null
private val analytics = FirebaseAnalyticsServiceImpl.getInstance()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ClaudeHangui it's better to use Hilt for injecting the analytics service. getInstance() method was added when we didn't have DI in the wallet.

Comment on lines +111 to +114
analytics.logEvent(if (dashToFiat) AnalyticsConstants.Coinbase.ENTER_AMOUNT_DASH
else AnalyticsConstants.Coinbase.ENTER_AMOUNT_FIAT,
bundleOf()
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this is a common component, then would not this log all currency direction changes as being from the coinbase module?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree, this is related to my previous comment. The fact that we cannot easily inject AnalyticsService into this component is the first indication that logs are made at the wrong level. DashToFiat should be propagated through the viewModel into the coinbase and logged in there.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should that be the case for all of the component classes? The Fragment that is using them and responding to events from the component should log the event, rather than the component itself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, that should be the case. Common components should only be responsible for their own functionality and shouldn't know or care about event logging.

private var loadingDialog: FancyAlertDialog? = null
private var currentExchangeRate: org.dash.wallet.common.data.ExchangeRate? = null

@Inject lateinit var analyticsService: FirebaseAnalyticsServiceImpl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When injecting, wouldn't it be:

     @Inject lateinit var analyticsService: AnalyticsService

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

one comment left above.

binding.continueBtn.setOnClickListener {
if (!binding.amountView.showCurrencySelector) {
analyticsService.logEvent(
AnalyticsConstants.Coinbase.CONTINUE_DASH_PURCHASE,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ClaudeHangui this is still wrong. Common components should only be responsible for their own functionality and shouldn't know or care about event logging. Events should be propagated down to the end-user (conbase module in this case) and logged in there.

Otherwise, we'll end up with a tree of if-else that checks for coinbase vs crowdnode vs etc logs. This breaks both single-responsibility and open-closed principles.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you guys are absolutely right !

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This has been addressed, so I will merge this story.

…baseServicesFragment.kt

- propagate logging of Coinbase events from EnterAmountFragment.kt to CoinbaseBuyDashFragment.kt
showSearch = false
) { _, index, dialog ->
dialog.dismiss()
analytics.logEvent(AnalyticsConstants.Coinbase.CHANGE_PAYMENT_METHOD, bundleOf())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here remains a logged event inside a common component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in last push

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

excellent.

@HashEngineering
HashEngineering self-requested a review February 15, 2022 01:44

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Excellent, this is ready to merge.

@HashEngineering
HashEngineering merged commit 9d7dec6 into feature-coinbase-integration Feb 15, 2022
@Syn-McJ
Syn-McJ deleted the feature-coinbase-buy-events branch March 23, 2022 08:00
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.

4 participants