Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Flags Service] Hello world 👋 #188562

Merged
merged 49 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
478d593
[Feature Flags Service] Hello world :wave:
afharo Jul 15, 2024
5fb7016
Cloud Experiments integration + server service + mocks
afharo Jul 17, 2024
cf8d28c
Actual usage
afharo Jul 17, 2024
7abfbf4
Remove left overs in navigation plugin
afharo Jul 18, 2024
7e82b16
Further cleanup + tsconfig.json updates
afharo Jul 18, 2024
8f22456
More cleanup + cloudExperiments tests
afharo Jul 19, 2024
53a9daa
Further cleanup
afharo Jul 19, 2024
c2f1bd7
Add unit tests
afharo Jul 19, 2024
4df2227
Add config overrides on the server-side
afharo Jul 19, 2024
1af5729
lint ts projects
afharo Jul 22, 2024
5f80536
Support overrides on the browser
afharo Jul 22, 2024
d1a7d8c
[renovate] OpenFeature should match LaunchDarkly upgrade strategy
afharo Jul 23, 2024
37e23f7
Use organizationId and orchestratorTarget from the cloud plugin
afharo Jul 24, 2024
7d4f065
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 24, 2024
3a2e5b6
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jul 24, 2024
8dc8628
Read config later so that the config definition is registered
afharo Jul 26, 2024
6d3dc21
Add http handler context + docs + example plugin
afharo Jul 27, 2024
cd414b5
Update limits
afharo Jul 27, 2024
78cdc41
Fix mocks and dynamic config references
afharo Jul 27, 2024
c92f509
Fix test
afharo Jul 27, 2024
2c00b35
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jul 27, 2024
0f6f908
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Jul 27, 2024
42394a4
Address CI errors
afharo Jul 27, 2024
6dc2f51
Remove export from src/core/server
afharo Jul 27, 2024
f803423
Add request handler context to the mocks
afharo Jul 27, 2024
3f77d4b
Add featureFlags' mocks to Fleet's storybook mocks
afharo Jul 27, 2024
ac50eeb
Merge branch 'main' of github.com:elastic/kibana into core-feature-fl…
afharo Jul 29, 2024
9541f7e
Update package types of the new packages
afharo Jul 29, 2024
320b717
Add jsdocs to the setup contract
afharo Jul 30, 2024
3dc6060
Update packages/core/feature-flags/core-feature-flags-browser/src/typ…
afharo Aug 1, 2024
5881d9e
Improve types of `EvaluationContext`
afharo Aug 1, 2024
b5e5699
Merge branch 'main' of github.com:elastic/kibana into core-feature-fl…
afharo Aug 1, 2024
ddb6063
Merge branch 'main' of github.com:elastic/kibana into core-feature-fl…
afharo Aug 2, 2024
bc268b8
Update x-pack/plugins/cloud_integrations/cloud_experiments/common/met…
afharo Aug 2, 2024
eeacb85
Add assertions to "with overrides" tests
afharo Aug 2, 2024
59c2d99
Use `switchMap` instead of `mergeMap`
afharo Aug 2, 2024
9026d32
Report in APM when the provider init is taking too long
afharo Aug 2, 2024
036a146
Merge branch 'main' into core-feature-flags-service
afharo Aug 2, 2024
d888c6e
Merge branch 'main' of github.com:elastic/kibana into core-feature-fl…
afharo Aug 5, 2024
acaf70b
Fix missing JSDocs
afharo Aug 5, 2024
7f41811
Throw if `setProvider` is called twice
afharo Aug 7, 2024
728861c
Merge branch 'main' of github.com:elastic/kibana into core-feature-fl…
afharo Aug 19, 2024
43f366d
Use constants in the example plugin
afharo Aug 19, 2024
25afa70
Use SDK key in the server side
afharo Aug 19, 2024
9c97aaa
Move chat flag evaluations to the route handler
afharo Aug 19, 2024
87179bb
Merge branch 'main' of github.com:elastic/kibana into core-feature-fl…
afharo Sep 17, 2024
5c8b3e0
[CI] Auto-commit changed files from 'node scripts/lint_packages --fix'
kibanamachine Sep 17, 2024
3f76163
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 17, 2024
8b495d7
Merge branch 'main' into core-feature-flags-service
afharo Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ packages/core/execution-context/core-execution-context-server-mocks @elastic/kib
packages/core/fatal-errors/core-fatal-errors-browser @elastic/kibana-core
packages/core/fatal-errors/core-fatal-errors-browser-internal @elastic/kibana-core
packages/core/fatal-errors/core-fatal-errors-browser-mocks @elastic/kibana-core
packages/core/feature-flags/core-feature-flags-browser @elastic/kibana-core
packages/core/feature-flags/core-feature-flags-browser-internal @elastic/kibana-core
packages/core/feature-flags/core-feature-flags-browser-mocks @elastic/kibana-core
packages/core/feature-flags/core-feature-flags-server @elastic/kibana-core
packages/core/feature-flags/core-feature-flags-server-internal @elastic/kibana-core
packages/core/feature-flags/core-feature-flags-server-mocks @elastic/kibana-core
test/plugin_functional/plugins/core_history_block @elastic/kibana-core
packages/core/http/core-http-browser @elastic/kibana-core
packages/core/http/core-http-browser-internal @elastic/kibana-core
Expand Down Expand Up @@ -446,6 +452,7 @@ examples/expressions_explorer @elastic/kibana-visualizations
src/plugins/expressions @elastic/kibana-visualizations
packages/kbn-failed-test-reporter-cli @elastic/kibana-operations @elastic/appex-qa
examples/feature_control_examples @elastic/kibana-security
examples/feature_flags_example @elastic/kibana-core
x-pack/test/plugin_api_integration/plugins/feature_usage_test @elastic/kibana-security
x-pack/plugins/features @elastic/kibana-core
x-pack/test/functional_execution_context/plugins/alerts @elastic/kibana-core
Expand Down
4 changes: 2 additions & 2 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ The plugin exposes the static DefaultEditorController class to consume.


|{kib-repo}blob/{branch}/x-pack/plugins/cloud_integrations/cloud_experiments/README.mdx[cloudExperiments]
|[!WARNING]
These APIs are deprecated and should not be used as we're working on a replacement Core Feature Flags Service that will arrive soon.
|[!NOTE]
This plugin no-longer exposes any evaluation APIs. Refer to <DocLink id="kibFeatureFlagsService" /> for more information about how to interact with feature flags.


|{kib-repo}blob/{branch}/x-pack/plugins/cloud_integrations/cloud_full_story/README.md[cloudFullStory]
Expand Down
5 changes: 5 additions & 0 deletions examples/feature_flags_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# featureFlagsExample

This plugin's goal is to demonstrate how to use the core feature flags service.

Refer to [the docs](../../packages/core/feature-flags/README.mdx) to know more.
11 changes: 11 additions & 0 deletions examples/feature_flags_example/common/feature_flags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const FeatureFlagExampleBoolean = 'example-boolean';
export const FeatureFlagExampleString = 'example-string';
export const FeatureFlagExampleNumber = 'example-number';
10 changes: 10 additions & 0 deletions examples/feature_flags_example/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const PLUGIN_ID = 'featureFlagsExample';
export const PLUGIN_NAME = 'Feature Flags Example';
13 changes: 13 additions & 0 deletions examples/feature_flags_example/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "plugin",
"id": "@kbn/feature-flags-example-plugin",
"owner": "@elastic/kibana-core",
"description": "Plugin that shows how to make use of the feature flags core service.",
"plugin": {
"id": "featureFlagsExample",
"server": true,
"browser": true,
"requiredPlugins": ["developerExamples"],
"optionalPlugins": []
}
}
32 changes: 32 additions & 0 deletions examples/feature_flags_example/public/application.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters, CoreStart } from '@kbn/core/public';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import { KibanaRootContextProvider } from '@kbn/react-kibana-context-root';
import { FeatureFlagsExampleApp } from './components/app';

export const renderApp = (coreStart: CoreStart, { element }: AppMountParameters) => {
const { notifications, http, featureFlags } = coreStart;
ReactDOM.render(
<KibanaRootContextProvider {...coreStart}>
<KibanaPageTemplate>
<FeatureFlagsExampleApp
featureFlags={featureFlags}
notifications={notifications}
http={http}
/>
</KibanaPageTemplate>
</KibanaRootContextProvider>,
element
);

return () => ReactDOM.unmountComponentAtNode(element);
};
90 changes: 90 additions & 0 deletions examples/feature_flags_example/public/components/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import {
EuiHorizontalRule,
EuiPageTemplate,
EuiTitle,
EuiText,
EuiLink,
EuiListGroup,
EuiListGroupItem,
} from '@elastic/eui';
import type { CoreStart, FeatureFlagsStart } from '@kbn/core/public';

import useObservable from 'react-use/lib/useObservable';
import {
FeatureFlagExampleBoolean,
FeatureFlagExampleNumber,
FeatureFlagExampleString,
} from '../../common/feature_flags';
import { PLUGIN_NAME } from '../../common';

interface FeatureFlagsExampleAppDeps {
featureFlags: FeatureFlagsStart;
notifications: CoreStart['notifications'];
http: CoreStart['http'];
}

export const FeatureFlagsExampleApp = ({ featureFlags }: FeatureFlagsExampleAppDeps) => {
// Fetching the feature flags synchronously
const bool = featureFlags.getBooleanValue(FeatureFlagExampleBoolean, false);
const str = featureFlags.getStringValue(FeatureFlagExampleString, 'red');
const num = featureFlags.getNumberValue(FeatureFlagExampleNumber, 1);

// Use React Hooks to observe feature flags changes
const bool$ = useObservable(featureFlags.getBooleanValue$(FeatureFlagExampleBoolean, false));
const str$ = useObservable(featureFlags.getStringValue$(FeatureFlagExampleString, 'red'));
const num$ = useObservable(featureFlags.getNumberValue$(FeatureFlagExampleNumber, 1));

return (
<>
<EuiPageTemplate>
<EuiPageTemplate.Header>
<EuiTitle size="l">
<h1>{PLUGIN_NAME}</h1>
</EuiTitle>
</EuiPageTemplate.Header>
<EuiPageTemplate.Section>
<EuiTitle>
<h2>Demo of the feature flags service</h2>
</EuiTitle>
<EuiText>
<p>
To learn more, refer to{' '}
<EuiLink
href={'https://docs.elastic.dev/kibana-dev-docs/tutorials/feature-flags-service'}
>
the docs
</EuiLink>
.
</p>
<EuiHorizontalRule />
<EuiListGroup>
<p>
The feature flags are:
<EuiListGroupItem label={`${FeatureFlagExampleBoolean}: ${bool}`} />
<EuiListGroupItem label={`${FeatureFlagExampleString}: ${str}`} />
<EuiListGroupItem label={`${FeatureFlagExampleNumber}: ${num}`} />
</p>
</EuiListGroup>
<EuiListGroup>
<p>
The <strong>observed</strong> feature flags are:
<EuiListGroupItem label={`${FeatureFlagExampleBoolean}: ${bool$}`} />
<EuiListGroupItem label={`${FeatureFlagExampleString}: ${str$}`} />
<EuiListGroupItem label={`${FeatureFlagExampleNumber}: ${num$}`} />
</p>
</EuiListGroup>
</EuiText>
</EuiPageTemplate.Section>
</EuiPageTemplate>
</>
);
};
13 changes: 13 additions & 0 deletions examples/feature_flags_example/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { FeatureFlagsExamplePlugin } from './plugin';

export function plugin() {
return new FeatureFlagsExamplePlugin();
}
39 changes: 39 additions & 0 deletions examples/feature_flags_example/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import { AppPluginSetupDependencies } from './types';
import { PLUGIN_NAME } from '../common';

export class FeatureFlagsExamplePlugin implements Plugin {
public setup(core: CoreSetup, deps: AppPluginSetupDependencies) {
// Register an application into the side navigation menu
core.application.register({
id: 'featureFlagsExample',
title: PLUGIN_NAME,
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in kibana.json
const [coreStart] = await core.getStartServices();
// Render the application
return renderApp(coreStart, params);
},
});

deps.developerExamples.register({
appId: 'featureFlagsExample',
title: PLUGIN_NAME,
description: 'Plugin that shows how to make use of the feature flags core service.',
});
}

public start(core: CoreStart) {}

public stop() {}
}
13 changes: 13 additions & 0 deletions examples/feature_flags_example/public/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import type { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';

export interface AppPluginSetupDependencies {
developerExamples: DeveloperExamplesSetup;
}
76 changes: 76 additions & 0 deletions examples/feature_flags_example/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import type { FeatureFlagDefinitions } from '@kbn/core-feature-flags-server';
import type { PluginInitializerContext } from '@kbn/core-plugins-server';
import {
FeatureFlagExampleBoolean,
FeatureFlagExampleNumber,
FeatureFlagExampleString,
} from '../common/feature_flags';

export const featureFlags: FeatureFlagDefinitions = [
{
key: FeatureFlagExampleBoolean,
name: 'Example boolean',
description: 'This is a demo of a boolean flag',
tags: ['example', 'my-plugin'],
variationType: 'boolean',
variations: [
{
name: 'On',
description: 'Auto-hides the bar',
value: true,
},
{
name: 'Off',
description: 'Static always-on',
value: false,
},
],
},
{
key: FeatureFlagExampleString,
name: 'Example string',
description: 'This is a demo of a string flag',
tags: ['example', 'my-plugin'],
variationType: 'string',
variations: [
{
name: 'Pink',
value: '#D75489',
},
{
name: 'Turquoise',
value: '#65BAAF',
},
],
},
{
key: FeatureFlagExampleNumber,
name: 'Example Number',
description: 'This is a demo of a number flag',
tags: ['example', 'my-plugin'],
variationType: 'number',
variations: [
{
name: 'Five',
value: 5,
},
{
name: 'Ten',
value: 10,
},
],
},
];

export async function plugin(initializerContext: PluginInitializerContext) {
const { FeatureFlagsExamplePlugin } = await import('./plugin');
return new FeatureFlagsExamplePlugin(initializerContext);
}
Loading