(clientId string)
| 219 | } |
| 220 | |
| 221 | func sendTelemetry(clientId string) error { |
| 222 | ctx, cancelFn := context.WithTimeout(context.Background(), WCloudDefaultTimeout) |
| 223 | defer cancelFn() |
| 224 | activity, err := telemetry.GetNonUploadedActivity(ctx) |
| 225 | if err != nil { |
| 226 | return fmt.Errorf("cannot get activity: %v", err) |
| 227 | } |
| 228 | if len(activity) == 0 { |
| 229 | return nil |
| 230 | } |
| 231 | log.Printf("[wcloud] sending telemetry data\n") |
| 232 | dayStr := daystr.GetCurDayStr() |
| 233 | input := TelemetryInputType{ |
| 234 | ClientId: clientId, |
| 235 | UserId: clientId, |
| 236 | AppType: "w2", |
| 237 | AutoUpdateEnabled: telemetry.IsAutoUpdateEnabled(), |
| 238 | AutoUpdateChannel: telemetry.AutoUpdateChannel(), |
| 239 | CurDay: dayStr, |
| 240 | Activity: activity, |
| 241 | } |
| 242 | req, err := makeAnonPostReq(ctx, TelemetryUrl, input) |
| 243 | if err != nil { |
| 244 | return err |
| 245 | } |
| 246 | _, err = doRequest(req, nil, true) |
| 247 | if err != nil { |
| 248 | return err |
| 249 | } |
| 250 | err = telemetry.MarkActivityAsUploaded(ctx, activity) |
| 251 | if err != nil { |
| 252 | return fmt.Errorf("error marking activity as uploaded: %v", err) |
| 253 | } |
| 254 | return nil |
| 255 | } |
| 256 | |
| 257 | func SendNoTelemetryUpdate(ctx context.Context, clientId string, noTelemetryVal bool) error { |
| 258 | req, err := makeAnonPostReq(ctx, NoTelemetryUrl, NoTelemetryInputType{ClientId: clientId, Value: noTelemetryVal}) |
nothing calls this directly
no test coverage detected