Skip to content

Commit ccd93a9

Browse files
update
2 parents c73e6a6 + 824a1d7 commit ccd93a9

File tree

8 files changed

+29
-19
lines changed

8 files changed

+29
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: FeatureManagement-JavaScriptProvider CI
1+
name: FeatureManagement-JavaScript CI
22

33
on:
44
push:

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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-preview.1",
3+
"version": "2.0.0-preview.2",
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",
@@ -42,7 +42,7 @@
4242
},
4343
"dependencies": {
4444
"@microsoft/applicationinsights-web": "^3.3.2",
45-
"@microsoft/feature-management": "1.0.0-preview.1"
45+
"@microsoft/feature-management": "2.0.0-preview.2"
4646
}
4747
}
4848

sdk/feature-management-applicationinsights-browser/src/telemetry.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import { EvaluationResult, VariantAssignmentReason } from "@microsoft/feature-ma
55
import { ApplicationInsights, IEventTelemetry } from "@microsoft/applicationinsights-web";
66
import { EVALUATION_EVENT_VERSION } from "./version.js";
77

8+
const VERSION = "Version";
9+
const FEATURE_NAME = "FeatureName";
10+
const ENABLED = "Enabled";
11+
const TARGETING_ID = "TargetingId";
12+
const VARIANT = "Variant";
13+
const VARIANT_ASSIGNMENT_REASON = "VariantAssignmentReason";
14+
const DEFAULT_WHEN_ENABLED = "DefaultWhenEnabled";
15+
const VARIANT_ASSIGNMENT_PERCENTAGE = "VariantAssignmentPercentage";
16+
const FEATURE_EVALUATION_EVENT_NAME = "FeatureEvaluation";
17+
818
/**
919
* Creates a telemetry publisher that sends feature evaluation events to Application Insights.
1020
* @param client The Application Insights telemetry client.
@@ -17,17 +27,17 @@ export function createTelemetryPublisher(client: ApplicationInsights): (event: E
1727
}
1828

1929
const eventProperties = {
20-
"Version": EVALUATION_EVENT_VERSION,
21-
"FeatureName": event.feature ? event.feature.id : "",
22-
"Enabled": event.enabled.toString(),
30+
[VERSION]: EVALUATION_EVENT_VERSION,
31+
[FEATURE_NAME]: event.feature ? event.feature.id : "",
32+
[ENABLED]: event.enabled.toString(),
2333
// Ensure targetingId is string so that it will be placed in customDimensions
24-
"TargetingId": event.targetingId ? event.targetingId.toString() : "",
25-
"Variant": event.variant ? event.variant.name : "",
26-
"VariantAssignmentReason": event.variantAssignmentReason,
34+
[TARGETING_ID]: event.targetingId ? event.targetingId.toString() : "",
35+
[VARIANT]: event.variant ? event.variant.name : "",
36+
[VARIANT_ASSIGNMENT_REASON]: event.variantAssignmentReason,
2737
};
2838

2939
if (event.feature.allocation?.default_when_enabled) {
30-
eventProperties["DefaultWhenEnabled"] = event.feature.allocation.default_when_enabled;
40+
eventProperties[DEFAULT_WHEN_ENABLED] = event.feature.allocation.default_when_enabled;
3141
}
3242

3343
if (event.variantAssignmentReason === VariantAssignmentReason.DefaultWhenEnabled) {
@@ -37,7 +47,7 @@ export function createTelemetryPublisher(client: ApplicationInsights): (event: E
3747
percentileAllocationPercentage += percentile.to - percentile.from;
3848
}
3949
}
40-
eventProperties["VariantAssignmentPercentage"] = (100 - percentileAllocationPercentage).toString();
50+
eventProperties[VARIANT_ASSIGNMENT_PERCENTAGE] = (100 - percentileAllocationPercentage).toString();
4151
}
4252
else if (event.variantAssignmentReason === VariantAssignmentReason.Percentile) {
4353
let percentileAllocationPercentage = 0;
@@ -48,7 +58,7 @@ export function createTelemetryPublisher(client: ApplicationInsights): (event: E
4858
}
4959
}
5060
}
51-
eventProperties["VariantAssignmentPercentage"] = percentileAllocationPercentage.toString();
61+
eventProperties[VARIANT_ASSIGNMENT_PERCENTAGE] = percentileAllocationPercentage.toString();
5262
}
5363

5464
const metadata = event.feature.telemetry?.metadata;
@@ -60,7 +70,7 @@ export function createTelemetryPublisher(client: ApplicationInsights): (event: E
6070
}
6171
}
6272

63-
client.trackEvent({ name: "FeatureEvaluation" }, eventProperties);
73+
client.trackEvent({ name: FEATURE_EVALUATION_EVENT_NAME }, eventProperties);
6474
};
6575
}
6676

@@ -77,6 +87,6 @@ export function createTelemetryPublisher(client: ApplicationInsights): (event: E
7787
export function trackEvent(client: ApplicationInsights, targetingId: string, event: IEventTelemetry, customProperties?: {[key: string]: any}): void {
7888
const properties = customProperties ? { ...customProperties } : {};
7989
// Ensure targetingId is string so that it will be placed in customDimensions
80-
properties["TargetingId"] = targetingId?.toString();
90+
properties[TARGETING_ID] = targetingId ? targetingId.toString() : "";
8191
client.trackEvent(event, properties);
8292
}
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-preview.1";
4+
export const VERSION = "2.0.0-preview.2";
55
export const EVALUATION_EVENT_VERSION = "1.0.0";

sdk/feature-management/package-lock.json

Lines changed: 1 addition & 1 deletion
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-preview.1",
3+
"version": "2.0.0-preview.2",
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",
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-preview.1";
4+
export const VERSION = "2.0.0-preview.2";

0 commit comments

Comments
 (0)