Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api state params to tracking #672

Merged
merged 3 commits into from
Sep 24, 2024
Merged
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
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>? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: return type can be non-optional, e.g,. IMap<String, Any>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm yea our ParsingHelper merge functions take in that specific type... not sure what's the best way to cast/not cast t_t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will send it for nowwww!

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
Loading