claudetool: remove telemetry endpoint and related functions
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s88833bbb3878c2a9k
diff --git a/claudetool/patch.go b/claudetool/patch.go
index 24a22ef..0d8e725 100644
--- a/claudetool/patch.go
+++ b/claudetool/patch.go
@@ -219,11 +219,6 @@
}
if patchErr != nil {
- sendTelemetry(ctx, "patch_error", map[string]any{
- "orig": origStr,
- "patches": input.Patches,
- "errors": patchErr,
- })
return nil, patchErr
}
diff --git a/claudetool/shared.go b/claudetool/shared.go
index 83048b9..d95a5e4 100644
--- a/claudetool/shared.go
+++ b/claudetool/shared.go
@@ -6,14 +6,7 @@
package claudetool
import (
- "bytes"
"context"
- "encoding/json"
- "fmt"
- "log/slog"
- "net/http"
- "os"
- "time"
)
type workingDirCtxKeyType string
@@ -30,43 +23,3 @@
wd, _ := ctx.Value(workingDirCtxKey).(string)
return wd
}
-
-// sendTelemetry posts debug data to an internal logging server.
-// It is meant for use by people developing sketch and is disabled by default.
-// This is a best-effort operation; errors are logged but not returned.
-func sendTelemetry(ctx context.Context, typ string, data any) {
- telemetryEndpoint := os.Getenv("SKETCH_TELEMETRY_ENDPOINT")
- if telemetryEndpoint == "" {
- return
- }
- err := doPostTelemetry(ctx, telemetryEndpoint, typ, data)
- if err != nil {
- slog.DebugContext(ctx, "failed to send JSON to server", "type", typ, "error", err)
- }
-}
-
-func doPostTelemetry(ctx context.Context, telemetryEndpoint, typ string, data any) error {
- jsonData, err := json.Marshal(data)
- if err != nil {
- return fmt.Errorf("failed to marshal %#v as JSON: %w", data, err)
- }
- timestamp := time.Now().Unix()
- url := fmt.Sprintf(telemetryEndpoint+"/%s_%d.json", typ, timestamp)
- req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
- if err != nil {
- return fmt.Errorf("failed to create HTTP request for %s: %w", typ, err)
- }
- req.Header.Set("Content-Type", "application/json")
-
- resp, err := http.DefaultClient.Do(req)
- if err != nil {
- return fmt.Errorf("failed to send %s JSON to server: %w", typ, err)
- }
- defer resp.Body.Close()
-
- if resp.StatusCode/100 != 2 {
- return fmt.Errorf("server returned non-success status for %s: %d", typ, resp.StatusCode)
- }
- slog.DebugContext(ctx, "successfully sent JSON to server", "file_type", typ, "url", url)
- return nil
-}