diff --git a/app/diagnostics.go b/app/diagnostics.go index bee7fb0b42..53d656f3c3 100644 --- a/app/diagnostics.go +++ b/app/diagnostics.go @@ -8,10 +8,9 @@ import ( "runtime" "strings" - "github.com/segmentio/analytics-go" - "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" + analytics "github.com/segmentio/analytics-go" ) const ( @@ -569,6 +568,7 @@ func (a *App) trackLicense() { "start": license.StartsAt, "expire": license.ExpiresAt, "users": *license.Features.Users, + "edition": license.SkuShortName, } features := license.Features.ToMap() diff --git a/app/license.go b/app/license.go index ea7f7d4b0c..5cd7134f59 100644 --- a/app/license.go +++ b/app/license.go @@ -212,6 +212,8 @@ func (a *App) GetSanitizedClientLicense() map[string]string { delete(sanitizedLicense, "IssuedAt") delete(sanitizedLicense, "StartsAt") delete(sanitizedLicense, "ExpiresAt") + delete(sanitizedLicense, "SkuName") + delete(sanitizedLicense, "SkuShortName") return sanitizedLicense } diff --git a/app/license_test.go b/app/license_test.go index f86d604d10..4a5f7df0ea 100644 --- a/app/license_test.go +++ b/app/license_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/mattermost/mattermost-server/model" + "github.com/stretchr/testify/assert" ) func TestLoadLicense(t *testing.T) { @@ -100,13 +101,18 @@ func TestGetSanitizedClientLicense(t *testing.T) { l1.Features = &model.Features{} l1.Customer = &model.Customer{} l1.Customer.Name = "TestName" + l1.SkuName = "SKU NAME" + l1.SkuShortName = "SKU SHORT NAME" l1.StartsAt = model.GetMillis() - 1000 l1.ExpiresAt = model.GetMillis() + 100000 th.App.SetLicense(l1) m := th.App.GetSanitizedClientLicense() - if _, ok := m["Name"]; ok { - t.Fatal("should have been sanatized") - } + _, ok := m["Name"] + assert.False(t, ok) + _, ok = m["SkuName"] + assert.False(t, ok) + _, ok = m["SkuShortName"] + assert.False(t, ok) } diff --git a/model/license.go b/model/license.go index fdf18285fd..e2ef3b0d58 100644 --- a/model/license.go +++ b/model/license.go @@ -21,12 +21,14 @@ type LicenseRecord struct { } type License struct { - Id string `json:"id"` - IssuedAt int64 `json:"issued_at"` - StartsAt int64 `json:"starts_at"` - ExpiresAt int64 `json:"expires_at"` - Customer *Customer `json:"customer"` - Features *Features `json:"features"` + Id string `json:"id"` + IssuedAt int64 `json:"issued_at"` + StartsAt int64 `json:"starts_at"` + ExpiresAt int64 `json:"expires_at"` + Customer *Customer `json:"customer"` + Features *Features `json:"features"` + SkuName string `json:"sku_name"` + SkuShortName string `json:"sku_short_name"` } type Customer struct { diff --git a/utils/license.go b/utils/license.go index b84ef7007b..95994e24e8 100644 --- a/utils/license.go +++ b/utils/license.go @@ -128,6 +128,8 @@ func GetClientLicense(l *model.License) map[string]string { if l != nil { props["Id"] = l.Id + props["SkuName"] = l.SkuName + props["SkuShortName"] = l.SkuShortName props["Users"] = strconv.Itoa(*l.Features.Users) props["LDAP"] = strconv.FormatBool(*l.Features.LDAP) props["MFA"] = strconv.FormatBool(*l.Features.MFA)