diff --git a/pkg/service/clientservice/clientservice.go b/pkg/service/clientservice/clientservice.go index 44638852a..f2a8d9b68 100644 --- a/pkg/service/clientservice/clientservice.go +++ b/pkg/service/clientservice/clientservice.go @@ -110,6 +110,25 @@ func (cs *ClientService) AgreeTos(ctx context.Context) (waveobj.UpdatesRtnType, return waveobj.ContextGetUpdatesRtn(ctx), nil } +func sendNoTelemetryUpdate(telemetryEnabled bool) { + ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) + defer cancelFn() + clientData, err := wstore.DBGetSingleton[*waveobj.Client](ctx) + if err != nil { + log.Printf("telemetry update: error getting client data: %v\n", err) + return + } + if clientData == nil { + log.Printf("telemetry update: client data is nil\n") + return + } + err = wcloud.SendNoTelemetryUpdate(ctx, clientData.OID, !telemetryEnabled) + if err != nil { + log.Printf("[error] sending no-telemetry update: %v\n", err) + return + } +} + func (cs *ClientService) TelemetryUpdate(ctx context.Context, telemetryEnabled bool) error { meta := waveobj.MetaMapType{ wconfig.ConfigKey_TelemetryEnabled: telemetryEnabled, @@ -118,17 +137,6 @@ func (cs *ClientService) TelemetryUpdate(ctx context.Context, telemetryEnabled b if err != nil { return fmt.Errorf("error setting telemetry value: %w", err) } - clientData, err := wstore.DBGetSingleton[*waveobj.Client](ctx) - if err != nil { - return fmt.Errorf("error getting client data: %w", err) - } - if clientData == nil { - return fmt.Errorf("client data is nil") - } - telemetryErr := wcloud.SendNoTelemetryUpdate(ctx, clientData.OID, !telemetryEnabled) - if telemetryErr != nil { - // don't return error here, just log - log.Printf("[error] sending telemetry update: %v\n", telemetryErr) - } + go sendNoTelemetryUpdate(telemetryEnabled) return nil }