Skip to content

Commit

Permalink
feat(capture-sdk): Add RA onboarding analytics events (#456)
Browse files Browse the repository at this point in the history
feat(capture-sdk): Add RA onboarding analytics events

PP-538
  • Loading branch information
ndubkov-distcotech authored Jun 14, 2024
1 parent 3978ea3 commit 9f0ae4d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.NavHostFragment
import androidx.transition.TransitionInflater
Expand All @@ -16,6 +17,10 @@ import net.gini.android.bank.sdk.util.getLayoutInflaterWithGiniCaptureTheme
import net.gini.android.capture.GiniCapture
import net.gini.android.capture.internal.ui.IntervalClickListener
import net.gini.android.capture.onboarding.view.OnboardingIllustrationAdapter
import net.gini.android.capture.tracking.useranalytics.UserAnalytics
import net.gini.android.capture.tracking.useranalytics.UserAnalyticsEvent
import net.gini.android.capture.tracking.useranalytics.UserAnalyticsScreen
import net.gini.android.capture.tracking.useranalytics.properties.UserAnalyticsEventProperty
import net.gini.android.capture.view.InjectedViewAdapterHolder

/**
Expand Down Expand Up @@ -47,6 +52,10 @@ class DigitalInvoiceOnboardingFragment : Fragment(), DigitalOnboardingScreenCont

private var presenter: DigitalOnboardingScreenContract.Presenter? = null

private val userAnalyticsEventTracker by lazy { UserAnalytics.getAnalyticsEventTracker() }

private val screenName = UserAnalyticsScreen.ReturnAssistantOnBoarding

override fun onGetLayoutInflater(savedInstanceState: Bundle?): LayoutInflater {
val inflater = super.onGetLayoutInflater(savedInstanceState)
return this.getLayoutInflaterWithGiniCaptureTheme(inflater)
Expand All @@ -69,9 +78,9 @@ class DigitalInvoiceOnboardingFragment : Fragment(), DigitalOnboardingScreenCont
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
createPresenter(requireActivity())
enterTransition = TransitionInflater.from(requireContext()).inflateTransition(R.transition.fade)
enterTransition =
TransitionInflater.from(requireContext()).inflateTransition(R.transition.fade)
exitTransition = enterTransition

}

private fun createPresenter(activity: Activity) =
Expand Down Expand Up @@ -126,6 +135,7 @@ class DigitalInvoiceOnboardingFragment : Fragment(), DigitalOnboardingScreenCont
setInputHandlers()
setupImageIllustrationAdapter()
setupOnboardingBottomNavigationBar()
trackAnalyticsScreenShownEvent()
}


Expand All @@ -149,6 +159,7 @@ class DigitalInvoiceOnboardingFragment : Fragment(), DigitalOnboardingScreenCont
injectedViewAdapter.setGetStartedButtonClickListener(
IntervalClickListener {
presenter?.dismisOnboarding(false)
trackAnalyticsGetStartedTappedEvent()
}
)
}
Expand All @@ -158,6 +169,45 @@ class DigitalInvoiceOnboardingFragment : Fragment(), DigitalOnboardingScreenCont
private fun setInputHandlers() {
binding.doneButton.setOnClickListener {
presenter?.dismisOnboarding(false)
trackAnalyticsGetStartedTappedEvent()
}
handleOnBackPressed()
}

private fun handleOnBackPressed() {
requireActivity().onBackPressedDispatcher.addCallback(
viewLifecycleOwner,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
trackAnalyticsDismissedEvent()
close()
isEnabled = false
remove()
}
})
}

private fun trackAnalyticsScreenShownEvent() {
userAnalyticsEventTracker.trackEvent(
UserAnalyticsEvent.SCREEN_SHOWN, setOf(
UserAnalyticsEventProperty.Screen(screenName)
)
)
}

private fun trackAnalyticsGetStartedTappedEvent() {
userAnalyticsEventTracker.trackEvent(
UserAnalyticsEvent.GET_STARTED_TAPPED, setOf(
UserAnalyticsEventProperty.Screen(screenName)
)
)
}

private fun trackAnalyticsDismissedEvent() {
userAnalyticsEventTracker.trackEvent(
UserAnalyticsEvent.DISMISSED, setOf(
UserAnalyticsEventProperty.Screen(screenName)
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ enum class UserAnalyticsEvent(val eventName: String) {
// region Camera Permission
GIVE_ACCESS_TAPPED("give_access_tapped"),
// endregion
DISMISSED("dismissed")
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ sealed class UserAnalyticsScreen(val name: String) {
}

object ReturnAssistant : UserAnalyticsScreen("return_assistant")
object ReturnAssistantOnBoarding : UserAnalyticsScreen("onoarding_return_assistant")

object EditReturnAssistant : UserAnalyticsScreen("edit_return_assistant")
}

0 comments on commit 9f0ae4d

Please sign in to comment.