Event Tracking¶
GiniHealth¶
The GiniHealth class exposes kotlin flows which you can collect to track events and receive updates. The following flows are available:
documentFlowis aStateFlowofResultWrapper<Document>which emits the Gini Health API’s document used by theReviewFragment. It emits the following states:ResultWrapper.Loading()when the document is being loaded.ResultWrapper.Success(document)when the document is available.ResultWrapper.Error(throwable)when there was an error loading the document.
paymentFlowis aStateFlowofResultWrapper<PaymentDetails>which emits the payment information shown in theReviewFragment.ResultWrapper.Loading()when the payment details are being loaded.ResultWrapper.Success(paymentDetails)when the payment details are available.ResultWrapper.Error(throwable)when there was an error loading the payment details.
openBankStateis aStateFlowofPaymentStatewhich emits the state of opening the banking app. It emits the following states:PaymentState.NoAction()is the idle state.PaymentState.Loading()when the user requested to open the banking app and the Health SDK started creating a payment request.PaymentState.Success(paymentRequest)when the payment request is ready and the banking app will be opened.PaymentState.Error(throwable)when there was an error creating the payment request or opening the banking app.PaymentState.Cancel()when the user cancelled the payment flow.
Warning
As the SDK is not responsible for navigation flows outside of it, removing the payment fragment from the hierarchy is the responsibility of implementers at
PaymentState.Success(paymentRequest)orPaymentState.Cancel()events.giniHealth.openBankState.collect { paymentState -> when (paymentState) { is GiniHealth.PaymentState.Success -> { ... // Remove fragment from view hierarchy } is GiniHealth.PaymentState.Cancel -> { // Remove fragment from view hierarchy } else -> {} } }
displayedScreenis aSharedFlowofDisplayedScreenwhich emits the currently displayed screen in thePaymentFragment. It can be collected to update the UI if needed, such as the toolbar title. It emits the following values:DisplayedScreen.Nothingis the default state.DisplayedScreen.PaymentComponentBottomSheetthePaymentComponentBottomSheetis displayed, showing either the selected bank, or prompting the user to select one.DisplayedScreen.BankSelectionBottomSheetwhen theBankSelectionBottomSheetis displayed, with the list of payment providers to choose from.DisplayedScreen.MoreInformationFragmentwhen theMoreInformationFragmentis displayed.DisplayedScreen.InstallAppBottomSheetwhen the selected payment provider is not installed.DisplayedScreen.OpenWithBottomSheetwhen the selected payment provider does not support GPC.DisplayedScreen.ShareSheetwhen the native share sheet is displayed.DisplayedScreen.ReviewBottomSheetthe payment details are shown in a bottom sheet. Emitted if payment flow was started without document id.DisplayedScreen.ReviewFragmentthe payment details are shown in a fragment. Emitted if payment flow was started with a document id.
trustMarkersFlowis aFlowofResultWrapper<TrustMarkerResponse>which emits the icons of two payment providers, along with the additional payment providers count.ResultWrapper.Loading()when the payment providers are still being loaded.ResultWrapper.Error(throwable)when there was an error loading the payment providers.ResultWrapper.Success(trustMarkerResponse)when the payment providers have been loaded.
PaymentComponent¶
The PaymentComponent class also exposes kotlin flows which you can collect to track events. The payment component flows can be collected
via giniHealth.giniInternalPaymentManager.paymentComponent. The following flows are available:
paymentProviderAppsFlowis aStateFlowofPaymentProviderAppsStatewhich emits the available payment provider apps used by thePaymentComponentViewand related screens. It emits the following states:PaymentProviderAppsState.Loading()when the payment provider apps are being loaded.PaymentProviderAppsState.Success(paymentProviderApps)when the list of payment provider apps is available.PaymentProviderAppsState.Error(throwable)when there was an error loading the payment provider apps.
selectedPaymentProviderAppFlowis aStateFlowofSelectedPaymentProviderAppStatewhich emits selected payment provider app shown in thePaymentComponentViewand related screens. It emits the following states:SelectedPaymentProviderAppState.NothingSelected()when there is no selection.SelectedPaymentProviderAppState.AppSelected(paymentProviderApp)when a payment provider app has been selected.