Conversation
simolus3
left a comment
There was a problem hiding this comment.
must check if can extract version string from
SDK_INT
I think including Build.VERSION and Build.RELEASE_OR_CODENAME should be enough here.
| } | ||
| } | ||
|
|
||
| internal expect fun getOS(): String |
There was a problem hiding this comment.
I'd prefer this to be in a separate file (e.g. utils/OSInfo.kt).
| headers { | ||
| append(HttpHeaders.Authorization, "Token ${credentials.token}") | ||
| append("User-Id", credentials.userId ?: "") | ||
| append("User-Agent", powerSyncUserAgent()) |
There was a problem hiding this comment.
Given that we're doing this on all requests, a better place to put this may be in init:
fun HttpClientConfig<*>.configureClient() {
install(HttpTimeout)
install(ContentNegotiation)
defaultRequest {
headers {
append("User-Agent", $LIBRARY_NAME/$LIBRARY_VERSION ${getOS()}")
}
}
}| // TODO: Swift SDK relies on this too. | ||
| // Find out how to add a build flag to toggle between "powersync-kotlin" and "powersync-swift". | ||
| buildConfigField(STRING, "LIBRARY_NAME", "powersync-kotlin") |
There was a problem hiding this comment.
I think we don't have to worry about this. We'll likely add an API for clients to add their own headers in the future. The Swift SDK could use that to always override the User-Agent header if necessary. So it should be fine if this always reports powersync-kotlin for now.
|
We've since added a user-agent to all requests as part of #192. |
Adds User-Agent in similar fashion to Dart and JS repos.
Based on abandoned pull #57
Todos
android $base/$versionwithandroid <SDK_INT or OS version>- must check if can extract version string fromSDK_INT