From aae4292aa89a88fdd575b33d2bceeee4a8b18643 Mon Sep 17 00:00:00 2001 From: "augmentcode[bot]" <185243770+augmentcode[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 01:06:15 +0000 Subject: [PATCH 1/3] Reduce Events Sent --- pkg/wcloud/wcloud.go | 12 ++++++- pkg/wcloud/wcloud_test.go | 76 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 pkg/wcloud/wcloud_test.go diff --git a/pkg/wcloud/wcloud.go b/pkg/wcloud/wcloud.go index b31ff94150..2e9cda1de2 100644 --- a/pkg/wcloud/wcloud.go +++ b/pkg/wcloud/wcloud.go @@ -1,4 +1,4 @@ -// Copyright 2025, Command Line Inc. +// Copyright 2026, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 package wcloud @@ -38,6 +38,7 @@ const MaxUpdatesToDeDup = 1000 const MaxUpdateWriterErrors = 3 const WCloudDefaultTimeout = 5 * time.Second const WCloudWebShareUpdateTimeout = 15 * time.Second +const SendEvents = false // setting to 1M to be safe (max is 6M for API-GW + Lambda, but there is base64 encoding and upload time) // we allow one extra update past this estimated size @@ -180,6 +181,9 @@ func sendTEventsBatch(clientId string) (bool, int, error) { } func sendTEvents(clientId string) (int, error) { + if !SendEvents { + return 0, nil + } numIters := 0 totalEvents := 0 for { @@ -219,6 +223,9 @@ func SendAllTelemetry(clientId string) error { } func sendTelemetry(clientId string) error { + if !SendEvents { + return nil + } ctx, cancelFn := context.WithTimeout(context.Background(), WCloudDefaultTimeout) defer cancelFn() activity, err := telemetry.GetNonUploadedActivity(ctx) @@ -255,6 +262,9 @@ func sendTelemetry(clientId string) error { } func SendNoTelemetryUpdate(ctx context.Context, clientId string, noTelemetryVal bool) error { + if !SendEvents { + return nil + } req, err := makeAnonPostReq(ctx, NoTelemetryUrl, NoTelemetryInputType{ClientId: clientId, Value: noTelemetryVal}) if err != nil { return err diff --git a/pkg/wcloud/wcloud_test.go b/pkg/wcloud/wcloud_test.go new file mode 100644 index 0000000000..5f5db038cc --- /dev/null +++ b/pkg/wcloud/wcloud_test.go @@ -0,0 +1,76 @@ +// Copyright 2026, Command Line Inc. +// SPDX-License-Identifier: Apache-2.0 + +package wcloud + +import ( + "context" + "encoding/json" + "io" + "net/http" + "strings" + "testing" +) + +type roundTripFunc func(*http.Request) (*http.Response, error) + +func (fn roundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { + return fn(req) +} + +func TestEventSending(t *testing.T) { + originalClient := http.DefaultClient + originalPingEndpoint := WCloudPingEndpoint_VarCache + t.Cleanup(func() { + http.DefaultClient = originalClient + WCloudPingEndpoint_VarCache = originalPingEndpoint + }) + WCloudPingEndpoint_VarCache = "https://ping.example.test/central" + var requests []*http.Request + var inputs []PingInputType + http.DefaultClient = &http.Client{Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) { + requests = append(requests, req) + if req.Method != http.MethodPost || req.URL.Path != "/central"+PingUrl { + t.Fatalf("unexpected request: %s %s", req.Method, req.URL.Path) + } + var input PingInputType + if err := json.NewDecoder(req.Body).Decode(&input); err != nil { + t.Fatal(err) + } + inputs = append(inputs, input) + return &http.Response{StatusCode: http.StatusOK, Body: io.NopCloser(strings.NewReader(""))}, nil + })} + + ctx := context.Background() + if count, err := sendTEvents("test-client"); err != nil || count != 0 { + t.Fatalf("event batch returned (%d, %v), want (0, nil)", count, err) + } + if err := sendTelemetry("test-client"); err != nil { + t.Fatal(err) + } + for _, disabled := range []bool{false, true} { + if err := SendNoTelemetryUpdate(ctx, "test-client", disabled); err != nil { + t.Fatal(err) + } + } + if len(requests) != 0 { + t.Fatalf("got %d requests with uploads disabled, want 0", len(requests)) + } + + for _, enabled := range []bool{false, true} { + if err := SendDiagnosticPing(ctx, "test-client", enabled); err != nil { + t.Fatal(err) + } + } + if len(inputs) != 2 { + t.Fatalf("got %d pings, want 2", len(inputs)) + } + for i, input := range inputs { + if input.ClientId != "test-client" || input.UsageTelemetry != (i == 1) { + t.Errorf("ping %d did not preserve its input", i) + } + if input.Arch == "" || input.Version == "" || input.LocalDate == "" { + t.Errorf("ping %d is missing app details", i) + } + } +} From b9edb6ed77419291939594980b8cea7d85a43057 Mon Sep 17 00:00:00 2001 From: "augmentcode[bot]" <185243770+augmentcode[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 01:34:36 +0000 Subject: [PATCH 2/3] update host --- pkg/wcloud/wcloud.go | 2 +- pkg/wcloud/wcloud_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/wcloud/wcloud.go b/pkg/wcloud/wcloud.go index 2e9cda1de2..0803935eb6 100644 --- a/pkg/wcloud/wcloud.go +++ b/pkg/wcloud/wcloud.go @@ -25,7 +25,7 @@ import ( const WCloudEndpoint = "https://api.waveterm.dev/central" const WCloudEndpointVarName = "WCLOUD_ENDPOINT" -const WCloudPingEndpoint = "https://ping.waveterm.dev/central" +const WCloudPingEndpoint = "https://cfapi.waveterm.dev/api" const WCloudPingEndpointVarName = "WCLOUD_PING_ENDPOINT" var WCloudEndpoint_VarCache string diff --git a/pkg/wcloud/wcloud_test.go b/pkg/wcloud/wcloud_test.go index 5f5db038cc..a11c8d03c5 100644 --- a/pkg/wcloud/wcloud_test.go +++ b/pkg/wcloud/wcloud_test.go @@ -30,7 +30,7 @@ func TestEventSending(t *testing.T) { var inputs []PingInputType http.DefaultClient = &http.Client{Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) { requests = append(requests, req) - if req.Method != http.MethodPost || req.URL.Path != "/central"+PingUrl { + if req.Method != http.MethodPost || req.URL.Path != "/api"+PingUrl { t.Fatalf("unexpected request: %s %s", req.Method, req.URL.Path) } var input PingInputType From caf9d7e915329a10e0d5d38444a900bc0f96efc5 Mon Sep 17 00:00:00 2001 From: "augmentcode[bot]" <185243770+augmentcode[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 01:49:59 +0000 Subject: [PATCH 3/3] update dev hosts in taskfile --- Taskfile.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 61ec92a7cb..be924cdb79 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -26,7 +26,6 @@ tasks: - build:tsunamiscaffold env: WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env" - WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central" WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central" WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev" WAVETERM_NOCONFIRMQUIT: "1" @@ -41,7 +40,6 @@ tasks: - build:backend env: WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env" - WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central" WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central" WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev" @@ -53,7 +51,6 @@ tasks: - build:backend:quickdev env: WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env" - WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central" WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central" WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev/" WAVETERM_NOCONFIRMQUIT: "1" @@ -80,7 +77,6 @@ tasks: - build:backend:quickdev:windows env: WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env" - WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central" WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central" WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev/" @@ -92,7 +88,6 @@ tasks: - build:backend:quickdev:linux env: WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env" - WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central" WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central" WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev/" WAVETERM_NOCONFIRMQUIT: "1"