Add telemetry event for submitting downgrade feedback.

Этот коммит содержится в:
Conor Macpherson
2023-01-13 14:52:24 -05:00
родитель 51ac81d816
Коммит a13fda6b61
2 изменённых файлов: 29 добавлений и 2 удалений

Просмотреть файл

@@ -132,6 +132,10 @@ func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if subscriptionChange.DowngradeFeedback != nil {
c.App.Srv().GetTelemetryService().SendTelemetry("downgrade_feedback", subscriptionChange.DowngradeFeedback.ToMap())
}
json, err := json.Marshal(changedSub)
if err != nil {
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.app_error", nil, "", http.StatusInternalServerError).Wrap(err)

Просмотреть файл

@@ -4,6 +4,7 @@
package model
import (
"encoding/json"
"strings"
)
@@ -260,9 +261,11 @@ type FailedPayment struct {
type CloudWorkspaceOwner struct {
UserName string `json:"username"`
}
type SubscriptionChange struct {
ProductID string `json:"product_id"`
Seats int `json:"seats"`
ProductID string `json:"product_id"`
Seats int `json:"seats"`
DowngradeFeedback *DowngradeFeedback `json:"downgrade_feedback"`
}
type BoardsLimits struct {
@@ -304,6 +307,11 @@ type CreateSubscriptionRequest struct {
DiscountID string `json:"discount_id"`
}
type DowngradeFeedback struct {
Reason string `json:"reason"`
Comments string `json:"comments"`
}
func (p *Product) IsYearly() bool {
return p.RecurringInterval == RecurringIntervalYearly
}
@@ -311,3 +319,18 @@ func (p *Product) IsYearly() bool {
func (p *Product) IsMonthly() bool {
return p.RecurringInterval == RecurringIntervalMonthly
}
func (df *DowngradeFeedback) ToMap() map[string]any {
var res map[string]any
feedback, err := json.Marshal(df)
if err != nil {
return res
}
err = json.Unmarshal(feedback, &res)
if err != nil {
return res
}
return res
}