Skip to content

Commit

Permalink
Add api state params to tracking (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
aforaleka authored Sep 24, 2024
1 parent d63fa57 commit 7586280
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.11.16"
version = "1.11.17"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import exchange.dydx.abacus.utils.JsonEncoder
import exchange.dydx.abacus.utils.ParsingHelper
import exchange.dydx.abacus.utils.ServerTime
import exchange.dydx.abacus.utils.UIImplementations
import exchange.dydx.abacus.utils.iMapOf
import kollections.iListOf
import kollections.iSetOf
import kollections.toIMap
Expand Down Expand Up @@ -555,4 +556,16 @@ class NetworkHelper(
}
}
}

internal fun apiStateParams(): IMap<String, Any>? {
val indexerTime = lastIndexerCallTime?.toEpochMilliseconds()
val validatorTime = lastValidatorCallTime?.toEpochMilliseconds()
val interval = indexerTime?.let { Clock.System.now().toEpochMilliseconds() - it }
return iMapOf(
"lastSuccessfulIndexerRPC" to indexerTime?.toDouble(),
"lastSuccessfulFullNodeRPC" to validatorTime?.toDouble(),
"elapsedTime" to interval?.toDouble(),
"validatorUrl" to validatorUrl,
) as IMap<String, Any>?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import exchange.dydx.abacus.utils.AnalyticsUtils
import exchange.dydx.abacus.utils.IMap
import exchange.dydx.abacus.utils.ParsingHelper
import exchange.dydx.abacus.utils.filterNotNull
import exchange.dydx.abacus.utils.iMapOf
import kollections.iListOf

internal open class NetworkSupervisor(
Expand Down Expand Up @@ -85,7 +84,7 @@ internal open class NetworkSupervisor(
}

internal fun tracking(eventName: String, params: IMap<String, Any?>?) {
val requiredParams = helper.validatorUrl?.let { iMapOf("validatorUrl" to it) } ?: iMapOf()
val requiredParams = helper.apiStateParams()
val mergedParams = params?.let { ParsingHelper.merge(params.filterNotNull(), requiredParams) } ?: requiredParams
val paramsAsString = helper.jsonEncoder.encode(mergedParams)
helper.ioImplementations.threading?.async(ThreadingType.main) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal class SubaccountTransactionTracker(
}

override fun tracking(eventName: String, params: IMap<String, Any?>?) {
val requiredParams = helper.validatorUrl?.let { iMapOf("validatorUrl" to it) } ?: iMapOf()
val requiredParams = helper.apiStateParams()
val mergedParams =
params?.let { ParsingHelper.merge(params.filterNotNull(), requiredParams) }
?: requiredParams
Expand Down
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'v4_abacus'
spec.version = '1.11.16'
spec.version = '1.11.17'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit 7586280

Please sign in to comment.