mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-01 04:46:43 +08:00
fix(jetbrains): keep sandbox telemetry local
This commit is contained in:
+3
-1
@@ -1,5 +1,7 @@
|
||||
package ai.kilocode.backend.dev
|
||||
|
||||
import ai.kilocode.log.KiloEnvironment
|
||||
|
||||
object KiloDevMode {
|
||||
fun enabled(): Boolean = System.getProperty("idea.plugin.in.sandbox.mode", "false").toBoolean()
|
||||
fun enabled(): Boolean = KiloEnvironment.sandbox()
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ class KiloBackendTelemetry(
|
||||
suspend fun capture(http: OkHttpClient?, port: Int, event: String, properties: Map<String, String>) {
|
||||
val body = payload(event, properties)
|
||||
if (KiloDevMode.enabled()) {
|
||||
log.debug { "telemetry capture dev-mode: $body" }
|
||||
log.info("telemetry capture sandbox: $body")
|
||||
return
|
||||
}
|
||||
if (http == null || port <= 0) return
|
||||
@@ -30,7 +30,7 @@ class KiloBackendTelemetry(
|
||||
suspend fun setEnabled(http: OkHttpClient?, port: Int, enabled: Boolean) {
|
||||
val body = JsonObject(mapOf("enabled" to JsonPrimitive(enabled))).toString()
|
||||
if (KiloDevMode.enabled()) {
|
||||
log.debug { "telemetry setEnabled dev-mode: $body" }
|
||||
log.info("telemetry setEnabled sandbox: $body")
|
||||
return
|
||||
}
|
||||
if (http == null || port <= 0) return
|
||||
|
||||
+6
@@ -2,6 +2,7 @@
|
||||
|
||||
package ai.kilocode.client.telemetry
|
||||
|
||||
import ai.kilocode.log.KiloEnvironment
|
||||
import ai.kilocode.log.KiloLog
|
||||
import ai.kilocode.rpc.KiloAppRpcApi
|
||||
import ai.kilocode.rpc.dto.TelemetryCaptureDto
|
||||
@@ -31,6 +32,11 @@ class KiloTelemetryService internal constructor(
|
||||
}
|
||||
|
||||
fun send(event: String, properties: Map<String, String> = emptyMap()) {
|
||||
if (KiloEnvironment.sandbox()) {
|
||||
val payload = KiloEnvironment.payload(LOG) + properties
|
||||
LOG.info("telemetry capture sandbox: event=$event ${payload.entries.joinToString(" ") { "${it.key}=${it.value}" }}")
|
||||
return
|
||||
}
|
||||
cs.launch {
|
||||
try {
|
||||
val dto = TelemetryCaptureDto(event, properties)
|
||||
|
||||
@@ -24,9 +24,8 @@ import java.util.logging.LogRecord
|
||||
* which writes to the standard IDE log file.
|
||||
*
|
||||
* In sandbox mode (i.e. when running via `./gradlew runIde`, detected via the `idea.plugin.in.sandbox.mode`
|
||||
* system property), or in RC plugin builds, output is additionally written to a `kilo-dev.log` file inside the
|
||||
* IDE log directory. This makes it easy to tail frontend and backend logs side-by-side during development or
|
||||
* RC validation without opening the IDE's own log viewer.
|
||||
* system property), output is written only to a `kilo-dev.log` file inside the IDE log directory. RC plugin builds
|
||||
* write to both IntelliJ's log and `kilo-dev.log`.
|
||||
*
|
||||
* Usage:
|
||||
* ```kotlin
|
||||
@@ -49,19 +48,17 @@ interface KiloLog {
|
||||
|
||||
companion object {
|
||||
fun create(cls: Class<*>): KiloLog {
|
||||
if (KiloEnvironment.sandbox()) return FileLog(cls)
|
||||
val intellij = IntellijLog(cls)
|
||||
if (!fileEnabled()) return intellij
|
||||
if (!runCatching { KiloPlugin.isRc() }.getOrDefault(false)) return intellij
|
||||
return CompositeLog(intellij, FileLog(cls))
|
||||
}
|
||||
|
||||
private fun fileEnabled(): Boolean {
|
||||
if (System.getProperty("idea.plugin.in.sandbox.mode", "false").toBoolean()) return true
|
||||
return runCatching { KiloPlugin.isRc() }.getOrDefault(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object KiloEnvironment {
|
||||
fun sandbox(): Boolean = System.getProperty("idea.plugin.in.sandbox.mode", "false").toBoolean()
|
||||
|
||||
fun payload(log: KiloLog? = null): Map<String, String> = buildMap {
|
||||
put("platform", "jetbrains")
|
||||
put("client", "jetbrains")
|
||||
|
||||
Reference in New Issue
Block a user