diff --git a/sdk/feature-management-applicationinsights-browser/package.json b/sdk/feature-management-applicationinsights-browser/package.json index 3f3cf6d..8970137 100644 --- a/sdk/feature-management-applicationinsights-browser/package.json +++ b/sdk/feature-management-applicationinsights-browser/package.json @@ -1,6 +1,6 @@ { "name": "@microsoft/feature-management-applicationinsights-browser", - "version": "2.0.0", + "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", @@ -24,9 +24,6 @@ "url": "git+https://github.com/microsoft/FeatureManagement-JavaScript.git" }, "license": "MIT", - "publishConfig": { - "tag": "stable" - }, "bugs": { "url": "https://github.com/microsoft/FeatureManagement-JavaScript/issues" }, @@ -45,7 +42,7 @@ }, "dependencies": { "@microsoft/applicationinsights-web": "^3.3.2", - "@microsoft/feature-management": "2.0.0" + "@microsoft/feature-management": "2.0.0-preview.3" } } \ No newline at end of file diff --git a/sdk/feature-management-applicationinsights-browser/src/version.ts b/sdk/feature-management-applicationinsights-browser/src/version.ts index b4709c9..074200b 100644 --- a/sdk/feature-management-applicationinsights-browser/src/version.ts +++ b/sdk/feature-management-applicationinsights-browser/src/version.ts @@ -1,4 +1,4 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -export const VERSION = "2.0.0"; +export const VERSION = "2.0.0-preview.3"; diff --git a/sdk/feature-management-applicationinsights-node/package.json b/sdk/feature-management-applicationinsights-node/package.json index 7d6a1e6..975199a 100644 --- a/sdk/feature-management-applicationinsights-node/package.json +++ b/sdk/feature-management-applicationinsights-node/package.json @@ -1,6 +1,6 @@ { "name": "@microsoft/feature-management-applicationinsights-node", - "version": "2.0.0", + "version": "2.0.0-preview.3", "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", @@ -24,9 +24,6 @@ "url": "git+https://github.com/microsoft/FeatureManagement-JavaScript.git" }, "license": "MIT", - "publishConfig": { - "tag": "stable" - }, "bugs": { "url": "https://github.com/microsoft/FeatureManagement-JavaScript/issues" }, @@ -45,7 +42,7 @@ }, "dependencies": { "applicationinsights": "^2.9.6", - "@microsoft/feature-management": "2.0.0" + "@microsoft/feature-management": "2.0.0-preview.3" } } \ No newline at end of file diff --git a/sdk/feature-management-applicationinsights-node/src/version.ts b/sdk/feature-management-applicationinsights-node/src/version.ts index b4709c9..074200b 100644 --- a/sdk/feature-management-applicationinsights-node/src/version.ts +++ b/sdk/feature-management-applicationinsights-node/src/version.ts @@ -1,4 +1,4 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -export const VERSION = "2.0.0"; +export const VERSION = "2.0.0-preview.3"; diff --git a/sdk/feature-management/package-lock.json b/sdk/feature-management/package-lock.json index a69abd1..12faae2 100644 --- a/sdk/feature-management/package-lock.json +++ b/sdk/feature-management/package-lock.json @@ -1,6 +1,6 @@ { "name": "@microsoft/feature-management", - "version": "2.0.0", + "version": "2.0.0-preview.3", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/sdk/feature-management/package.json b/sdk/feature-management/package.json index 78a4a0f..3e77c26 100644 --- a/sdk/feature-management/package.json +++ b/sdk/feature-management/package.json @@ -1,6 +1,6 @@ { "name": "@microsoft/feature-management", - "version": "2.0.0", + "version": "2.0.0-preview.3", "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.", "main": "./dist/commonjs/index.js", "module": "./dist/esm/index.js", @@ -26,9 +26,6 @@ "url": "git+https://github.com/microsoft/FeatureManagement-JavaScript.git" }, "license": "MIT", - "publishConfig": { - "tag": "stable" - }, "bugs": { "url": "https://github.com/microsoft/FeatureManagement-JavaScript/issues" }, diff --git a/sdk/feature-management/src/telemetry/featureEvaluationEvent.ts b/sdk/feature-management/src/telemetry/featureEvaluationEvent.ts index b76f46b..2c195c6 100644 --- a/sdk/feature-management/src/telemetry/featureEvaluationEvent.ts +++ b/sdk/feature-management/src/telemetry/featureEvaluationEvent.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { EvaluationResult } from "../featureManager"; +import { EvaluationResult, VariantAssignmentReason } from "../featureManager"; import { EVALUATION_EVENT_VERSION } from "../version.js"; const VERSION = "Version"; @@ -10,6 +10,8 @@ const ENABLED = "Enabled"; const TARGETING_ID = "TargetingId"; const VARIANT = "Variant"; const VARIANT_ASSIGNMENT_REASON = "VariantAssignmentReason"; +const DEFAULT_WHEN_ENABLED = "DefaultWhenEnabled"; +const VARIANT_ASSIGNMENT_PERCENTAGE = "VariantAssignmentPercentage"; export function createFeatureEvaluationEventProperties(result: EvaluationResult): any { if (result.feature === undefined) { @@ -26,6 +28,31 @@ export function createFeatureEvaluationEventProperties(result: EvaluationResult) [VARIANT_ASSIGNMENT_REASON]: result.variantAssignmentReason, }; + if (result.feature.allocation?.default_when_enabled) { + eventProperties[DEFAULT_WHEN_ENABLED] = result.feature.allocation.default_when_enabled; + } + + if (result.variantAssignmentReason === VariantAssignmentReason.DefaultWhenEnabled) { + let percentileAllocationPercentage = 0; + if (result.variant !== undefined && result.feature.allocation !== undefined && result.feature.allocation.percentile !== undefined) { + for (const percentile of result.feature.allocation.percentile) { + percentileAllocationPercentage += percentile.to - percentile.from; + } + } + eventProperties[VARIANT_ASSIGNMENT_PERCENTAGE] = (100 - percentileAllocationPercentage).toString(); + } + else if (result.variantAssignmentReason === VariantAssignmentReason.Percentile) { + let percentileAllocationPercentage = 0; + if (result.variant !== undefined && result.feature.allocation !== undefined && result.feature.allocation.percentile !== undefined) { + for (const percentile of result.feature.allocation.percentile) { + if (percentile.variant === result.variant.name) { + percentileAllocationPercentage += percentile.to - percentile.from; + } + } + } + eventProperties[VARIANT_ASSIGNMENT_PERCENTAGE] = percentileAllocationPercentage.toString(); + } + const metadata = result.feature.telemetry?.metadata; if (metadata) { for (const key in metadata) { diff --git a/sdk/feature-management/src/version.ts b/sdk/feature-management/src/version.ts index aaae469..65fbbf3 100644 --- a/sdk/feature-management/src/version.ts +++ b/sdk/feature-management/src/version.ts @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -export const VERSION = "2.0.0"; +export const VERSION = "2.0.0-preview.3"; export const EVALUATION_EVENT_VERSION = "1.0.0";