Skip to content

Commit

Permalink
Add common params
Browse files Browse the repository at this point in the history
  • Loading branch information
simond-stripe committed Dec 13, 2024
1 parent ce2571b commit 808631f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
import androidx.annotation.RestrictTo
import com.stripe.android.connect.analytics.ConnectAnalyticsEvent
import com.stripe.android.connect.analytics.ConnectAnalyticsService
import com.stripe.android.connect.webview.StripeConnectWebViewContainer
import com.stripe.android.connect.webview.StripeConnectWebViewContainerImpl

Expand Down Expand Up @@ -38,6 +40,11 @@ class PayoutsView private constructor(

init {
webViewContainerBehavior.initializeView(this)
ConnectAnalyticsService(this.context, isTestMode = true).track(
ConnectAnalyticsEvent.WebPageLoaded(
timeToLoad = 1.0,
)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.stripe.android.connect.analytics
*/
internal sealed class ConnectAnalyticsEvent(
val eventName: String,
val params: Map<String, String?>? = null,
val params: Map<String, Any?>? = null,
) {
/**
* A component was instantiated via create{ComponentType}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import kotlinx.coroutines.launch
*/
internal class ConnectAnalyticsService(
context: Context,
private val isTestMode: Boolean,
) {
internal var merchantId: String? = null

private val application: Application = context.applicationContext as Application

private val analyticsRequestStorage = RealAnalyticsRequestV2Storage(application)
Expand Down Expand Up @@ -56,13 +59,15 @@ internal class ConnectAnalyticsService(
}
}

private fun commonParams(): Map<String, String?> {
return mapOf()
private fun commonParams(): Map<String, Any?> {
return mapOf(
"livemode" to !isTestMode,
"merchantId" to merchantId,
).filterNot { (_, v) -> v == null }
}

internal companion object {
const val CLIENT_ID = "mobile-identity-sdk"
const val ORIGIN = "stripe-identity-android"
const val ID = "id"
const val CLIENT_ID = "mobile_connect_sdk"
const val ORIGIN = "stripe-connect-android"
}
}

0 comments on commit 808631f

Please sign in to comment.