Skip to content

Commit 1c3733e

Browse files
merge main
2 parents 28d27ce + 4ffb19b commit 1c3733e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3082
-989
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,51 @@ jobs:
2020
matrix:
2121
node-version: [18.x, 20.x]
2222

23+
defaults:
24+
run:
25+
working-directory: sdk/feature-management
26+
2327
steps:
2428
- uses: actions/checkout@v3
2529
- name: Use Node.js ${{ matrix.node-version }}
2630
uses: actions/setup-node@v3
2731
with:
2832
node-version: ${{ matrix.node-version }}
2933
cache: 'npm'
30-
- run: npm ci
31-
- run: npm run lint
32-
- run: npm run build
33-
- run: npm run test
34-
- run: npm run test-browser
34+
cache-dependency-path: sdk/feature-management/package-lock.json
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
working-directory: sdk/feature-management
39+
40+
- name: Run lint check for feature-management
41+
run: npm run lint
42+
working-directory: sdk/feature-management
43+
44+
- name: Build feature-management
45+
run: npm run build
46+
working-directory: sdk/feature-management
47+
48+
- name: Run tests
49+
run: npm run test
50+
working-directory: sdk/feature-management
51+
52+
- name: Run browser tests
53+
run: npm run test-browser
54+
working-directory: sdk/feature-management
55+
56+
- name: Build feature-management-applicationinsights-browser
57+
run: npm run build
58+
working-directory: sdk/feature-management-applicationinsights-browser
59+
60+
- name: Run lint check for feature-management-applicationinsights-browser
61+
run: npm run lint
62+
working-directory: sdk/feature-management-applicationinsights-browser
63+
64+
- name: Build feature-management-applicationinsights-node
65+
run: npm run build
66+
working-directory: sdk/feature-management-applicationinsights-node
67+
68+
- name: Run lint check for feature-management-applicationinsights-node
69+
run: npm run lint
70+
working-directory: sdk/feature-management-applicationinsights-node

scripts/build-and-pack.sh

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,57 @@
33
# Stop on error.
44
set -e
55

6-
# Get the directory of the script.
76
SCRIPT_DIR=$(dirname $(readlink -f $0))
8-
9-
# Get the directory of the project.
107
PROJECT_BASE_DIR=$(dirname $SCRIPT_DIR)
8+
SDK_DIR="$PROJECT_BASE_DIR/sdk"
9+
10+
PACKAGE="feature-management"
11+
PACKAGE_DIR="$SDK_DIR/$PACKAGE"
1112

12-
# Change to the project directory.
13-
cd $PROJECT_BASE_DIR
13+
echo "Building package $PACKAGE in $PACKAGE_DIR"
14+
cd "$PACKAGE_DIR"
1415

15-
# Install dependencies, build, and test.
16-
echo "npm clean install"
16+
echo "npm clean install in $PACKAGE_DIR"
1717
npm ci
1818

19-
echo "npm run build"
19+
echo "npm run build in $PACKAGE_DIR"
2020
npm run build
2121

22-
echo "npm run test"
22+
echo "npm run test in $PACKAGE_DIR"
2323
npm run test
2424

25-
# Create a tarball.
26-
echo "npm pack"
25+
echo "npm pack in $PACKAGE_DIR"
26+
npm pack
27+
28+
echo "copy $PACKAGE package to $PROJECT_BASE_DIR"
29+
cp "$PACKAGE_DIR"/*.tgz "$PROJECT_BASE_DIR"
30+
31+
PACKAGE="feature-management-applicationinsights-browser"
32+
PACKAGE_DIR="$SDK_DIR/$PACKAGE"
33+
34+
echo "Building package $PACKAGE in $PACKAGE_DIR"
35+
cd "$PACKAGE_DIR"
36+
37+
echo "npm run build in $PACKAGE_DIR"
38+
npm run build
39+
40+
echo "npm pack in $PACKAGE_DIR"
2741
npm pack
42+
43+
echo "copy $PACKAGE package to $PROJECT_BASE_DIR"
44+
cp "$PACKAGE_DIR"/*.tgz "$PROJECT_BASE_DIR"
45+
46+
PACKAGE="feature-management-applicationinsights-node"
47+
PACKAGE_DIR="$SDK_DIR/$PACKAGE"
48+
49+
echo "Building package $PACKAGE in $PACKAGE_DIR"
50+
cd "$PACKAGE_DIR"
51+
52+
echo "npm run build in $PACKAGE_DIR"
53+
npm run build
54+
55+
echo "npm pack in $PACKAGE_DIR"
56+
npm pack
57+
58+
echo "copy $PACKAGE package to $PROJECT_BASE_DIR"
59+
cp "$PACKAGE_DIR"/*.tgz "$PROJECT_BASE_DIR"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"mocha": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"ignorePatterns": [
12+
],
13+
"overrides": [
14+
{
15+
"env": {
16+
"node": true
17+
},
18+
"files": [
19+
".eslintrc.{js,cjs}"
20+
],
21+
"parserOptions": {
22+
"sourceType": "script"
23+
}
24+
}
25+
],
26+
"parser": "@typescript-eslint/parser",
27+
"parserOptions": {
28+
"ecmaVersion": "latest"
29+
},
30+
"plugins": [
31+
"@typescript-eslint"
32+
],
33+
"rules": {
34+
"quotes": [
35+
"error",
36+
"double",
37+
{
38+
"avoidEscape": true
39+
}
40+
],
41+
"@typescript-eslint/no-explicit-any": "off",
42+
"eol-last": [
43+
"error",
44+
"always"
45+
],
46+
"no-trailing-spaces": "error",
47+
"space-before-blocks": [
48+
"error",
49+
"always"
50+
],
51+
"no-multi-spaces": "error",
52+
"no-multiple-empty-lines": [
53+
"error",
54+
{
55+
"max": 1
56+
}
57+
],
58+
"semi": ["error", "always"]
59+
}
60+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Microsoft Feature Management Application Insights Plugin for Browser
2+
3+
Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.
4+
5+
## Getting Started
6+
7+
### Usage
8+
9+
``` javascript
10+
import { ApplicationInsights } from "@microsoft/applicationinsights-web"
11+
import { FeatureManager, ConfigurationObjectFeatureFlagProvider } from "@microsoft/feature-management";
12+
import { createTelemetryPublisher, trackEvent } from "@microsoft/feature-management-applicationinsights-browser";
13+
14+
const appInsights = new ApplicationInsights({ config: {
15+
connectionString: CONNECTION_STRING
16+
}});
17+
appInsights.loadAppInsights();
18+
19+
const publishTelemetry = createTelemetryPublisher(appInsights);
20+
const provider = new ConfigurationObjectFeatureFlagProvider(jsonObject);
21+
const featureManager = new FeatureManager(provider, {onFeatureEvaluated: publishTelemetry});
22+
23+
// FeatureEvaluation event will be emitted when a feature flag is evaluated
24+
featureManager.getVariant("TestFeature", {userId : TARGETING_ID}).then((variant) => { /* do something*/ });
25+
26+
// Emit a custom event with targeting id attached.
27+
trackEvent(appInsights, TARGETING_ID, {name: "TestEvent"}, {"Tag": "Some Value"});
28+
```
29+
30+
## Contributing
31+
32+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
33+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
34+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
35+
36+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
37+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
38+
provided by the bot. You will only need to do this once across all repos using our CLA.
39+
40+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
41+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
42+
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
43+
44+
## Trademarks
45+
46+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
47+
trademarks or logos is subject to and must follow
48+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
49+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
50+
Any use of third-party trademarks or logos are subject to those third-party's policies.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "@microsoft/feature-management-applicationinsights-browser",
3+
"version": "2.0.0-preview.3",
4+
"description": "Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.",
5+
"main": "./dist/umd/index.js",
6+
"module": "./dist/esm/index.js",
7+
"types": "types/index.d.ts",
8+
"files": [
9+
"dist/",
10+
"types/",
11+
"LICENSE",
12+
"README.md"
13+
],
14+
"scripts": {
15+
"build": "npm run link && npm run clean && rollup --config",
16+
"clean": "rimraf dist types",
17+
"link": "npm link ../feature-management",
18+
"dev": "rollup --config --watch",
19+
"lint": "eslint src/",
20+
"fix-lint": "eslint src/ --fix"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/microsoft/FeatureManagement-JavaScript.git"
25+
},
26+
"license": "MIT",
27+
"bugs": {
28+
"url": "https://github.com/microsoft/FeatureManagement-JavaScript/issues"
29+
},
30+
"homepage": "https://github.com/microsoft/FeatureManagement-JavaScript#readme",
31+
"devDependencies": {
32+
"@rollup/plugin-typescript": "^11.1.5",
33+
"@types/node": "^20.10.7",
34+
"@typescript-eslint/eslint-plugin": "^6.18.1",
35+
"@typescript-eslint/parser": "^6.18.1",
36+
"eslint": "^8.56.0",
37+
"rimraf": "^5.0.5",
38+
"rollup": "^4.9.4",
39+
"rollup-plugin-dts": "^6.1.0",
40+
"tslib": "^2.6.2",
41+
"typescript": "^5.3.3"
42+
},
43+
"dependencies": {
44+
"@microsoft/applicationinsights-web": "^3.3.2",
45+
"@microsoft/feature-management": "2.0.0-preview.3"
46+
}
47+
}
48+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// rollup.config.js
2+
import typescript from "@rollup/plugin-typescript";
3+
import dts from "rollup-plugin-dts";
4+
5+
export default [
6+
{
7+
input: "src/index.ts",
8+
output: [
9+
{
10+
dir: "dist/esm/",
11+
format: "esm",
12+
sourcemap: true,
13+
preserveModules: true,
14+
},
15+
{
16+
file: "dist/umd/index.js",
17+
format: "umd",
18+
name: 'FeatureManagementApplicationInsights',
19+
sourcemap: true
20+
}
21+
],
22+
plugins: [
23+
typescript({
24+
compilerOptions: {
25+
"lib": [
26+
"DOM",
27+
"WebWorker",
28+
"ESNext"
29+
],
30+
"skipDefaultLibCheck": true,
31+
"module": "ESNext",
32+
"moduleResolution": "Node",
33+
"target": "ES2022",
34+
"strictNullChecks": true,
35+
"strictFunctionTypes": true,
36+
"sourceMap": true,
37+
"inlineSources": true
38+
}
39+
})
40+
],
41+
},
42+
{
43+
input: "src/index.ts",
44+
output: [{ file: "types/index.d.ts", format: "esm" }],
45+
plugins: [dts()],
46+
},
47+
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
export { createTelemetryPublisher, trackEvent } from "./telemetry.js";
5+
export { VERSION } from "./version.js";

0 commit comments

Comments
 (0)