Merge pull request #22078 from mattermost/MM-49474-add-downgrade-feedback

MM-49474 - Add Telemetry Event for Submitting Downgrade Feedback
Этот коммит содержится в:
Conor Macpherson
2023-01-17 11:19:33 -05:00
коммит произвёл GitHub
родитель c99f9b1f57 2e04003fc2
Коммит 087aa38afb
2 изменённых файлов: 29 добавлений и 2 удалений

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

@@ -135,6 +135,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
}