Skip to content

Commit

Permalink
about endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
shalom938 committed Nov 7, 2024
1 parent 6fe19ec commit b807ac7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
package org.digma.intellij.plugin.analytics

import com.intellij.openapi.project.Project
import org.digma.intellij.plugin.common.findActiveProject

fun isCentralized(project: Project): Boolean {
return BackendInfoHolder.getInstance(project).isCentralized()
}

fun getVersion(project: Project): String {
return BackendInfoHolder.getInstance(project).getAbout()?.applicationVersion ?: "unknown";
}
fun getBackendVersion(project: Project): String {
return BackendInfoHolder.getInstance(project).getAbout()?.applicationVersion ?: "unknown"
}

fun getBackendVersion(): String {
val project = findActiveProject()
return project?.let {
BackendInfoHolder.getInstance(it).getAbout()?.applicationVersion ?: "unknown"
} ?: "unknown"
}

fun getBackendDeploymentType(): String {
val project = findActiveProject()
return project?.let {
BackendInfoHolder.getInstance(it).getAbout()?.deploymentType?.name ?: "unknown"
} ?: "unknown"
}

fun isCentralized(): Boolean {
val project = findActiveProject()
return project?.let {
BackendInfoHolder.getInstance(it).getAbout()?.isCentralize ?: false
} ?:false
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.http.FullHttpRequest
import io.netty.handler.codec.http.HttpRequest
import io.netty.handler.codec.http.QueryStringDecoder
import org.digma.intellij.plugin.analytics.getBackendDeploymentType
import org.digma.intellij.plugin.analytics.getBackendVersion
import org.digma.intellij.plugin.analytics.isCentralized
import org.digma.intellij.plugin.semanticversion.SemanticVersionUtil
import org.jetbrains.ide.RestService
import java.io.OutputStream

Expand Down Expand Up @@ -75,6 +79,11 @@ fun writeAboutJson(writer: JsonGenerator) {
writer.writeStringField("buildNumber", build.asStringWithoutProductCode())
}

writer.writeStringField("pluginVersion", SemanticVersionUtil.getPluginVersionWithoutBuildNumberAndPreRelease("unknown"))
writer.writeStringField("backendVersion", getBackendVersion())
writer.writeStringField("backendDeploymentType", getBackendDeploymentType())
writer.writeBooleanField("isCentralized", isCentralized())

writer.array("openProjects") {
for (project in ProjectManager.getInstance().openProjects) {
writer.writeString(project.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import com.intellij.openapi.project.Project
import org.apache.maven.artifact.versioning.ComparableVersion
import org.cef.browser.CefBrowser
import org.digma.intellij.plugin.analytics.getVersion
import org.digma.intellij.plugin.analytics.getBackendVersion
import org.digma.intellij.plugin.common.newerThan
import org.digma.intellij.plugin.log.Log
import org.digma.intellij.plugin.model.rest.highlights.HighlightsRequest
Expand All @@ -20,7 +20,7 @@ class HighlightsMessageRouterHandler(project: Project) : BaseCommonMessageRouter

override fun doOnQuery(project: Project, browser: CefBrowser, requestJsonNode: JsonNode, rawRequest: String, action: String): Boolean {

val version = getVersion(project)
val version = getBackendVersion(project)
val comparableVersion = ComparableVersion(version)
if (version == "unknown" || comparableVersion.newerThan(ComparableVersion("0.3.7"))) {
when (action) {
Expand Down

0 comments on commit b807ac7

Please sign in to comment.