Skip to content

Commit

Permalink
[Behavioral Analytics] Remove feature flag to hide functionality (#14…
Browse files Browse the repository at this point in the history
…7429)

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>
  • Loading branch information
joemcelroy and kibanamachine authored Dec 14, 2022
1 parent 1b699fc commit e87e1ce
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,6 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
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.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,5 @@ export interface UsageStats {
'securitySolution:enableGroupedNav': boolean;
'securitySolution:showRelatedIntegrations': boolean;
'visualization:visualize:legacyGaugeChartsLibrary': boolean;
'enterpriseSearch:enableBehavioralAnalyticsSection': boolean;
'enterpriseSearch:enableEnginesSection': boolean;
}
6 changes: 0 additions & 6 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
*/

export const enterpriseSearchFeatureId = 'enterpriseSearch';
export const enableBehavioralAnalyticsSection = 'enterpriseSearch:enableBehavioralAnalyticsSection';
export const enableEnginesSection = 'enterpriseSearch:enableEnginesSection';

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 '.';
Expand All @@ -29,26 +26,14 @@ describe('EnterpriseSearchAnalytics', () => {
});

it('always renders the overview', () => {
mockKibanaValues.uiSettings.get.mockReturnValue(true);

const wrapper = shallow(<Analytics />);

expect(wrapper.find(AnalyticsOverview)).toHaveLength(1);
});

it('renders VersionMismatchPage when there are mismatching versions', () => {
mockKibanaValues.uiSettings.get.mockReturnValue(true);

const wrapper = shallow(<Analytics enterpriseSearchVersion="7.15.0" kibanaVersion="7.16.0" />);

expect(wrapper.find(VersionMismatchPage)).toHaveLength(1);
});

it('renders behavioural analytics is disabled message', () => {
mockKibanaValues.uiSettings.get.mockReturnValue(false);

const wrapper = shallow(<Analytics />);

expect(wrapper.find(AnalyticsFeatureDisabledError)).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,20 @@
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';

export const Analytics: React.FC<InitialAppData> = (props) => {
const { enterpriseSearchVersion, kibanaVersion } = props;
const incompatibleVersions = isVersionMismatch(enterpriseSearchVersion, kibanaVersion);
const { uiSettings } = useValues(KibanaLogic);

const analyticsSectionEnabled = uiSettings?.get<boolean>(enableBehavioralAnalyticsSection, false);

if (!analyticsSectionEnabled) {
return <AnalyticsFeatureDisabledError />;
}

return (
<Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -57,7 +54,7 @@ describe('useEnterpriseSearchContentNav', () => {
name: 'Content',
},
{
id: 'enterpiseSearchEngines',
id: 'enterpriseSearchEngines',
name: 'Engines',
href: '/app/enterprise_search/content/engines',
},
Expand Down Expand Up @@ -99,10 +96,6 @@ describe('useEnterpriseSearchContentNav', () => {
name: 'Search',
},
]);
expect(mockKibanaValues.uiSettings.get).toHaveBeenCalledWith(
enableBehavioralAnalyticsSection,
false
);
expect(mockKibanaValues.uiSettings.get).toHaveBeenCalledWith(enableEnginesSection, false);
});

Expand Down Expand Up @@ -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,
Expand All @@ -233,20 +205,17 @@ 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 = {
hasAppSearchAccess: true,
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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -35,7 +32,6 @@ import { generateNavLink } from './nav_link_helpers';
export const useEnterpriseSearchNav = () => {
const { productAccess, uiSettings } = useValues(KibanaLogic);

const analyticsSectionEnabled = uiSettings?.get<boolean>(enableBehavioralAnalyticsSection, false);
const enginesSectionEnabled = uiSettings?.get<boolean>(enableEnginesSection, false);

const navItems: Array<EuiSideNavItemType<unknown>> = [
Expand Down Expand Up @@ -82,7 +78,7 @@ export const useEnterpriseSearchNav = () => {
...(enginesSectionEnabled
? [
{
id: 'enterpiseSearchEngines',
id: 'enterpriseSearchEngines',
name: i18n.translate('xpack.enterpriseSearch.nav.enginesTitle', {
defaultMessage: 'Engines',
}),
Expand All @@ -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: [
Expand Down
33 changes: 11 additions & 22 deletions x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -74,11 +72,6 @@ export class EnterpriseSearchPlugin implements Plugin {
public setup(core: CoreSetup, plugins: PluginsSetup) {
const { cloud } = plugins;

const bahavioralAnalyticsEnabled = core.uiSettings?.get<boolean>(
enableBehavioralAnalyticsSection,
false
);

core.application.register({
id: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.ID,
title: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.NAV_TITLE,
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit e87e1ce

Please sign in to comment.