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

Shopper Insights - Merchant analytics #869

Merged
merged 5 commits into from
Dec 21, 2023

Conversation

saperi22
Copy link
Contributor

@saperi22 saperi22 commented Dec 20, 2023

Summary of changes

DTBTSDK-3296

  • Adding methods for merchants to send analytic events for shopper insights feature.

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@saperi22 saperi22 requested a review from a team as a code owner December 20, 2023 21:40
@@ -1,6 +1,10 @@
package com.braintreepayments.api

import androidx.annotation.VisibleForTesting
import com.braintreepayments.api.ShopperInsightsAnalytics.PAYPAL_PRESENTED
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be my lack of Android knowledge but can we just do import com.braintreepayments.api.ShopperInsightsAnalytics or do we need to import each event individually?

Copy link
Contributor

Choose a reason for hiding this comment

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

In other modules we have been fully qualifying the events when used (ex: on line 61 braintreeClient.sendAnalyticsEvent(ShopperInsightsAnalytics.PAYPAL_PRESENTED)) that being said, either way is fine with me

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, we could use a wildcard import here import com.braintreepayments.api.ShopperInsightsAnalytics.*, but Google is opinionated about import statements. https://developer.android.com/kotlin/style-guide#import_statements

I think there are pros and cons to both ways, but Android Studio is pretty good at formatting imports and auto imports.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thanks for sending over that doc!

Copy link
Contributor Author

@saperi22 saperi22 Dec 21, 2023

Choose a reason for hiding this comment

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

Some of the cons of using wildcard imports might no longer apply to kotlin, as it gives us a way to use import alias as shown below, but the tools and practices are slower to catch up to the capabilities of the newer languages, so we just go with whatever the tools suggest :D

But yeah, no reason not to use wild card imports in this current scenario.

Example of import alias.

import org.example.Message // Message is accessible
import org.test.Message as TestMessage // TestMessage stands for 'org.test.Message'

See: https://kotlinlang.org/docs/packages.html#imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you are interested, here's how things could go wrong using wildcard imports.
https://www.javadude.com/posts/20040522-import-on-demand-is-evil/

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a way to turn off autogen of import * in Android Studio in preferences, I forget exactly where.

@saperi22 saperi22 merged commit 883ef28 into payment-insights-complete-feature Dec 21, 2023
3 checks passed
saperi22 added a commit that referenced this pull request Jun 13, 2024
* Create PayPalMessaging Module (#847)

* added new module for paypal-messaging
* Created empty PayPalMessagingClient.kt and PayPalMessagingClientUnitTest.ktclass files
* Added AndroidManifest.xml to this module
* Created build.gradle to include necessary dependencies and settings

Co-authored-by: Jax DesMarais-Leder <[email protected]>

* Add Payment Insights Client public API shell (#844)

* Added Shopper Insights client, request, result, stubs and docs

* Added Shopper Insights client unit test

Added Shopper Insights client unit test

* Added insight callback updated unit test

* adding unit test documentation

* remove coroutines

* add new line

* remove open

* fix detekt

* Update BraintreeCore/src/main/java/com/braintreepayments/api/BraintreeShopperInsightsClient.kt

Co-authored-by: Sarah Koop <[email protected]>

* rename ShopperInsightsClient

* lighten ShopperInsight docs

* change ShopperInsightRequest from val to var

* remove special char e.g.

* rename response to info

* Add Email and Phone request sub classes with unit tests

* rename methods

* updated unit tests

* Added Email and Phone data class

* Add docs and make interface a functional interface

* simplify syntax

* updating dependency

* Rename parameters

* fix lint issues

* Addressing PR comment: making email a simple string

* fix tests

* Refactoring tests

* linter fixes

* refactoring

* Renaming class

* formatting

* compact code

* add docs

* add kdoc

* more kdocs

* use constants for key strings

* fix suppress params

* Update BraintreeCore/src/test/java/com/braintreepayments/api/ShopperInsightsClientUnitTest.kt

Co-authored-by: sshropshire <[email protected]>

* Rename classes

* Address PR comments.
Move the object to json conversion to API class

* move class to its own file

* Change the ShopperInsightsRequest class signature

* Moving the validation logic

* adding kdoc

---------

Co-authored-by: Sarah Koop <[email protected]>
Co-authored-by: saperi <[email protected]>
Co-authored-by: saperi22 <[email protected]>
Co-authored-by: sshropshire <[email protected]>

* Create ShopperInsights module and move files there. (#853)

* Create ShopperInsights module and move files there.

* Add EOF line

* Add README.md to the module

* clean up dependencies

* Refactor classes to standard package name

* remove unused files

* Modify release.yml to include newly created ShopperInsights module

* Modify release_snapshot.yml to include newly created ShopperInsights module

* remove example instrumented test

* update dependencies

* add dokka plugin to ShopperInsights module

* removing readme

* Add PayPal Messaging Release Steps (#863)

* Add testing PayPalMessaging to GitHub workflows
* Add PayPalMessaging to build.gradle

* Add Shopping Insights Demo App Integration (#854)

* Add Shopping Insights Fragment

* move insight row

* added shopping insight vm, ui and integration

* fix linting

* Add email and phone null switches

* remove unused import

* import ShopperInsights module

---------

Co-authored-by: Sai <[email protected]>

* rename PayPalMessagingClient to PayPalMessagingView (#870)

* Shopper Insights - Merchant analytics (#869)

* Add events for merchant analytics

* Add API for merchants to call to send shopper insights analytics events

* Adding tests

* fixing lint issue

* Use constants instead of sealed class for analytics event strings

* Adding PayPal and Venmo apps installed check (#872)

* Checking if PayPal and Venmo are installed and returning a success result.

* fix linter

* Change logic to check if both Venmo and PayPal apps are installed

* refactoring logic

* rename class

* Wire up demo app

* rename ShoppingInsights to ShopperInsights

* adding another test

* modify tests

* refactor logic

* Created Shopping Insight Api request with default values

* Created Shopper Insight Api Result

* change api result to camel case

* fix

* create body and api separate classes

* fix unit test

* fix detekt

* remove gson

* add ShopperInsightApiResultTest

* change to internal

* separate data class files

* drop call name from shopping api class

* remove vault tokens not needed

* renamed to ShopperInsightsApi

* var to val for request data

* fixed name shoppingInsightsApi

* removed options and default from ShopperInsightsPaymentMethodDetails

* rename to eligibleInPayPalNetwork

* fix eligibleInPayPalNetwork

* fixed json optional object

* rename to ShoppingInsightsCreateBodyUnitTest

* fix ShopperInsightApiResultUnitTest

* Adding analytics events for Shopper Insights (#882)

* move toJson into shopper request api

* create shopper api wrapper class for client

* fix gradle missing empty space

* reorganize and renamed classes

* update class docs

* move out of findeligiblepayments package

* remove Find

* match class name eligiblePaymentsApi

* Add PayPal Messaging Dependency (#888)

* add PayPal Messages dependency
* update build.grade to reflect min SDK version and import snapshots
* add TODO to remove importing snapshots before release
* add rootProject.minSdkVersionPayPalMessaging

* Paypal Messaging Implementation (#895)

* Add PayPalMessagingRequest, PayPalMessagingColor, PayPalMessagingLogoType, PayPalMessagingOfferType, PayPalMessagingPlacement, PayPalMessagingTextAlignment, and PayPalMessagingListener
* Add PayPalMessagingView as the main entry point for merchants

* Messaging analytics

* Add network call for shopper insights (#894)

* add network call using bt client

* add authorization header

* pass result to demo app

* use bearer token

* fix linting

* add move url todo

* fix detekt

* Update BraintreeCore/src/main/java/com/braintreepayments/api/BraintreeHttpClient.kt

Co-authored-by: sshropshire <[email protected]>

* suppress CyclomaticComplexMethod

* check httpError

* return httpError if responseBody is null

* use config environment for base url

* add eligible payments api unit test class

* Update API response logic in ShopperInsightsClient and add test coverage for BraintreeHttpClient, EligiblePaymentsApi and ShopperInsightsClient

* Use BraintreeException instead of a NullPointerException

---------

Co-authored-by: sshropshire <[email protected]>
Co-authored-by: Timothy Chow <[email protected]>

* Address PR comments

* Remove App Check From Shopper Insights and Analytics Updates (#909)

* Remove app check from Shopper Insights and update analytics logic

* Fix test names

* Add function for callbackSuccess

* update enum for analytics event names

* Helper method for onSuccess

* Adding new line

* Remove .value

* Remove semicolon on package

* Add PayPal-Client-Metadata-Id to Shopper Insights API Call (#912)

* Add PayPal-Client-Metadata-Id to shopper insights API call

* Fix spacing lint issue

* Remove unneeded empty map in ApiClient

* Add PayPal Messaging Feature to Demo App (#915)

* Add PayPalMessagingFragment to Demo app
* Add button to demo app to select this feature
* Implement PayPalMessagingView
* Update PayPalMessagingView method and subclass FrameLayout so the class is a view type
* Move context to constructor vs in start method as it is needed for FrameLayout subclass
* Update CHANGELOG with these changes

* [Shopper Insights] Demo App Parity (#913)

 - Add Venmo & PayPal Vault buttons to ShopperInsights demo
    - Disable Venmo & PP buttons until `getRecommendedPaymentMethods()` result
 - Add default email & phone test values to trigger mocked API response

* Add optional param, payerEmail, to PayPalVaultRequest (#918)

* Cleanup PayPal Messaging Implementation (#927)

* Move to setListener() pattern used in other modules
* Remove unneeded else block

* Remove payee and merchant id from eligible payments API request (#929)

* Add Unit Tests for PayPal Messaging (#925)

* Add Unit Tests for PayPal Messaging feature

Co-authored-by: Justin Warmkessel <[email protected]>

* DocString on Country Restrictions

* fix line length lint error

* Jax PR feedback

* Add merchant logging in the Shopper Insights demo flow (#933)

* Update Dependencies (#936)

* Update Room to 2.6.1 and Dokka to 1.9.10

* Update gson to 2.10.0 in the demo module

* Update Play Services to 19.3.0

* Add network config for Demo app (#938)

* Add has user location consent to Data Collector and PayPal Data Collector (#954)

* Add hasUserLocationConsent param to the Data Collector and PayPal Data Collector modules

* Add unit tests for overloaded methods defaulting to false

* Add deprecation annotation and add feature branch snapshot trigger

* Add test case when request object is passed in

* Add workflow dispatch

* Add has user location consent param in PayPal, PayPal Native, and Local Payment modules (#956)

* Add hasUserLocationConsent parameter to the PayPal module

* Add hasUserLocationConsent parameter to the PayPal Native module

* Add hasUserLocationConsent parameter to the Local Payment Module

* Update changelog for hasUserLocationConsent interface changes

* Update changelog for Data Collector and PayPal Data Collector

* Update changelog wording and change unit test assertion

* Update PayPalNativeCheckout/src/main/java/com/braintreepayments/api/PayPalNativeCheckoutVaultRequest.java

Co-authored-by: Sarah Koop <[email protected]>

* Add empty constructor for PayPalRequest

---------

Co-authored-by: Sarah Koop <[email protected]>

* Update PULL_REQUEST_TEMPLATE.MD (#957)

* Add GooglePay.isReadyToPay() with Context Parameter (#951)

* Add isReadyToPay method for GooglePayClient with Context.

* Add unit tests for GooglePayClient application context when calling isReadyToPay.

* Fix error message for null context in GooglePayClient.isReadyToPay.

* Fix unit test issue.

* Add CHANGELOG entry.

* Update Magnes SDK and Add Javadocs for the hasUserLocationConsent Param (#961)

* Update Magnes SDK to 5.5.0 and add javadocs for the hasUserLocationConsent param in Local Payment and PayPal modules

* Revert PayPalNative interface changes

* Add docs for DataCollector and PayPalDataCollector

* Update CHANGELOG.md to add Magnes version bump

Co-authored-by: Sarah Koop <[email protected]>

* Bump Detekt to 1.23.6 for ignoring maxLineLength for comments that contain URLs

---------

Co-authored-by: Sarah Koop <[email protected]>

* Remove changlog links to developer docs for the Google Play Store Rejection fix

* Update PayPal/src/main/java/com/braintreepayments/api/PayPalCheckoutRequest.java

Co-authored-by: Sarah Koop <[email protected]>

* Use new constructor for LocalPaymentRequest

* Fix indent for Google Play changelog

Co-authored-by: Sarah Koop <[email protected]>

* Remove internal javadoc

Co-authored-by: Sarah Koop <[email protected]>

* Fix indent for Google Play changelog and move riskCorrelationId into PayPalDataCollector

* Fix javadoc syntax

* Fix compile error in PayPalDataCollectorTest (#967)

* Release 4.44.0

* Prepare for development

* Add Google Pay Direct Integration (#972)

* Make direct Google Pay integration method public

* Add new certs to v4 (#969)

* Updated expiring certs

* Update CHANGELOG.md

* Updated cert output file

* PayPal Native - Play Store Compliance Fix (#977)

* Bump MXO SDK to 1.3.2 and bump Magnes SDK to 5.5.1

* Add hasUserLocationConsent boolean to PayPal Native request classes and pass flag to the MXO SDK and Magnes

* Add sections to CHANGELOG.md

Co-authored-by: Sarah Koop <[email protected]>

* Update hasUserLocationConsent doc to remove optional

Co-authored-by: Sarah Koop <[email protected]>

* Make PayPalNativeRequest constructor package private

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* Release 4.45.0

* Prepare for development

* Remove duplicate test

* Buyer Email for PayPal One Time Checkout (#978)

* Pass buyer email to PayPal one time checkout

* Update changelog

* Add input for setting buyer email address in the demo app (#979)

* Send `link_type` FPTI tag (#976)

* Add linkt type parameter used by Venmo Client

* Fix some UTs

* Add description on CHANGELOG

* Update UTs

* Address PR comments

* Migrate database

* Delete unnecessary file

* Fix lint

* Fix lint

* Add database migration support from version 1 to version 3

* Revert changes on v2 json file

* Remove unnecessary manual migration

* Add ExperimentalBetaApi annotation (#985)

* Add ExperimentalBetaApi annotation

* Add kdocs to annotation class

* Add New Demo Tokenization Key for PayPal (#996)

* Add new tokenization key

* Fix keys and settings

* Bump PayPal Messages to v1.0.0 develop.2 (#981)

* Update Gradle with PayPal Messages 1.0.0-develop.2

* Replace PayPalMessagingPlacement with PayPalMessagingPageType

* Update PayPalMessagingRequest

* Fix UTs

* Update CHANGELOG

* Add version SDK name method on Braintree Client

* Rename PayPalMessagingLogoType case simple to none

* Update UT

* Remove getter and add Version Name on gradle file

* Fix UTs

* Replace rawValue with internalValue

* Replace default logo type and textAligment values with the same default values in PayPalMessageStyle

* Revert color parameter on request constructor

* Revert Request default values

* Update README - Added upgrade SDK message (#994)

* Update README - Added upgrade SDK message

* Added Announcements section

* Handle empty email address (#1000)

* Prevent sending email param when email is empty and send postal code in the demo app

* Use put instead of putOpt

* Add `venmo_installed` Analytics tag (#991)

* Add venmo_installed Analytics tag

* revert changes to 3.json

* fix lint error

* fix autoMigration

* venmoInstalled in BraintreeClient

* Steven PR feedback: deviceInspector init in constructor

* Write venmoInstalled values to analytics db

* Steven PR feedback, incremental database migration

---------

Co-authored-by: Sai <[email protected]>

* Add requiresOptin (#1001)

* Add ExperimentalBetaApi annotation

[email protected]
[email protected]

---------

Co-authored-by: Sai <[email protected]>

* Paypal messaging feature update dependency (#1002)

[email protected]
[email protected]
[email protected]

* Update the unit test

* Update to dependency 1.0.0

* Add isEligibleInPayPalNetwork boolean to ShopperInsightsInfo (#1005)

* Add isEligibleInPayPalNetwork boolean to ShopperInsightsInfo

* Add kdoc for isEligibleInPayPalNetwork

* Add Shopper Insights to the changelog (#1006)

* Add Shopper Insights to the changelog

* Remove individual classes

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* Send `is_vault` FPTI tag (#1004)

* Update Analytics database with isVaultResquest parameter

* Add isVaultResquest keys on client

* Update BraintreeClient.sendAnalytics with isVaultRequest parameter

* Add isVaultRequest in sendAnalytics calls for PayPalClient

* Add isVaultRequest in semdAnalytitcs calls for VenmoClient

* Set isVaultRequest up on VenmoClient

* Update AnalyticsClientTests

* Update PayPal client tests

* Update CHANGELOG

* Fix lint

* Fix VisaCheckout module after adding new parameter in sendAnalyticsEvent

* Fix Venmo Client UTs

* Update PayPalNativeCheckoutClient with isVaultRequest parameter in sendAnalytics method

* Update Changelog

* Update CHANGELOG

* Update Changelog

* bump paypal messaging to version 1.0.1 (#1010)

* Chore messaging set global analytics (#1007)

* Use PayPalMessageConfig setGlobalAnalytics for integration and version

[email protected]
[email protected]
[email protected]

* Update PayPalMessaging/src/main/java/com/braintreepayments/api/PayPalMessagingView.kt

Co-authored-by: Jax DesMarais-Leder <[email protected]>

---------

Co-authored-by: Jax DesMarais-Leder <[email protected]>

* Update PayPalInternalClient to use Pairing ID as Client Metadata ID (#983)

* Update PayPalInternalClient to use pairing ID as client metadata ID by default.

* Set applicationGuid for data collector request

* Add unit tests for ba_token and token url param parsing from PayPal redirect URL.

* Fix unit tests for PayPal Native Checkout.

---------

Co-authored-by: Sai <[email protected]>

* Update existing PayPalMessagingView (#1013)

* Create internal messageView property to track if has been initialized

* Add test to validate number of subviews

* Address PR comment

* update changelog.md (#1017)

* Release 4.45.1

* Prepare for development

* Log context ID analytics before launching PayPal browser switch (#1018)

* Release 4.46.0

* Prepare for development

* Shopper Insights Final Changes (#1024)

* Remove merchantId from EligiblePaymentsApiRequest

* Use the default tokenization key for prod

* Remove new line

* Update ShopperInsights changelog

* Fix demo app fragment layout

* Update CHANGELOG with Missing Timestamps (#1022)

* Add missing CHANGELOG for pointed versions.

* Add additional timestamps manually.

* Fix 3DS Black Screen Bug on Android 14 (#1025)

* Add translucent theme to ThreeDSecureActivity.

* Add reference links.

* Update CHANGELOG.

* App links feature (#1027)

* Add appLinkReturnUri to BraintreeClient (#980)

* Add appLinkReturnUri to BraintreeClient and collapse BraintreeClient constructors using default values

* Add doc strings and unit tests

* Update BraintreeCore/src/main/java/com/braintreepayments/api/BraintreeClient.kt

Co-authored-by: Sarah Koop <[email protected]>

* Update changelog for appLinkReturnUri

* Fix lint

---------

Co-authored-by: Sarah Koop <[email protected]>

* Add useAppLinkReturn to PayPalRequest (#984)

* Add useAppLinkReturn to PayPalRequest for Android App Link support

* Update changelog

* Update property name to appLinkEnabled

* Update PayPal/src/main/java/com/braintreepayments/api/PayPalRequest.java

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* Send app link URL to PayPal API (#986)

* Add ability to launch PayPal flows with app links (#988)

* Add ability to launch PayPal flows with app links

* Add demo merchant site URL

* Add intent filter for demo app link (#989)

* Pass app link to browser switch (#999)

* Pass app link uri to BrowserSwtichOptions.

* update browser-switch dependency

* Update CHANGELOG.md

Co-authored-by: Sarah Koop <[email protected]>

* Update PayPal/src/main/java/com/braintreepayments/api/PayPalClient.java

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* exclude tests from LargeClass detekt rule

---------

Co-authored-by: Tim Chow <[email protected]>
Co-authored-by: Sarah Koop <[email protected]>

* Release 4.47.0

* Prepare for development

* Resolve compile issues caused by merge conflicts

* Fix lint issues and failing unit tests (WIP)

* Fix remaining Venmo tests

---------

Co-authored-by: agedd <[email protected]>
Co-authored-by: Jax DesMarais-Leder <[email protected]>
Co-authored-by: Max Hastings <[email protected]>
Co-authored-by: Sarah Koop <[email protected]>
Co-authored-by: saperi <[email protected]>
Co-authored-by: saperi22 <[email protected]>
Co-authored-by: sshropshire <[email protected]>
Co-authored-by: mhastings <[email protected]>
Co-authored-by: Justin Warmkessel <[email protected]>
Co-authored-by: scannillo <[email protected]>
Co-authored-by: warmkesselj <[email protected]>
Co-authored-by: Sammy Cannillo <[email protected]>
Co-authored-by: Victoria Park <[email protected]>
Co-authored-by: braintreeps <[email protected]>
Co-authored-by: Stephanie <[email protected]>
Co-authored-by: Rich Herrera <[email protected]>
@jaxdesmarais jaxdesmarais deleted the merchant-analytics branch August 1, 2024 12:59
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.

5 participants