feat(GODT-2713): Send config_progress event once a day if the configuration is stucked in pending for more than a day.

This commit is contained in:
Romain LE JEUNE
2023-06-27 20:16:31 +02:00
parent 08af1da966
commit fa4c0ec823
4 changed files with 77 additions and 1 deletions

View File

@ -82,4 +82,33 @@ func (user *User) SendConfigStatusRecovery() {
}
func (user *User) SendConfigStatusProgress() {
if !user.telemetryManager.IsTelemetryAvailable() {
return
}
if !user.configStatus.IsPending() {
return
}
var builder configstatus.ConfigProgressBuilder
progress := builder.New(user.configStatus.Data)
if progress.Values.NbDaySinceLast == 0 || progress.Values.NbDay == 0 {
return
}
data, err := json.Marshal(progress)
if err != nil {
if err := user.reporter.ReportMessageWithContext("Cannot parse config_progress data.", reporter.Context{
"error": err,
}); err != nil {
user.log.WithError(err).Error("Failed to report config_progress data parsing error.")
}
return
}
if err := user.SendTelemetry(context.Background(), data); err == nil {
user.log.Info("Configuration Status Progress event sent.")
if err := user.configStatus.ApplyProgress(); err != nil {
user.log.WithError(err).Error("Failed to ApplyProgress on config_status.")
}
}
}