Skip to content

Commit 712387f

Browse files
Revert "remove exp telemetry & stable v2 (#76)"
This reverts commit add9e26.
1 parent 538e680 commit 712387f

File tree

8 files changed

+38
-11
lines changed

8 files changed

+38
-11
lines changed

sdk/feature-management-applicationinsights-browser/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/feature-management-applicationinsights-browser",
3-
"version": "2.0.0",
3+
"version": "2.0.0-preview.3",
44
"description": "Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.",
55
"main": "./dist/umd/index.js",
66
"module": "./dist/esm/index.js",
@@ -45,7 +45,7 @@
4545
},
4646
"dependencies": {
4747
"@microsoft/applicationinsights-web": "^3.3.2",
48-
"@microsoft/feature-management": "2.0.0"
48+
"@microsoft/feature-management": "2.0.0-preview.3"
4949
}
5050
}
5151

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export const VERSION = "2.0.0";
4+
export const VERSION = "2.0.0-preview.3";

sdk/feature-management-applicationinsights-node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/feature-management-applicationinsights-node",
3-
"version": "2.0.0",
3+
"version": "2.0.0-preview.3",
44
"description": "Feature Management Application Insights Plugin for Node.js provides a solution for sending feature flag evaluation events produced by the Feature Management library.",
55
"main": "./dist/commonjs/index.js",
66
"module": "./dist/esm/index.js",
@@ -45,7 +45,7 @@
4545
},
4646
"dependencies": {
4747
"applicationinsights": "^2.9.6",
48-
"@microsoft/feature-management": "2.0.0"
48+
"@microsoft/feature-management": "2.0.0-preview.3"
4949
}
5050
}
5151

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export const VERSION = "2.0.0";
4+
export const VERSION = "2.0.0-preview.3";

sdk/feature-management/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/feature-management/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/feature-management",
3-
"version": "2.0.0",
3+
"version": "2.0.0-preview.3",
44
"description": "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.",
55
"main": "./dist/commonjs/index.js",
66
"module": "./dist/esm/index.js",

sdk/feature-management/src/telemetry/featureEvaluationEvent.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
import { EvaluationResult } from "../featureManager";
4+
import { EvaluationResult, VariantAssignmentReason } from "../featureManager";
55
import { EVALUATION_EVENT_VERSION } from "../version.js";
66

77
const VERSION = "Version";
@@ -10,6 +10,8 @@ const ENABLED = "Enabled";
1010
const TARGETING_ID = "TargetingId";
1111
const VARIANT = "Variant";
1212
const VARIANT_ASSIGNMENT_REASON = "VariantAssignmentReason";
13+
const DEFAULT_WHEN_ENABLED = "DefaultWhenEnabled";
14+
const VARIANT_ASSIGNMENT_PERCENTAGE = "VariantAssignmentPercentage";
1315

1416
export function createFeatureEvaluationEventProperties(result: EvaluationResult): any {
1517
if (result.feature === undefined) {
@@ -26,6 +28,31 @@ export function createFeatureEvaluationEventProperties(result: EvaluationResult)
2628
[VARIANT_ASSIGNMENT_REASON]: result.variantAssignmentReason,
2729
};
2830

31+
if (result.feature.allocation?.default_when_enabled) {
32+
eventProperties[DEFAULT_WHEN_ENABLED] = result.feature.allocation.default_when_enabled;
33+
}
34+
35+
if (result.variantAssignmentReason === VariantAssignmentReason.DefaultWhenEnabled) {
36+
let percentileAllocationPercentage = 0;
37+
if (result.variant !== undefined && result.feature.allocation !== undefined && result.feature.allocation.percentile !== undefined) {
38+
for (const percentile of result.feature.allocation.percentile) {
39+
percentileAllocationPercentage += percentile.to - percentile.from;
40+
}
41+
}
42+
eventProperties[VARIANT_ASSIGNMENT_PERCENTAGE] = (100 - percentileAllocationPercentage).toString();
43+
}
44+
else if (result.variantAssignmentReason === VariantAssignmentReason.Percentile) {
45+
let percentileAllocationPercentage = 0;
46+
if (result.variant !== undefined && result.feature.allocation !== undefined && result.feature.allocation.percentile !== undefined) {
47+
for (const percentile of result.feature.allocation.percentile) {
48+
if (percentile.variant === result.variant.name) {
49+
percentileAllocationPercentage += percentile.to - percentile.from;
50+
}
51+
}
52+
}
53+
eventProperties[VARIANT_ASSIGNMENT_PERCENTAGE] = percentileAllocationPercentage.toString();
54+
}
55+
2956
const metadata = result.feature.telemetry?.metadata;
3057
if (metadata) {
3158
for (const key in metadata) {

sdk/feature-management/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export const VERSION = "2.0.0";
4+
export const VERSION = "2.0.0-preview.3";
55
export const EVALUATION_EVENT_VERSION = "1.0.0";

0 commit comments

Comments
 (0)