reduce posthog costs, report core exits
This commit is contained in:
parent
69215a7627
commit
5db3a581c3
5 changed files with 51 additions and 6 deletions
|
|
@ -37,6 +37,7 @@ dependencies {
|
|||
implementation("io.ktor:ktor-server-cors:2.3.7"){
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
implementation("com.posthog.java:posthog:1.+")
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.github.continuedev.continueintellijextension.listeners.ContinuePlugin
|
|||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.github.continuedev.continueintellijextension.services.SettingsListener
|
||||
import com.github.continuedev.continueintellijextension.services.TelemetryService
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
|
|
@ -211,6 +212,16 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
|||
|
||||
val coreMessenger = CoreMessenger(project, esbuildPath, continueCorePath, ideProtocolClient)
|
||||
continuePluginService.coreMessenger = coreMessenger
|
||||
|
||||
coreMessenger.request("config/getSerializedProfileInfo", null, null) { resp ->
|
||||
val data = resp as? Map<String, Any>
|
||||
val profileInfo = data?.get("config") as? Map<String, Any>
|
||||
val allowAnonymousTelemetry = profileInfo?.get("allowAnonymousTelemetry") as? Boolean
|
||||
val telemetryService = service<TelemetryService>()
|
||||
if (allowAnonymousTelemetry == true || allowAnonymousTelemetry == null) {
|
||||
telemetryService.setup(getMachineUniqueID())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
import java.io.OutputStreamWriter
|
||||
|
||||
import java.io.*
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.TelemetryService
|
||||
import com.google.gson.Gson
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import java.io.*
|
||||
import java.net.Socket
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Files
|
||||
|
|
@ -241,6 +238,12 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
|
|||
val err = process?.errorStream?.bufferedReader()?.readText()?.trim()
|
||||
println("Core process exited with output: $err")
|
||||
ideProtocolClient.showMessage("Core process exited with output: $err")
|
||||
|
||||
// Log the cause of the failure
|
||||
val telemetryService = service<TelemetryService>()
|
||||
telemetryService.capture("jetbrains_core_exit", mapOf(
|
||||
"error" to err
|
||||
))
|
||||
}
|
||||
|
||||
Thread {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.github.continuedev.continueintellijextension.services
|
||||
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.posthog.java.PostHog
|
||||
import com.posthog.java.PostHog.Builder
|
||||
|
||||
@Service
|
||||
class TelemetryService {
|
||||
private val POSTHOG_API_KEY = "phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs"
|
||||
private var posthog: PostHog? = null;
|
||||
private var distinctId: String? = null;
|
||||
|
||||
fun setup(distinctId: String) {
|
||||
this.posthog = Builder(POSTHOG_API_KEY).host("https://app.posthog.com").build()
|
||||
this.distinctId = distinctId
|
||||
}
|
||||
|
||||
fun capture(eventName: String, properties: Map<String, *>) {
|
||||
if (this.posthog == null || this.distinctId == null) {
|
||||
return;
|
||||
}
|
||||
this.posthog?.capture(this.distinctId, eventName, properties)
|
||||
}
|
||||
|
||||
fun shutdown() {
|
||||
this.posthog?.shutdown()
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,9 @@ const CustomPostHogProvider = ({ children }: PropsWithChildren) => {
|
|||
posthog.init("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", {
|
||||
api_host: "https://app.posthog.com",
|
||||
disable_session_recording: true,
|
||||
autocapture: false,
|
||||
// // We need to manually track pageviews since we're a SPA
|
||||
capture_pageleave: false,
|
||||
capture_pageview: false,
|
||||
});
|
||||
posthog.identify(window.vscMachineId);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue