From e87e1cef5ebb6df895fc393f9cb5993334383398 Mon Sep 17 00:00:00 2001 From: Joseph McElroy Date: Wed, 14 Dec 2022 11:52:43 +0000 Subject: [PATCH] [Behavioral Analytics] Remove feature flag to hide functionality (#147429) Removing feature flag code from behavorial analytics. Behavorial Analytics is now accessible generally. This involves removing the feature flag from uiSettings. Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../server/collectors/management/schema.ts | 4 -- .../server/collectors/management/types.ts | 1 - src/plugins/telemetry/schema/oss_plugins.json | 6 --- .../common/ui_settings_keys.ts | 1 - .../analytics_feature_disabled_error.test.tsx | 26 ---------- .../analytics_feature_disabled_error.tsx | 31 ------------ .../applications/analytics/index.test.tsx | 15 ------ .../public/applications/analytics/index.tsx | 12 ----- .../applications/shared/layout/nav.test.tsx | 41 ++------------- .../public/applications/shared/layout/nav.tsx | 50 ++++++++----------- .../enterprise_search/public/plugin.ts | 33 ++++-------- .../translations/translations/fr-FR.json | 1 - .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - 14 files changed, 37 insertions(+), 186 deletions(-) delete mode 100644 x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.test.tsx delete mode 100644 x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.tsx diff --git a/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts b/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts index cb64f95915c5e..25a943496ab81 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts @@ -574,10 +574,6 @@ export const stackManagementSchema: MakeSchemaFrom = { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, }, - 'enterpriseSearch:enableBehavioralAnalyticsSection': { - type: 'boolean', - _meta: { description: 'Non-default value of setting.' }, - }, 'enterpriseSearch:enableEnginesSection': { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, diff --git a/src/plugins/kibana_usage_collection/server/collectors/management/types.ts b/src/plugins/kibana_usage_collection/server/collectors/management/types.ts index a57bb1ef016fd..a7bb32f53bd10 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/management/types.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/management/types.ts @@ -153,6 +153,5 @@ export interface UsageStats { 'securitySolution:enableGroupedNav': boolean; 'securitySolution:showRelatedIntegrations': boolean; 'visualization:visualize:legacyGaugeChartsLibrary': boolean; - 'enterpriseSearch:enableBehavioralAnalyticsSection': boolean; 'enterpriseSearch:enableEnginesSection': boolean; } diff --git a/src/plugins/telemetry/schema/oss_plugins.json b/src/plugins/telemetry/schema/oss_plugins.json index e3bd69c3bd243..deef2fc562954 100644 --- a/src/plugins/telemetry/schema/oss_plugins.json +++ b/src/plugins/telemetry/schema/oss_plugins.json @@ -9114,12 +9114,6 @@ "description": "Non-default value of setting." } }, - "enterpriseSearch:enableBehavioralAnalyticsSection": { - "type": "boolean", - "_meta": { - "description": "Non-default value of setting." - } - }, "enterpriseSearch:enableEnginesSection": { "type": "boolean", "_meta": { diff --git a/x-pack/plugins/enterprise_search/common/ui_settings_keys.ts b/x-pack/plugins/enterprise_search/common/ui_settings_keys.ts index 1c6cec2ca9c15..9438c0a803f98 100644 --- a/x-pack/plugins/enterprise_search/common/ui_settings_keys.ts +++ b/x-pack/plugins/enterprise_search/common/ui_settings_keys.ts @@ -6,5 +6,4 @@ */ export const enterpriseSearchFeatureId = 'enterpriseSearch'; -export const enableBehavioralAnalyticsSection = 'enterpriseSearch:enableBehavioralAnalyticsSection'; export const enableEnginesSection = 'enterpriseSearch:enableEnginesSection'; diff --git a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.test.tsx b/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.test.tsx deleted file mode 100644 index 51f417df97984..0000000000000 --- a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.test.tsx +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; - -import { shallow } from 'enzyme'; - -import { EuiEmptyPrompt } from '@elastic/eui'; - -import { AnalyticsFeatureDisabledError } from './analytics_feature_disabled_error'; - -describe('AnalyticsFeatureDisabledError', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - it('renders ', () => { - const wrapper = shallow(); - - expect(wrapper.find(EuiEmptyPrompt)).toHaveLength(1); - }); -}); diff --git a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.tsx b/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.tsx deleted file mode 100644 index 1cbcf0b208cb7..0000000000000 --- a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_feature_disabled_error/analytics_feature_disabled_error.tsx +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; - -import { EuiEmptyPrompt } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template'; - -export const AnalyticsFeatureDisabledError: React.FC = () => { - return ( - - - {i18n.translate('xpack.enterpriseSearch.analytics.featureDisabledState.title', { - defaultMessage: 'Behavioural Analytics is disabled', - })} - - } - titleSize="l" - /> - - ); -}; diff --git a/x-pack/plugins/enterprise_search/public/applications/analytics/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/analytics/index.test.tsx index 4a8fcf7573a36..d3261eb265c06 100644 --- a/x-pack/plugins/enterprise_search/public/applications/analytics/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/analytics/index.test.tsx @@ -10,15 +10,12 @@ import '../__mocks__/kea_logic'; import '../__mocks__/shallow_useeffect.mock'; import '../__mocks__/enterprise_search_url.mock'; -import { mockKibanaValues } from '../__mocks__/kea_logic'; - import React from 'react'; import { shallow } from 'enzyme'; import { VersionMismatchPage } from '../shared/version_mismatch'; -import { AnalyticsFeatureDisabledError } from './components/analytics_feature_disabled_error/analytics_feature_disabled_error'; import { AnalyticsOverview } from './components/analytics_overview/analytics_overview'; import { Analytics } from '.'; @@ -29,26 +26,14 @@ describe('EnterpriseSearchAnalytics', () => { }); it('always renders the overview', () => { - mockKibanaValues.uiSettings.get.mockReturnValue(true); - const wrapper = shallow(); expect(wrapper.find(AnalyticsOverview)).toHaveLength(1); }); it('renders VersionMismatchPage when there are mismatching versions', () => { - mockKibanaValues.uiSettings.get.mockReturnValue(true); - const wrapper = shallow(); expect(wrapper.find(VersionMismatchPage)).toHaveLength(1); }); - - it('renders behavioural analytics is disabled message', () => { - mockKibanaValues.uiSettings.get.mockReturnValue(false); - - const wrapper = shallow(); - - expect(wrapper.find(AnalyticsFeatureDisabledError)).toHaveLength(1); - }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/analytics/index.tsx b/x-pack/plugins/enterprise_search/public/applications/analytics/index.tsx index f1228682fe888..b2f7d20bf261c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/analytics/index.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/analytics/index.tsx @@ -8,18 +8,13 @@ import React from 'react'; import { Route, Switch } from 'react-router-dom'; -import { useValues } from 'kea'; - import { isVersionMismatch } from '../../../common/is_version_mismatch'; import { InitialAppData } from '../../../common/types'; -import { enableBehavioralAnalyticsSection } from '../../../common/ui_settings_keys'; -import { KibanaLogic } from '../shared/kibana'; import { VersionMismatchPage } from '../shared/version_mismatch'; import { AddAnalyticsCollection } from './components/add_analytics_collections/add_analytics_collection'; import { AnalyticsCollectionView } from './components/analytics_collection_view/analytics_collection_view'; -import { AnalyticsFeatureDisabledError } from './components/analytics_feature_disabled_error/analytics_feature_disabled_error'; import { AnalyticsOverview } from './components/analytics_overview/analytics_overview'; import { ROOT_PATH, COLLECTION_CREATION_PATH, COLLECTION_VIEW_PATH } from './routes'; @@ -27,13 +22,6 @@ import { ROOT_PATH, COLLECTION_CREATION_PATH, COLLECTION_VIEW_PATH } from './rou export const Analytics: React.FC = (props) => { const { enterpriseSearchVersion, kibanaVersion } = props; const incompatibleVersions = isVersionMismatch(enterpriseSearchVersion, kibanaVersion); - const { uiSettings } = useValues(KibanaLogic); - - const analyticsSectionEnabled = uiSettings?.get(enableBehavioralAnalyticsSection, false); - - if (!analyticsSectionEnabled) { - return ; - } return ( diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.test.tsx index 167e2850f1b85..2df0c2de2abdb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.test.tsx @@ -13,10 +13,7 @@ import { setMockValues, mockKibanaValues } from '../../__mocks__/kea_logic'; import { ProductAccess } from '../../../../common/types'; -import { - enableBehavioralAnalyticsSection, - enableEnginesSection, -} from '../../../../common/ui_settings_keys'; +import { enableEnginesSection } from '../../../../common/ui_settings_keys'; import { useEnterpriseSearchNav } from './nav'; @@ -57,7 +54,7 @@ describe('useEnterpriseSearchContentNav', () => { name: 'Content', }, { - id: 'enterpiseSearchEngines', + id: 'enterpriseSearchEngines', name: 'Engines', href: '/app/enterprise_search/content/engines', }, @@ -99,10 +96,6 @@ describe('useEnterpriseSearchContentNav', () => { name: 'Search', }, ]); - expect(mockKibanaValues.uiSettings.get).toHaveBeenCalledWith( - enableBehavioralAnalyticsSection, - false - ); expect(mockKibanaValues.uiSettings.get).toHaveBeenCalledWith(enableEnginesSection, false); }); @@ -204,27 +197,6 @@ describe('useEnterpriseSearchContentNav', () => { }); }); - it('excludes analytics when feature flag is off', () => { - const fullProductAccess: ProductAccess = { - hasAppSearchAccess: true, - hasWorkplaceSearchAccess: true, - }; - setMockValues({ productAccess: fullProductAccess }); - - const esNav = useEnterpriseSearchNav(); - expect(esNav.find((item) => item.id === 'enterpriseSearchAnalytics')).toBeUndefined(); - }); - it('includes analytics when feature flag is off', () => { - const fullProductAccess: ProductAccess = { - hasAppSearchAccess: true, - hasWorkplaceSearchAccess: true, - }; - setMockValues({ productAccess: fullProductAccess }); - mockKibanaValues.uiSettings.get.mockReturnValueOnce(true).mockReturnValue(false); - - const esNav = useEnterpriseSearchNav(); - expect(esNav.find((item) => item.id === 'enterpriseSearchAnalytics')).not.toBeUndefined(); - }); it('excludes engines when feature flag is off', () => { const fullProductAccess: ProductAccess = { hasAppSearchAccess: true, @@ -233,7 +205,7 @@ describe('useEnterpriseSearchContentNav', () => { setMockValues({ productAccess: fullProductAccess }); const esNav = useEnterpriseSearchNav(); - expect(esNav.find((item) => item.id === 'enterpiseSearchEngines')).toBeUndefined(); + expect(esNav.find((item) => item.id === 'enterpriseSearchEngines')).toBeUndefined(); }); it('includes engines when feature flag is on', () => { const fullProductAccess: ProductAccess = { @@ -241,12 +213,9 @@ describe('useEnterpriseSearchContentNav', () => { hasWorkplaceSearchAccess: true, }; setMockValues({ productAccess: fullProductAccess }); - mockKibanaValues.uiSettings.get - .mockReturnValueOnce(false) - .mockReturnValueOnce(true) - .mockReturnValue(false); + mockKibanaValues.uiSettings.get.mockReturnValue(true); const esNav = useEnterpriseSearchNav(); - expect(esNav.find((item) => item.id === 'enterpiseSearchEngines')).not.toBeUndefined(); + expect(esNav.find((item) => item.id === 'enterpriseSearchEngines')).not.toBeUndefined(); }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.tsx index 4eee88ecd474e..6060fc13f85d4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.tsx @@ -19,10 +19,7 @@ import { SEARCH_EXPERIENCES_PLUGIN, WORKPLACE_SEARCH_PLUGIN, } from '../../../../common/constants'; -import { - enableBehavioralAnalyticsSection, - enableEnginesSection, -} from '../../../../common/ui_settings_keys'; +import { enableEnginesSection } from '../../../../common/ui_settings_keys'; import { ENGINES_PATH, SEARCH_INDICES_PATH, @@ -35,7 +32,6 @@ import { generateNavLink } from './nav_link_helpers'; export const useEnterpriseSearchNav = () => { const { productAccess, uiSettings } = useValues(KibanaLogic); - const analyticsSectionEnabled = uiSettings?.get(enableBehavioralAnalyticsSection, false); const enginesSectionEnabled = uiSettings?.get(enableEnginesSection, false); const navItems: Array> = [ @@ -82,7 +78,7 @@ export const useEnterpriseSearchNav = () => { ...(enginesSectionEnabled ? [ { - id: 'enterpiseSearchEngines', + id: 'enterpriseSearchEngines', name: i18n.translate('xpack.enterpriseSearch.nav.enginesTitle', { defaultMessage: 'Engines', }), @@ -94,29 +90,25 @@ export const useEnterpriseSearchNav = () => { }, ] : []), - ...(analyticsSectionEnabled - ? [ - { - id: 'enterpriseSearchAnalytics', - items: [ - { - id: 'analytics_collections', - name: i18n.translate('xpack.enterpriseSearch.nav.analyticsCollectionsTitle', { - defaultMessage: 'Collections', - }), - ...generateNavLink({ - shouldNotCreateHref: true, - shouldShowActiveForSubroutes: true, - to: ANALYTICS_PLUGIN.URL, - }), - }, - ], - name: i18n.translate('xpack.enterpriseSearch.nav.analyticsTitle', { - defaultMessage: 'Analytics', - }), - }, - ] - : []), + { + id: 'enterpriseSearchAnalytics', + items: [ + { + id: 'analytics_collections', + name: i18n.translate('xpack.enterpriseSearch.nav.analyticsCollectionsTitle', { + defaultMessage: 'Collections', + }), + ...generateNavLink({ + shouldNotCreateHref: true, + shouldShowActiveForSubroutes: true, + to: ANALYTICS_PLUGIN.URL, + }), + }, + ], + name: i18n.translate('xpack.enterpriseSearch.nav.analyticsTitle', { + defaultMessage: 'Analytics', + }), + }, { id: 'search', items: [ diff --git a/x-pack/plugins/enterprise_search/public/plugin.ts b/x-pack/plugins/enterprise_search/public/plugin.ts index 6e35890bdcaa5..c68f59a50619d 100644 --- a/x-pack/plugins/enterprise_search/public/plugin.ts +++ b/x-pack/plugins/enterprise_search/public/plugin.ts @@ -34,8 +34,6 @@ import { } from '../common/constants'; import { InitialAppData } from '../common/types'; -import { enableBehavioralAnalyticsSection } from '../common/ui_settings_keys'; - import { docLinks } from './applications/shared/doc_links'; export interface ClientConfigType { @@ -74,11 +72,6 @@ export class EnterpriseSearchPlugin implements Plugin { public setup(core: CoreSetup, plugins: PluginsSetup) { const { cloud } = plugins; - const bahavioralAnalyticsEnabled = core.uiSettings?.get( - enableBehavioralAnalyticsSection, - false - ); - core.application.register({ id: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.ID, title: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.NAV_TITLE, @@ -129,10 +122,8 @@ export class EnterpriseSearchPlugin implements Plugin { id: ANALYTICS_PLUGIN.ID, title: ANALYTICS_PLUGIN.NAME, euiIconType: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.LOGO, - searchable: bahavioralAnalyticsEnabled, - navLinkStatus: bahavioralAnalyticsEnabled - ? AppNavLinkStatus.default - : AppNavLinkStatus.hidden, + searchable: true, + navLinkStatus: AppNavLinkStatus.default, appRoute: ANALYTICS_PLUGIN.URL, category: DEFAULT_APP_CATEGORIES.enterpriseSearch, mount: async (params: AppMountParameters) => { @@ -247,17 +238,15 @@ export class EnterpriseSearchPlugin implements Plugin { order: 100, }); - if (bahavioralAnalyticsEnabled) { - plugins.home.featureCatalogue.register({ - id: ANALYTICS_PLUGIN.ID, - title: ANALYTICS_PLUGIN.NAME, - icon: 'appAnalytics', - description: ANALYTICS_PLUGIN.DESCRIPTION, - path: ANALYTICS_PLUGIN.URL, - category: 'data', - showOnHomePage: false, - }); - } + plugins.home.featureCatalogue.register({ + id: ANALYTICS_PLUGIN.ID, + title: ANALYTICS_PLUGIN.NAME, + icon: 'appAnalytics', + description: ANALYTICS_PLUGIN.DESCRIPTION, + path: ANALYTICS_PLUGIN.URL, + category: 'data', + showOnHomePage: false, + }); plugins.home.featureCatalogue.register({ id: APP_SEARCH_PLUGIN.ID, diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index d3fa0147a18cb..424033fab2769 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -11010,7 +11010,6 @@ "xpack.enterpriseSearch.analytics.collectionsView.tabs.eventsName": "Événements", "xpack.enterpriseSearch.analytics.collectionsView.tabs.integrateName": "Intégrer", "xpack.enterpriseSearch.analytics.collectionsView.tabs.settingsName": "Paramètres", - "xpack.enterpriseSearch.analytics.featureDisabledState.title": "L'analyse comportementale est désactivée", "xpack.enterpriseSearch.analytics.productCardDescription": "Tableaux de bord et outils permettant de visualiser le comportement des utilisateurs finaux et de mesurer les performances de vos applications de recherche.", "xpack.enterpriseSearch.analytics.productDescription": "Tableaux de bord et outils permettant de visualiser le comportement des utilisateurs finaux et de mesurer les performances de vos applications de recherche.", "xpack.enterpriseSearch.analytics.productName": "Analyse", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 97e414267b619..91da7a03e5bbf 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -10997,7 +10997,6 @@ "xpack.enterpriseSearch.analytics.collectionsView.tabs.eventsName": "イベント", "xpack.enterpriseSearch.analytics.collectionsView.tabs.integrateName": "統合", "xpack.enterpriseSearch.analytics.collectionsView.tabs.settingsName": "設定", - "xpack.enterpriseSearch.analytics.featureDisabledState.title": "行動分析が無効です", "xpack.enterpriseSearch.analytics.productCardDescription": "エンドユーザーの行動を可視化し、検索アプリケーションのパフォーマンスを測定するためのダッシュボードとツール。", "xpack.enterpriseSearch.analytics.productDescription": "エンドユーザーの行動を可視化し、検索アプリケーションのパフォーマンスを測定するためのダッシュボードとツール。", "xpack.enterpriseSearch.analytics.productName": "分析", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 88f1630c01cb0..98387aeea244d 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -11014,7 +11014,6 @@ "xpack.enterpriseSearch.analytics.collectionsView.tabs.eventsName": "事件", "xpack.enterpriseSearch.analytics.collectionsView.tabs.integrateName": "集成", "xpack.enterpriseSearch.analytics.collectionsView.tabs.settingsName": "设置", - "xpack.enterpriseSearch.analytics.featureDisabledState.title": "行为分析已禁用", "xpack.enterpriseSearch.analytics.productCardDescription": "用于对最终用户行为进行可视化并评估搜索应用程序性能的仪表板和工具。", "xpack.enterpriseSearch.analytics.productDescription": "用于对最终用户行为进行可视化并评估搜索应用程序性能的仪表板和工具。", "xpack.enterpriseSearch.analytics.productName": "分析",