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 {