Skip to content

Commit

Permalink
Added default headers in PKGS APIs calls for IDE version and PKGS plu…
Browse files Browse the repository at this point in the history
…gin version. (#60)
  • Loading branch information
lamba92 authored Feb 7, 2024
1 parent d21faf8 commit 5a9173f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import com.intellij.ide.actions.cache.AsyncRecoveryResult
import com.intellij.ide.actions.cache.RecoveryAction
import com.intellij.ide.actions.cache.RecoveryScope
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.appSystemDir
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.Service.Level
import com.intellij.openapi.components.service
import com.jetbrains.packagesearch.plugin.PackageSearchBundle
import com.jetbrains.packagesearch.plugin.core.PackageSearch
import com.jetbrains.packagesearch.plugin.core.nitrite.buildDefaultNitrate
import com.jetbrains.packagesearch.plugin.core.utils.IntelliJApplication
import com.jetbrains.packagesearch.plugin.core.utils.PKGSInternalAPI
import com.jetbrains.packagesearch.plugin.utils.ApiPackageCacheEntry
import com.jetbrains.packagesearch.plugin.utils.ApiRepositoryCacheEntry
Expand All @@ -20,8 +23,10 @@ import com.jetbrains.packagesearch.plugin.utils.KtorDebugLogger
import com.jetbrains.packagesearch.plugin.utils.PackageSearchApiPackageCache
import com.jetbrains.packagesearch.plugin.utils.PackageSearchProjectService
import io.ktor.client.engine.java.Java
import io.ktor.client.plugins.DefaultRequest
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logging
import io.ktor.http.headers
import java.util.concurrent.CompletableFuture
import kotlin.io.path.absolutePathString
import kotlin.io.path.div
Expand Down Expand Up @@ -76,6 +81,12 @@ class PackageSearchApplicationCachesService(private val coroutineScope: Coroutin
logger = KtorDebugLogger()
filter { it.attributes.getOrNull(PackageSearchApiClient.Attributes.Cache) == true }
}
install(DefaultRequest) {
headers {
append("JB-Plugin-Version", PackageSearch.pluginVersion)
append("JB-IDE-Version", IntelliJApplication.service<ApplicationInfo>().strictVersion)
}
}
}
)

Expand Down

0 comments on commit 5a9173f

Please sign in to comment.