forked from Silverfish/proton-bridge
feat(GODT-2711): Send config_abort event on User removal.
This commit is contained in:
@ -608,6 +608,11 @@ func (bridge *Bridge) logoutUser(ctx context.Context, user *user.User, withAPI,
|
|||||||
logrus.WithError(err).Error("Failed to remove IMAP user")
|
logrus.WithError(err).Error("Failed to remove IMAP user")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if this is actually a remove account
|
||||||
|
if withData && withAPI {
|
||||||
|
user.SendConfigStatusAbort()
|
||||||
|
}
|
||||||
|
|
||||||
if err := user.Logout(ctx, withAPI); err != nil {
|
if err := user.Logout(ctx, withAPI); err != nil {
|
||||||
logrus.WithError(err).Error("Failed to logout user")
|
logrus.WithError(err).Error("Failed to logout user")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,4 +17,38 @@
|
|||||||
|
|
||||||
package configstatus
|
package configstatus
|
||||||
|
|
||||||
// GODT-2711
|
import "time"
|
||||||
|
|
||||||
|
type ConfigAbortValues struct {
|
||||||
|
Duration int `json:"duration"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigAbortDimensions struct {
|
||||||
|
ReportClick interface{} `json:"report_click"`
|
||||||
|
ReportSent interface{} `json:"report_sent"`
|
||||||
|
ClickedLink uint64 `json:"clicked_link"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigAbortData struct {
|
||||||
|
MeasurementGroup string
|
||||||
|
Event string
|
||||||
|
Values ConfigSuccessValues
|
||||||
|
Dimensions ConfigSuccessDimensions
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigAbortBuilder struct{}
|
||||||
|
|
||||||
|
func (*ConfigAbortBuilder) New(data *ConfigurationStatusData) ConfigAbortData {
|
||||||
|
return ConfigAbortData{
|
||||||
|
MeasurementGroup: "bridge.any.configuration",
|
||||||
|
Event: "bridge_config_abort",
|
||||||
|
Values: ConfigSuccessValues{
|
||||||
|
Duration: int(time.Since(data.DataV1.PendingSince).Minutes()),
|
||||||
|
},
|
||||||
|
Dimensions: ConfigSuccessDimensions{
|
||||||
|
ReportClick: data.DataV1.ReportClick,
|
||||||
|
ReportSent: data.DataV1.ReportSent,
|
||||||
|
ClickedLink: data.DataV1.ClickedLink,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -29,7 +29,6 @@ func (user *User) SendConfigStatusSuccess() {
|
|||||||
if !user.telemetryManager.IsTelemetryAvailable() {
|
if !user.telemetryManager.IsTelemetryAvailable() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !user.configStatus.IsPending() {
|
if !user.configStatus.IsPending() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -41,11 +40,13 @@ func (user *User) SendConfigStatusSuccess() {
|
|||||||
if err := user.reporter.ReportMessageWithContext("Cannot parse config_success data.", reporter.Context{
|
if err := user.reporter.ReportMessageWithContext("Cannot parse config_success data.", reporter.Context{
|
||||||
"error": err,
|
"error": err,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
user.log.WithError(err).Error("Failed to parse config_success data.")
|
user.log.WithError(err).Error("Failed to report config_success data parsing error.")
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := user.SendTelemetry(context.Background(), data); err == nil {
|
if err := user.SendTelemetry(context.Background(), data); err == nil {
|
||||||
|
user.log.Info("Configuration Status Success event sent.")
|
||||||
if err := user.configStatus.ApplySuccess(); err != nil {
|
if err := user.configStatus.ApplySuccess(); err != nil {
|
||||||
user.log.WithError(err).Error("Failed to ApplySuccess on config_status.")
|
user.log.WithError(err).Error("Failed to ApplySuccess on config_status.")
|
||||||
}
|
}
|
||||||
@ -53,6 +54,28 @@ func (user *User) SendConfigStatusSuccess() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) SendConfigStatusAbort() {
|
func (user *User) SendConfigStatusAbort() {
|
||||||
|
if !user.telemetryManager.IsTelemetryAvailable() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !user.configStatus.IsPending() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var builder configstatus.ConfigAbortBuilder
|
||||||
|
abort := builder.New(user.configStatus.Data)
|
||||||
|
data, err := json.Marshal(abort)
|
||||||
|
if err != nil {
|
||||||
|
if err := user.reporter.ReportMessageWithContext("Cannot parse config_abort data.", reporter.Context{
|
||||||
|
"error": err,
|
||||||
|
}); err != nil {
|
||||||
|
user.log.WithError(err).Error("Failed to report config_abort data parsing error.")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := user.SendTelemetry(context.Background(), data); err == nil {
|
||||||
|
user.log.Info("Configuration Status Abort event sent.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) SendConfigStatusRecovery() {
|
func (user *User) SendConfigStatusRecovery() {
|
||||||
|
|||||||
Reference in New Issue
Block a user