Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions core/src/main/java/com/web3auth/core/Web3Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.web3auth.core.analytics.AnalyticsEvents
import com.web3auth.core.analytics.AnalyticsManager
import com.web3auth.core.analytics.AnalyticsSdkType
import com.web3auth.core.api.ApiHelper
import com.web3auth.core.api.ApiService
import com.web3auth.core.keystore.IS_SFA
Expand Down Expand Up @@ -87,8 +86,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
)
AnalyticsManager.setGlobalProperties(
mapOf(
"sdk_name" to AnalyticsSdkType.ANDROID,
"sdk_version" to AnalyticsEvents.SDK_VERSION,
"sdk_name" to web3AuthOptions.getSdkName(),
"sdk_version" to web3AuthOptions.getSdkVersion(),
"web3auth_client_id" to web3AuthOptions.clientId,
"web3auth_network" to web3AuthOptions.web3AuthNetwork,
)
Expand Down Expand Up @@ -242,7 +241,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
"whitelabel_logo_dark_enabled" to (web3AuthOption.whiteLabel?.logoDark != null),
"whitelabel_theme_mode" to (web3AuthOption.whiteLabel?.theme),
"duration" to System.currentTimeMillis() - startTime,
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"dapp_url" to this.loginParams?.dappUrl,
)

Expand All @@ -269,7 +268,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
AnalyticsManager.trackEvent(
AnalyticsEvents.SDK_INITIALIZATION_FAILED,
mutableMapOf<String, Any>(
"integration_type" to AnalyticsSdkType.ANDROID,
"integration_type" to web3AuthOption.getSdkName(),
"dapp_url" to "this.loginParams?.dappUrl.toString()",
"duration" to System.currentTimeMillis() - startTime,
"error_message" to "Fetch project config API error. ${err.message}"
Expand Down Expand Up @@ -321,7 +320,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
AnalyticsManager.trackEvent(
AnalyticsEvents.MFA_MANAGEMENT_FAILED,
mutableMapOf<String, Any>(
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"dapp_url" to this.loginParams?.dappUrl.toString(),
"connector" to "auth",
"duration" to System.currentTimeMillis() - startTime,
Expand Down Expand Up @@ -588,7 +587,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
"dapp_url" to loginParams.dappUrl.toString(),
"chain_id" to web3AuthOption.defaultChainId.toString(),
"chains" to (web3AuthOption.chains?.toString() ?: "[]"),
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"is_mfa_enabled" to (actionType == "enable_mfa"),
"is_sfa" to true
)
Expand Down Expand Up @@ -743,7 +742,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
AnalyticsManager.trackEvent(
AnalyticsEvents.MFA_ENABLEMENT_STARTED,
mutableMapOf<String, Any>(
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"dapp_url" to this.loginParams?.dappUrl.toString(),
"connector" to "auth",
"duration" to System.currentTimeMillis() - startTime,
Expand All @@ -769,7 +768,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
AnalyticsManager.trackEvent(
AnalyticsEvents.MFA_MANAGEMENT_STARTED,
mutableMapOf<String, Any>(
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"dapp_url" to this.loginParams?.dappUrl.toString(),
"connector" to "auth"
)
Expand Down Expand Up @@ -855,8 +854,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
// Set global properties for analytics after fetching project config
AnalyticsManager.setGlobalProperties(
mapOf(
"sdk_name" to AnalyticsSdkType.ANDROID,
"sdk_version" to AnalyticsEvents.SDK_VERSION,
"sdk_name" to web3AuthOption.getSdkName(),
"sdk_version" to web3AuthOption.getSdkVersion(),
"web3auth_client_id" to web3AuthOption.clientId,
"web3auth_network" to web3AuthOption.web3AuthNetwork,
"team_id" to projectConfigResponse?.teamId.toString(),
Expand Down Expand Up @@ -929,7 +928,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
AnalyticsManager.trackEvent(
AnalyticsEvents.WALLET_UI_CLICKED,
mutableMapOf<String, Any>(
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"dapp_url" to this.loginParams?.dappUrl.toString(),
)
)
Expand Down Expand Up @@ -1003,7 +1002,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
AnalyticsManager.trackEvent(
AnalyticsEvents.WALLET_SERVICES_FAILED,
mutableMapOf<String, Any>(
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"dapp_url" to this.loginParams?.dappUrl.toString(),
"duration" to System.currentTimeMillis() - startTime,
"error" to "Wallet Services Error: Session ID is not found. Please login first."
Expand Down Expand Up @@ -1265,7 +1264,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
"dapp_url" to loginParams?.dappUrl.toString(),
"chain_id" to web3AuthOption.defaultChainId.toString(),
"chains" to (web3AuthOption.chains?.toString() ?: "[]"),
"integration_type" to "android",
"integration_type" to web3AuthOption.getSdkName(),
"is_mfa_enabled" to (actionType == "enable_mfa"),
"is_sfa" to false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ object AnalyticsEvents {
const val REQUEST_FUNCTION_COMPLETED = "Request Function Completed"
const val REQUEST_FUNCTION_FAILED = "Request Function Failed"

const val SDK_VERSION = "10.0.0"
const val ANDROID_SDK_VERSION = "10.0.0"
}

object AnalyticsSdkType {
const val ANDROID = "android"
const val FLUTTER = "flutter"
}

object SegmentKeys {
Expand Down
24 changes: 24 additions & 0 deletions core/src/main/java/com/web3auth/core/types/Web3AuthOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.web3auth.core.types

import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import com.web3auth.core.analytics.AnalyticsEvents
import com.web3auth.core.analytics.AnalyticsSdkType
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

@Keep
Expand Down Expand Up @@ -30,6 +32,28 @@ data class Web3AuthOptions(
@Keep val walletServicesConfig: WalletServicesConfig? = null,
@Keep var mfaSettings: MfaSettings? = null,
) {

@Transient
private var isFlutterAnalytics: Boolean? = false
private var sdkVersion: String? = null
fun setFlutterAnalytics(analytics: Boolean?, sdkVersion: String? = null) {
this.isFlutterAnalytics = analytics ?: false
this.sdkVersion = sdkVersion
}

fun getFlutterAnalytics(): Boolean? = isFlutterAnalytics
fun getSdkVersion(): String {
return if (sdkVersion.isNullOrEmpty()) {
AnalyticsEvents.ANDROID_SDK_VERSION // android sdk version
} else {
sdkVersion ?: "unknown" // flutter sdk version
}
}

fun getSdkName(): String {
return if (isFlutterAnalytics == true) AnalyticsSdkType.FLUTTER else AnalyticsSdkType.ANDROID
}

init {
if (dashboardUrl == null) {
dashboardUrl = getDashboardUrl(authBuildEnv)
Expand Down