Skip to content

Merge main to release/v2 #100

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

Merged
merged 7 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

[![feature-management](https://img.shields.io/npm/v/@microsoft/feature-management?label=@microsoft/feature-management)](https://www.npmjs.com/package/@microsoft/feature-management)

Feature Management is a library for enabling/disabling features at runtime.
Developers can use feature flags in simple use cases like conditional statement to more advanced scenarios like conditionally adding routes.
Feature management provides a way to develop and expose application functionality based on features. Many applications have special requirements when a new feature is developed such as when the feature should be enabled and under what conditions. This library provides a way to define these relationships, and also integrates into common .NET code patterns to make exposing these features possible.

## Getting Started

### Prerequisites
[Azure App Configuration Quickstart](https://learn.microsoft.com/azure/azure-app-configuration/quickstart-feature-flag-javascript): A quickstart guide about how to integrate feature flags from Azure App Configuration into your JavaScript applications.

- Node.js LTS version
[Feature Overview](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-overview#feature-development-status): This document provides a feature status overview.

[Feature Reference](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-javascript-reference): This document provides a full feature rundown.

### Usage

You can use feature flags from the Azure App Configuration service, local files or any other sources.
You can use feature flags from the Azure App Configuration service, local files or any other sources. For more information, please go to [Feature flag configuration](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-javascript-reference#feature-flag-configuration).

#### Use feature flags from Azure App Configuration

The App Configuration JavaScript provider provides feature flags in as a `Map` object.
A builtin `ConfigurationMapFeatureFlagProvider` helps to load feature flags in this case.

```js
const appConfig = await load(connectionString, {featureFlagOptions}); // load feature flags from Azure App Configuration service
import { load } from "@azure/app-configuration-provider";
import { FeatureManager, ConfigurationMapFeatureFlagProvider } from "@microsoft/feature-management";
const appConfig = await load("<CONNECTION-STRING>", {featureFlagOptions}); // load feature flags from Azure App Configuration service
const featureProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
const featureManager = new FeatureManager(featureProvider);
const isAlphaEnabled = await featureManager.isEnabled("Alpha");
Expand Down Expand Up @@ -54,13 +57,18 @@ Content of `sample.json`:

Load feature flags from `sample.json` file.
```js
import { FeatureManager, ConfigurationObjectFeatureFlagProvider } from "@microsoft/feature-management";
const config = JSON.parse(await fs.readFile("path/to/sample.json"));
const featureProvider = new ConfigurationObjectFeatureFlagProvider(config);
const featureManager = new FeatureManager(featureProvider);
const isAlphaEnabled = await featureManager.isEnabled("Alpha");
console.log("Feature Alpha is:", isAlphaEnabled);
```

## Examples

See code snippets under [examples/](./examples/) folder.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand Down
6 changes: 4 additions & 2 deletions src/feature-management-applicationinsights-browser/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Microsoft Feature Management Application Insights Plugin for Browser

Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.
Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation telemetry produced by the [`@microsoft/feature-management`](https://www.npmjs.com/package/@microsoft/feature-management) library.

## Getting Started

For more information, please go to [Feature reference](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-javascript-reference#application-insights-integration).

### Usage

``` javascript
Expand All @@ -12,7 +14,7 @@ import { FeatureManager, ConfigurationObjectFeatureFlagProvider } from "@microso
import { createTelemetryPublisher, trackEvent } from "@microsoft/feature-management-applicationinsights-browser";

const appInsights = new ApplicationInsights({ config: {
connectionString: CONNECTION_STRING
connectionString: "<APPINSIGHTS_CONNECTION_STRING>"
}});
appInsights.loadAppInsights();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/feature-management-applicationinsights-browser",
"version": "2.0.0",
"version": "2.0.1",
"description": "Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.",
"main": "./dist/esm/index.js",
"module": "./dist/esm/index.js",
Expand Down Expand Up @@ -46,7 +46,7 @@
},
"dependencies": {
"@microsoft/applicationinsights-web": "^3.3.2",
"@microsoft/feature-management": "2.0.0"
"@microsoft/feature-management": "2.0.1"
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const VERSION = "2.0.0";
export const VERSION = "2.0.1";
20 changes: 11 additions & 9 deletions src/feature-management-applicationinsights-node/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
# Microsoft Feature Management Application Insights Plugin for Browser
# Microsoft Feature Management Application Insights Plugin for Node

Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.
Feature Management Application Insights Plugin for Node provides a solution for sending feature flag evaluation telemetry produced by the [`@microsoft/feature-management`](https://www.npmjs.com/package/@microsoft/feature-management) library.

## Getting Started

For more information, please go to [Feature reference](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-javascript-reference#application-insights-integration).

### Prerequisites

- Node.js LTS version
- `applicationinsights` SDK 2.x (classic)

### Usage

``` javascript
import appInsights from "applicationinsights";
import { FeatureManager, ConfigurationObjectFeatureFlagProvider } from "@microsoft/feature-management";
import { createTelemetryPublisher, trackEvent } from "@microsoft/feature-management-applicationinsights-node";
const appInsights = require("applicationinsights");
appInsights.setup(process.env.APPINSIGHTS_CONNECTION_STRING).start();

appInsights.setup(CONNECTION_STRING)
.start();
const { FeatureManager, ConfigurationObjectFeatureFlagProvider } = require("@microsoft/feature-management");
const { createTelemetryPublisher, trackEvent } = require("@microsoft/feature-management-applicationinsights-node");

const publishTelemetry = createTelemetryPublisher(appInsights.defaultClient);
const provider = new ConfigurationObjectFeatureFlagProvider(jsonObject);
const featureManager = new FeatureManager(provider, {onFeatureEvaluated: publishTelemetry});

// FeatureEvaluation event will be emitted when a feature flag is evaluated
featureManager.getVariant("TestFeature", {userId : TARGETING_ID}).then((variant) => { /* do something*/ });
featureManager.getVariant("TestFeature", {userId : "<TARGETING_ID>"}).then((variant) => { /* do something*/ });

// Emit a custom event with targeting id attached.
trackEvent(appInsights.defaultClient, TARGETING_ID, {name: "TestEvent"});
trackEvent(appInsights.defaultClient, "<TARGETING_ID>", {name: "TestEvent", properties: {"Tag": "Some Value"}});
```

## Contributing
Expand Down
4 changes: 2 additions & 2 deletions src/feature-management-applicationinsights-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/feature-management-applicationinsights-node",
"version": "2.0.0",
"version": "2.0.1",
"description": "Feature Management Application Insights Plugin for Node.js provides a solution for sending feature flag evaluation events produced by the Feature Management library.",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
Expand Down Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"applicationinsights": "^2.9.6",
"@microsoft/feature-management": "2.0.0"
"@microsoft/feature-management": "2.0.1"
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const VERSION = "2.0.0";
export const VERSION = "2.0.1";
22 changes: 15 additions & 7 deletions src/feature-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

[![feature-management](https://img.shields.io/npm/v/@microsoft/feature-management?label=@microsoft/feature-management)](https://www.npmjs.com/package/@microsoft/feature-management)

Feature Management is a library for enabling/disabling features at runtime.
Developers can use feature flags in simple use cases like conditional statement to more advanced scenarios like conditionally adding routes.
Feature management provides a way to develop and expose application functionality based on features. Many applications have special requirements when a new feature is developed such as when the feature should be enabled and under what conditions. This library provides a way to define these relationships, and also integrates into common .NET code patterns to make exposing these features possible.

## Getting Started

### Prerequisites
[Azure App Configuration Quickstart](https://learn.microsoft.com/azure/azure-app-configuration/quickstart-feature-flag-javascript): A quickstart guide about how to integrate feature flags from Azure App Configuration into your JavaScript applications.

- Node.js LTS version
[Feature Overview](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-overview#feature-development-status): This document provides a feature status overview.

[Feature Reference](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-javascript-reference): This document provides a full feature rundown.

### Usage

You can use feature flags from the Azure App Configuration service, local files or any other sources.
You can use feature flags from the Azure App Configuration service, local files or any other sources. For more information, please go to [Feature flag configuration](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-javascript-reference#feature-flag-configuration).

#### Use feature flags from Azure App Configuration

The App Configuration JavaScript provider provides feature flags in as a `Map` object.
A builtin `ConfigurationMapFeatureFlagProvider` helps to load feature flags in this case.

```js
const appConfig = load(connectionString, {featureFlagOptions}); // load feature flags from Azure App Configuration service
import { load } from "@azure/app-configuration-provider";
import { FeatureManager, ConfigurationMapFeatureFlagProvider } from "@microsoft/feature-management";
const appConfig = await load("<CONNECTION-STRING>", {featureFlagOptions}); // load feature flags from Azure App Configuration service
const featureProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
const featureManager = new FeatureManager(featureProvider);
const isAlphaEnabled = await featureManager.isEnabled("Alpha");
Expand All @@ -42,7 +45,7 @@ Content of `sample.json`:
{
"id": "Alpha",
"description": "",
"enabled": "true",
"enabled": true,
"conditions": {
"client_filters": []
}
Expand All @@ -54,13 +57,18 @@ Content of `sample.json`:

Load feature flags from `sample.json` file.
```js
import { FeatureManager, ConfigurationObjectFeatureFlagProvider } from "@microsoft/feature-management";
const config = JSON.parse(await fs.readFile("path/to/sample.json"));
const featureProvider = new ConfigurationObjectFeatureFlagProvider(config);
const featureManager = new FeatureManager(featureProvider);
const isAlphaEnabled = await featureManager.isEnabled("Alpha");
console.log("Feature Alpha is:", isAlphaEnabled);
```

## Examples

See code snippets under [examples/](./examples/) folder.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand Down
Loading