Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d8e7d54
support feature variant (#13)
Eskibear Aug 15, 2024
7e3a228
Merge branch 'main' of https://github.com/microsoft/FeatureManagement…
zhiyuanliang-ms Aug 15, 2024
fd588be
merge main & resolve conflict
zhiyuanliang-ms Sep 2, 2024
91b7a2d
Merge pull request #19 from microsoft/zhiyuanliang/merge-main-to-preview
zhiyuanliang-ms Sep 11, 2024
386ae79
remove config reference from variant feature flag (#35)
zhiyuanliang-ms Sep 11, 2024
525092d
adjust folder structure (#34)
zhiyuanliang-ms Sep 12, 2024
fe42395
Add basic telemetry support (#36)
zhiyuanliang-ms Sep 14, 2024
4b34f79
move readme and license (#37)
zhiyuanliang-ms Sep 14, 2024
619d2ea
use targeting id (#38)
zhiyuanliang-ms Sep 14, 2024
e546a47
Add @microsoft/feature-management-applicationinsights-browser package…
zhiyuanliang-ms Oct 11, 2024
01b2b31
version bump v2-preview1
zhiyuanliang-ms Oct 11, 2024
f58e22f
fix lint
zhiyuanliang-ms Oct 11, 2024
f663f88
fix lint
zhiyuanliang-ms Oct 11, 2024
f892ce3
merge main to preview
zhiyuanliang-ms Oct 15, 2024
977e24f
Merge pull request #52 from microsoft/zhiyuanliang/merge-main-to-preview
zhiyuanliang-ms Oct 15, 2024
eff58e6
merge preview
zhiyuanliang-ms Oct 15, 2024
2f20902
Merge pull request #49 from microsoft/zhiyuanliang/version-bump
zhiyuanliang-ms Oct 15, 2024
f47352b
Update package-lock.json (#53)
zhiyuanliang-ms Oct 15, 2024
443a658
update build script (#54)
zhiyuanliang-ms Oct 15, 2024
850418a
init
zhiyuanliang-ms Oct 18, 2024
1dca54f
fix lint
zhiyuanliang-ms Oct 18, 2024
c516a63
fix bug
zhiyuanliang-ms Oct 23, 2024
ee47659
update property name
zhiyuanliang-ms Oct 23, 2024
413d089
fix bug (#56)
zhiyuanliang-ms Oct 23, 2024
c73e6a6
merge preview
zhiyuanliang-ms Oct 23, 2024
ef1f2f1
update version (#57)
linglingye001 Oct 24, 2024
6d573be
update (#59)
zhiyuanliang-ms Oct 24, 2024
4197a30
update dependency version (#62)
zhiyuanliang-ms Oct 25, 2024
cde61c5
Merge branch 'main' of https://github.com/microsoft/FeatureManagement…
zhiyuanliang-ms Oct 28, 2024
824a1d7
Merge pull request #63 from microsoft/zhiyuanliang/merge-main-to-preview
zhiyuanliang-ms Oct 28, 2024
ccd93a9
update
zhiyuanliang-ms Oct 28, 2024
72461bf
Merge pull request #55 from microsoft/zhiyuanliang/exp-telemetry
zhiyuanliang-ms Nov 1, 2024
bb2bd7e
Merge branch 'main' of https://github.com/microsoft/FeatureManagement…
zhiyuanliang-ms Nov 6, 2024
2c53e2e
use string seed in sample feature flag
zhiyuanliang-ms Nov 6, 2024
6bd8759
Merge pull request #69 from microsoft/merge-main-to-preview
zhiyuanliang-ms Nov 6, 2024
a197093
Add node.js app insights package (#64)
zhiyuanliang-ms Nov 8, 2024
61e71d4
version bump 2.0.0-preview.3 (#70)
zhiyuanliang-ms Nov 8, 2024
7a4a6fa
update readme (#72)
zhiyuanliang-ms Nov 12, 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
46 changes: 41 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,51 @@ jobs:
matrix:
node-version: [18.x, 20.x]

defaults:
run:
working-directory: sdk/feature-management

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm run test
- run: npm run test-browser
cache-dependency-path: sdk/feature-management/package-lock.json

- name: Install dependencies
run: npm ci
working-directory: sdk/feature-management

- name: Run lint check for feature-management
run: npm run lint
working-directory: sdk/feature-management

- name: Build feature-management
run: npm run build
working-directory: sdk/feature-management

- name: Run tests
run: npm run test
working-directory: sdk/feature-management

- name: Run browser tests
run: npm run test-browser
working-directory: sdk/feature-management

- name: Build feature-management-applicationinsights-browser
run: npm run build
working-directory: sdk/feature-management-applicationinsights-browser

- name: Run lint check for feature-management-applicationinsights-browser
run: npm run lint
working-directory: sdk/feature-management-applicationinsights-browser

- name: Build feature-management-applicationinsights-node
run: npm run build
working-directory: sdk/feature-management-applicationinsights-node

- name: Run lint check for feature-management-applicationinsights-node
run: npm run lint
working-directory: sdk/feature-management-applicationinsights-node
54 changes: 43 additions & 11 deletions scripts/build-and-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,57 @@
# Stop on error.
set -e

# Get the directory of the script.
SCRIPT_DIR=$(dirname $(readlink -f $0))

# Get the directory of the project.
PROJECT_BASE_DIR=$(dirname $SCRIPT_DIR)
SDK_DIR="$PROJECT_BASE_DIR/sdk"

PACKAGE="feature-management"
PACKAGE_DIR="$SDK_DIR/$PACKAGE"

# Change to the project directory.
cd $PROJECT_BASE_DIR
echo "Building package $PACKAGE in $PACKAGE_DIR"
cd "$PACKAGE_DIR"

# Install dependencies, build, and test.
echo "npm clean install"
echo "npm clean install in $PACKAGE_DIR"
npm ci

echo "npm run build"
echo "npm run build in $PACKAGE_DIR"
npm run build

echo "npm run test"
echo "npm run test in $PACKAGE_DIR"
npm run test

# Create a tarball.
echo "npm pack"
echo "npm pack in $PACKAGE_DIR"
npm pack

echo "copy $PACKAGE package to $PROJECT_BASE_DIR"
cp "$PACKAGE_DIR"/*.tgz "$PROJECT_BASE_DIR"

PACKAGE="feature-management-applicationinsights-browser"
PACKAGE_DIR="$SDK_DIR/$PACKAGE"

echo "Building package $PACKAGE in $PACKAGE_DIR"
cd "$PACKAGE_DIR"

echo "npm run build in $PACKAGE_DIR"
npm run build

echo "npm pack in $PACKAGE_DIR"
npm pack

echo "copy $PACKAGE package to $PROJECT_BASE_DIR"
cp "$PACKAGE_DIR"/*.tgz "$PROJECT_BASE_DIR"

PACKAGE="feature-management-applicationinsights-node"
PACKAGE_DIR="$SDK_DIR/$PACKAGE"

echo "Building package $PACKAGE in $PACKAGE_DIR"
cd "$PACKAGE_DIR"

echo "npm run build in $PACKAGE_DIR"
npm run build

echo "npm pack in $PACKAGE_DIR"
npm pack

echo "copy $PACKAGE package to $PROJECT_BASE_DIR"
cp "$PACKAGE_DIR"/*.tgz "$PROJECT_BASE_DIR"
60 changes: 60 additions & 0 deletions sdk/feature-management-applicationinsights-browser/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"env": {
"browser": true,
"es2021": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"ignorePatterns": [
],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"quotes": [
"error",
"double",
{
"avoidEscape": true
}
],
"@typescript-eslint/no-explicit-any": "off",
"eol-last": [
"error",
"always"
],
"no-trailing-spaces": "error",
"space-before-blocks": [
"error",
"always"
],
"no-multi-spaces": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"semi": ["error", "always"]
}
}
21 changes: 21 additions & 0 deletions sdk/feature-management-applicationinsights-browser/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
50 changes: 50 additions & 0 deletions sdk/feature-management-applicationinsights-browser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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.

## Getting Started

### Usage

``` javascript
import { ApplicationInsights } from "@microsoft/applicationinsights-web"
import { FeatureManager, ConfigurationObjectFeatureFlagProvider } from "@microsoft/feature-management";
import { createTelemetryPublisher, trackEvent } from "@microsoft/feature-management-applicationinsights-browser";

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

const publishTelemetry = createTelemetryPublisher(appInsights);
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*/ });

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

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
48 changes: 48 additions & 0 deletions sdk/feature-management-applicationinsights-browser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@microsoft/feature-management-applicationinsights-browser",
"version": "2.0.0-preview.3",
"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/umd/index.js",
"module": "./dist/esm/index.js",
"types": "types/index.d.ts",
"files": [
"dist/",
"types/",
"LICENSE",
"README.md"
],
"scripts": {
"build": "npm run link && npm run clean && rollup --config",
"clean": "rimraf dist types",
"link": "npm link ../feature-management",
"dev": "rollup --config --watch",
"lint": "eslint src/",
"fix-lint": "eslint src/ --fix"
},
"repository": {
"type": "git",
"url": "git+https://github.com/microsoft/FeatureManagement-JavaScript.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/microsoft/FeatureManagement-JavaScript/issues"
},
"homepage": "https://github.com/microsoft/FeatureManagement-JavaScript#readme",
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.5",
"@types/node": "^20.10.7",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"eslint": "^8.56.0",
"rimraf": "^5.0.5",
"rollup": "^4.9.4",
"rollup-plugin-dts": "^6.1.0",
"tslib": "^2.6.2",
"typescript": "^5.3.3"
},
"dependencies": {
"@microsoft/applicationinsights-web": "^3.3.2",
"@microsoft/feature-management": "2.0.0-preview.3"
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// rollup.config.js
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";

export default [
{
input: "src/index.ts",
output: [
{
dir: "dist/esm/",
format: "esm",
sourcemap: true,
preserveModules: true,
},
{
file: "dist/umd/index.js",
format: "umd",
name: 'FeatureManagementApplicationInsights',
sourcemap: true
}
],
plugins: [
typescript({
compilerOptions: {
"lib": [
"DOM",
"WebWorker",
"ESNext"
],
"skipDefaultLibCheck": true,
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2022",
"strictNullChecks": true,
"strictFunctionTypes": true,
"sourceMap": true,
"inlineSources": true
}
})
],
},
{
input: "src/index.ts",
output: [{ file: "types/index.d.ts", format: "esm" }],
plugins: [dts()],
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export { createTelemetryPublisher, trackEvent } from "./telemetry.js";
export { VERSION } from "./version.js";
Loading
Loading