From 3703f943ecb2400b49df8455efa56ccdc955b71e Mon Sep 17 00:00:00 2001 From: Martin Kraft Date: Fri, 17 Jun 2022 08:07:28 -0400 Subject: [PATCH] MM-44642 hide insights per license (#20490) * MM-44642: Add a config key for Insights. * MM-44642: Includes feature flag in config key/value conditional. Adds tests. * MM-44642: Send the EnableCustomGroups and InsightsEnabled keys to unlicensed clients too. * MM-44642: Adds some tests for Custom Groups config setting. --- config/client.go | 6 +++ config/client_test.go | 112 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/config/client.go b/config/client.go index dc5d97b7f6..2b24878056 100644 --- a/config/client.go +++ b/config/client.go @@ -129,6 +129,8 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li props["IsDefaultMarketplace"] = strconv.FormatBool(*c.PluginSettings.MarketplaceURL == model.PluginSettingsDefaultMarketplaceURL) props["ExperimentalSharedChannels"] = "false" props["CollapsedThreads"] = *c.ServiceSettings.CollapsedThreads + props["EnableCustomGroups"] = "false" + props["InsightsEnabled"] = "false" if license != nil { props["ExperimentalEnableAuthenticationTransfer"] = strconv.FormatBool(*c.ServiceSettings.ExperimentalEnableAuthenticationTransfer) @@ -203,6 +205,10 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li if license.SkuShortName == model.LicenseShortSkuProfessional || license.SkuShortName == model.LicenseShortSkuEnterprise { props["EnableCustomGroups"] = strconv.FormatBool(*c.ServiceSettings.EnableCustomGroups) } + + if (license.SkuShortName == model.LicenseShortSkuProfessional || license.SkuShortName == model.LicenseShortSkuEnterprise) && c.FeatureFlags.InsightsEnabled { + props["InsightsEnabled"] = "true" + } } return props diff --git a/config/client_test.go b/config/client_test.go index 8402d14af3..e32834136c 100644 --- a/config/client_test.go +++ b/config/client_test.go @@ -150,6 +150,118 @@ func TestGetClientConfig(t *testing.T) { "ShowFullName": "true", }, }, + { + "Insights professional license", + &model.Config{ + FeatureFlags: &model.FeatureFlags{ + InsightsEnabled: true, + }, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: model.LicenseShortSkuProfessional, + }, + map[string]string{ + "InsightsEnabled": "true", + }, + }, + { + "Insights enterprise license", + &model.Config{ + FeatureFlags: &model.FeatureFlags{ + InsightsEnabled: true, + }, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: model.LicenseShortSkuEnterprise, + }, + map[string]string{ + "InsightsEnabled": "true", + }, + }, + { + "Insights other license", + &model.Config{ + FeatureFlags: &model.FeatureFlags{ + InsightsEnabled: true, + }, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: "other", + }, + map[string]string{ + "InsightsEnabled": "false", + }, + }, + { + "Insights professional license, feature flag disabled", + &model.Config{ + FeatureFlags: &model.FeatureFlags{ + InsightsEnabled: false, + }, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: model.LicenseShortSkuProfessional, + }, + map[string]string{ + "InsightsEnabled": "false", + }, + }, + { + "Custom groups professional license", + &model.Config{ + FeatureFlags: &model.FeatureFlags{ + CustomGroups: true, + }, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: model.LicenseShortSkuProfessional, + }, + map[string]string{ + "EnableCustomGroups": "true", + }, + }, + { + "Custom groups enterprise license", + &model.Config{ + FeatureFlags: &model.FeatureFlags{ + CustomGroups: true, + }, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: model.LicenseShortSkuEnterprise, + }, + map[string]string{ + "EnableCustomGroups": "true", + }, + }, + { + "Custom groups other license", + &model.Config{ + FeatureFlags: &model.FeatureFlags{ + InsightsEnabled: true, + }, + }, + "", + &model.License{ + Features: &model.Features{}, + SkuShortName: "other", + }, + map[string]string{ + "EnableCustomGroups": "false", + }, + }, } for _, testCase := range testCases {