Skip to content

Commit 996a218

Browse files
committed
feat: Add error-message in case of event failure analytics
Signed-off-by: Gaurav Goel <[email protected]>
1 parent 983757e commit 996a218

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

core/src/main/java/com/web3auth/core/Web3Auth.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
263263
AnalyticsEvents.SDK_INITIALIZATION_FAILED,
264264
mutableMapOf<String, Any>(
265265
"duration" to System.currentTimeMillis() - startTime,
266+
"error" to "Fetch project config API error. ${err.message}"
266267
)
267268
)
268269
initializeCf.completeExceptionally(err)
@@ -299,6 +300,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
299300
AnalyticsEvents.MFA_ENABLEMENT_FAILED,
300301
mutableMapOf<String, Any>(
301302
"duration" to System.currentTimeMillis() - startTime,
303+
"error_message" to "MFA Enablement Failed: $error"
302304
)
303305
)
304306
}
@@ -311,6 +313,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
311313
AnalyticsEvents.MFA_MANAGEMENT_FAILED,
312314
mutableMapOf<String, Any>(
313315
"duration" to System.currentTimeMillis() - startTime,
316+
"error_message" to "MFA Management Failed: $error"
314317
)
315318
)
316319
}
@@ -443,6 +446,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
443446
"auth_connection" to loginParams.authConnection,
444447
"auth_connection_id" to loginParams.authConnectionId,
445448
"group_auth_connection_id" to loginParams.groupedAuthConnectionId,
449+
"chain_id" to web3AuthOption.defaultChainId.toString(),
450+
"chains" to (web3AuthOption.chains?.toString() ?: "[]"),
446451
"dappUrl" to loginParams.dappUrl,
447452
)
448453
)
@@ -458,6 +463,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
458463
AnalyticsManager.trackEvent(
459464
AnalyticsEvents.CONNECTION_STARTED,
460465
mutableMapOf<String, Any>(
466+
"chain_id" to web3AuthOption.defaultChainId.toString(),
467+
"chains" to (web3AuthOption.chains?.toString() ?: "[]"),
461468
"is_sfa" to false,
462469
)
463470
)
@@ -680,7 +687,10 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
680687
logoutCompletableFuture.complete(null)
681688
} else {
682689
AnalyticsManager.trackEvent(
683-
AnalyticsEvents.LOGOUT_FAILED
690+
AnalyticsEvents.LOGOUT_FAILED,
691+
mutableMapOf<String, Any>(
692+
"error_message" to "Logout Failed: ${error.message}"
693+
)
684694
)
685695
logoutCompletableFuture.completeExceptionally(Exception(error))
686696
}
@@ -946,6 +956,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
946956
AnalyticsEvents.WALLET_SERVICES_FAILED,
947957
mutableMapOf<String, Any>(
948958
"duration" to System.currentTimeMillis() - startTime,
959+
"error" to "Wallet Services Error: Session ID is not found. Please login first."
949960
)
950961
)
951962
launchWalletServiceCF.completeExceptionally(Exception("Please login first to launch wallet"))
@@ -1052,6 +1063,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
10521063
AnalyticsEvents.REQUEST_FUNCTION_FAILED,
10531064
mutableMapOf<String, Any>(
10541065
"duration" to System.currentTimeMillis() - startTime,
1066+
"error" to "Request Function Error: Session ID is not found. Please login first."
10551067
)
10561068
)
10571069
signMsgCF.completeExceptionally(Exception("Please login first to launch wallet"))
@@ -1173,7 +1185,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
11731185

11741186
val properties = mapOf(
11751187
"duration" to System.currentTimeMillis() - startTime,
1176-
"error" to (error?.name ?: "Unknown Error")
1188+
"error_message" to (error?.name ?: "Unknown Error")
11771189
)
11781190

11791191
AnalyticsManager.trackEvent(event, properties)

core/src/main/java/com/web3auth/core/analytics/AnalyticsManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ internal object AnalyticsManager {
3333

3434
fun trackEvent(eventName: String, properties: Map<String, Any?>? = null) {
3535
if (!isInitialized) return
36+
if (isSkipped()) return
3637

3738
val combinedProps = Properties().apply {
3839
globalProperties.forEach { (k, v) -> putValue(k, v) }

0 commit comments

Comments
 (0)