mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
make no-telemetry request async
This commit is contained in:
parent
3ea8f45284
commit
91a85e06c8
@ -110,6 +110,25 @@ func (cs *ClientService) AgreeTos(ctx context.Context) (waveobj.UpdatesRtnType,
|
|||||||
return waveobj.ContextGetUpdatesRtn(ctx), nil
|
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 {
|
func (cs *ClientService) TelemetryUpdate(ctx context.Context, telemetryEnabled bool) error {
|
||||||
meta := waveobj.MetaMapType{
|
meta := waveobj.MetaMapType{
|
||||||
wconfig.ConfigKey_TelemetryEnabled: telemetryEnabled,
|
wconfig.ConfigKey_TelemetryEnabled: telemetryEnabled,
|
||||||
@ -118,17 +137,6 @@ func (cs *ClientService) TelemetryUpdate(ctx context.Context, telemetryEnabled b
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error setting telemetry value: %w", err)
|
return fmt.Errorf("error setting telemetry value: %w", err)
|
||||||
}
|
}
|
||||||
clientData, err := wstore.DBGetSingleton[*waveobj.Client](ctx)
|
go sendNoTelemetryUpdate(telemetryEnabled)
|
||||||
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)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user