Skip to content

Commit 72a4a5f

Browse files
Merge pull request #302256 from MicrosoftDocs/main
Merged by Learn.Build PR Management system
2 parents f9d0ca5 + 0960f34 commit 72a4a5f

File tree

85 files changed

+484
-259
lines changed

Some content is hidden

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

85 files changed

+484
-259
lines changed

.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,12 @@
757757
"url": "https://github.com/AzureADQuickStarts/WebApp-OpenIdConnect-DotNet",
758758
"branch": "GuidedSetup",
759759
"branch_mapping": {}
760+
},
761+
{
762+
"path_to_root": "azure-policy-autogen-docs",
763+
"url": "https://github.com/MicrosoftDocs/azure-policy-autogen-docs",
764+
"branch": "main",
765+
"branch_mapping": {}
760766
}
761767
],
762768
"branch_target_mapping": {

articles/api-management/policy-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ the link in the **Version** column to view the source on the
2222

2323
## Azure API Management
2424

25-
[!INCLUDE [azure-policy-reference-rp-apimanagement](../../includes/policy/reference/byrp/microsoft.apimanagement.md)]
25+
[!INCLUDE [azure-policy-reference-rp-apimanagement](~/azure-policy-autogen-docs/includes/policy/reference/byrp/microsoft.apimanagement.md)]
2626

2727
## Related content
2828

articles/api-management/security-controls-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ compliant with the specific standard.
2121

2222
[!INCLUDE [azure-policy-compliancecontrols-introwarning](../../includes/policy/standards/intro-warning.md)]
2323

24-
[!INCLUDE [azure-policy-compliancecontrols-apim](../../includes/policy/standards/byrp/microsoft.apimanagement.md)]
24+
[!INCLUDE [azure-policy-compliancecontrols-apim](~/azure-policy-autogen-docs/includes/policy/standards/byrp/microsoft.apimanagement.md)]
2525

2626
## Related content
2727

articles/app-service/policy-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ the link in the **Version** column to view the source on the
1919

2020
## Azure App Service
2121

22-
[!INCLUDE [azure-policy-reference-rp-appservice](../../includes/policy/reference/byrp/microsoft.web.md)]
22+
[!INCLUDE [azure-policy-reference-rp-appservice](~/azure-policy-autogen-docs/includes/policy/reference/byrp/microsoft.web.md)]
2323

2424
## Release notes
2525

articles/app-service/security-controls-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ compliant with the specific standard.
2020

2121
[!INCLUDE [Azure-policy-compliancecontrols-introwarning](../../includes/policy/standards/intro-warning.md)]
2222

23-
[!INCLUDE [Azure-policy-compliancecontrols-appservice](../../includes/policy/standards/byrp/microsoft.web.md)]
23+
[!INCLUDE [Azure-policy-compliancecontrols-appservice](~/azure-policy-autogen-docs/includes/policy/standards/byrp/microsoft.web.md)]
2424

2525
## Next steps
2626

articles/automation/policy-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ the link in the **Version** column to view the source on the
1919

2020
## Azure Automation
2121

22-
[!INCLUDE [azure-policy-reference-rp-automation](../../includes/policy/reference/byrp/microsoft.automation.md)]
22+
[!INCLUDE [azure-policy-reference-rp-automation](~/azure-policy-autogen-docs/includes/policy/reference/byrp/microsoft.automation.md)]
2323

2424
## Next steps
2525

articles/automation/security-controls-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ with the specific standard.
2020

2121
[!INCLUDE [azure-policy-compliancecontrols-introwarning](../../includes/policy/standards/intro-warning.md)]
2222

23-
[!INCLUDE [azure-policy-compliancecontrols-automation](../../includes/policy/standards/byrp/microsoft.automation.md)]
23+
[!INCLUDE [azure-policy-compliancecontrols-automation](~/azure-policy-autogen-docs/includes/policy/standards/byrp/microsoft.automation.md)]
2424

2525
## Next steps
2626

articles/azure-app-configuration/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@
226226
href: howto-telemetry.md
227227
- name: Python
228228
href: howto-telemetry-python.md
229+
- name: JavaScript
230+
href: howto-telemetry-javascript.md
229231
- name: CI/CD integration
230232
items:
231233
- name: Use configuration files
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
title: Enable telemetry for feature flags in a Node.js application
3+
titleSuffix: Azure App Configuration
4+
description: Learn how to use telemetry in Node.js for feature flags in Azure App Configuration.
5+
ms.service: azure-app-configuration
6+
author: zhiyuanliang-ms
7+
ms.author: zhiyuanliang
8+
ms.topic: how-to
9+
ms.date: 06/25/2025
10+
---
11+
12+
# Enable telemetry for feature flags in a Node.js application
13+
14+
In this tutorial, you use telemetry in your Node.js application to track feature flag evaluations and custom events. Telemetry allows you to make informed decisions about your feature management strategy. You utilize the feature flag with telemetry enabled created in the [overview for enabling telemetry for feature flags](./howto-telemetry.md). Before proceeding, ensure that you create a feature flag named *Greeting* in your Configuration store with telemetry enabled. This tutorial builds on top of the tutorial for [using variant feature flags in a Node.js application](./howto-variant-feature-flags-javascript.md).
15+
16+
## Prerequisites
17+
18+
- The variant feature flag with telemetry enabled from [Enable telemetry for feature flags](./howto-telemetry.md).
19+
- The application from [Use variant feature flags in a Node.js application](./howto-variant-feature-flags-javascript.md).
20+
21+
## Add telemetry to your Node.js application
22+
23+
1. Install the following packages.
24+
25+
```bash
26+
npm install @microsoft/feature-management-applicationinsights-node
27+
```
28+
29+
1. Open `server.js` and add the following code in the beginning to connect to Application Insights to publish telemetry.
30+
31+
```js
32+
const appInsightsConnectionString = process.env.APPLICATIONINSIGHTS_CONNECTION_STRING;
33+
const applicationInsights = require("applicationinsights");
34+
applicationInsights.setup(appInsightsConnectionString).start();
35+
36+
const express = require("express");
37+
const server = express();
38+
// existing code ...
39+
```
40+
41+
1. Add the following import.
42+
43+
```js
44+
const { createTelemetryPublisher, trackEvent } = require("@microsoft/feature-management-applicationinsights-node");
45+
```
46+
47+
1. Create and register the telemetry publisher when initializing the `FeatureManager`.
48+
49+
```js
50+
// existing code ...
51+
const featureFlagProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
52+
const publishTelemetry = createTelemetryPublisher(applicationInsights.defaultClient);
53+
featureManager = new FeatureManager(featureFlagProvider, {
54+
onFeatureEvaluated: publishTelemetry
55+
});
56+
// existing code ...
57+
```
58+
59+
The `publishTelemetry` callback will send telemetry data each time a feature flag is evaluated.
60+
61+
1. Track custom events for user interactions. Modify the `/api/like` endpoint to send telemetry data to Application Insights whenever a user likes content. This helps you analyze which feature variants perform better.
62+
63+
```js
64+
server.post("/api/like", (req, res) => {
65+
const { UserId } = req.body;
66+
if (UserId === undefined) {
67+
return res.status(400).send({ error: "UserId is required" });
68+
}
69+
trackEvent(applicationInsights.defaultClient, UserId, { name: "Liked" });
70+
res.status(200).send();
71+
});
72+
```
73+
74+
## Run the application
75+
76+
1. Application insights requires a connection string to connect to your Application Insights resource. Set the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable to the connection string for your Application Insights resource.
77+
78+
```cmd
79+
setx APPLICATIONINSIGHTS_CONNECTION_STRING "applicationinsights-connection-string"
80+
```
81+
82+
If you use PowerShell, run the following command:
83+
84+
```powershell
85+
$Env:APPLICATIONINSIGHTS_CONNECTION_STRING = "applicationinsights-connection-string"
86+
```
87+
88+
If you use macOS or Linux, run the following command:
89+
90+
```bash
91+
export APPLICATIONINSIGHTS_CONNECTION_STRING='applicationinsights-connection-string'
92+
```
93+
94+
1. Run the application, [see step 4 of Use variant feature flags](./howto-variant-feature-flags-javascript.md#run-the-application).
95+
96+
1. Create 10 different users and log into the application. As you log in with each user, you get a different message variant for some of them. ~50% of the time you get no message. 25% of the time you get the message "Hello!" and 25% of the time you get "I hope this makes your day!"
97+
98+
1. With some of the users click the **Like** button to trigger the telemetry event.
99+
100+
> [!div class="mx-imgBorder"]
101+
> ![Screenshot of the application with like button clicked.](./media/howto-telemetry-javascript/like-button.png)
102+
103+
1. Open your Application Insights resource in the Azure portal and select **Logs** under **Monitoring**. In the query window, run the following query to see the telemetry events:
104+
105+
```kusto
106+
// Step 1: Get distinct users and their Variant from FeatureEvaluation
107+
let evaluated_users =
108+
customEvents
109+
| where name == "FeatureEvaluation"
110+
| extend TargetingId = tostring(customDimensions.TargetingId),
111+
Variant = tostring(customDimensions.Variant)
112+
| summarize Variant = any(Variant) by TargetingId;
113+
114+
// Step 2: Get distinct users who emitted a "Like"
115+
let liked_users =
116+
customEvents
117+
| where name == "Liked"
118+
| extend TargetingId = tostring(customDimensions.TargetingId)
119+
| summarize by TargetingId;
120+
121+
// Step 3: Join them to get only the evaluated users who also liked
122+
let hearted_users =
123+
evaluated_users
124+
| join kind=inner (liked_users) on TargetingId
125+
| summarize HeartedUsers = dcount(TargetingId) by Variant;
126+
127+
// Step 4: Total evaluated users per variant
128+
let total_users =
129+
evaluated_users
130+
| summarize TotalUsers = dcount(TargetingId) by Variant;
131+
132+
// Step 5: Combine results
133+
let combined_data =
134+
total_users
135+
| join kind=leftouter (hearted_users) on Variant
136+
| extend HeartedUsers = coalesce(HeartedUsers, 0)
137+
| extend PercentageHearted = strcat(round(HeartedUsers * 100.0 / TotalUsers, 1), "%")
138+
| project Variant, TotalUsers, HeartedUsers, PercentageHearted;
139+
140+
// Step 6: Add total row
141+
let total_sum =
142+
combined_data
143+
| summarize
144+
TotalUsers = sum(TotalUsers),
145+
HeartedUsers = sum(HeartedUsers)
146+
| extend
147+
Variant = "All",
148+
PercentageHearted = strcat(round(HeartedUsers * 100.0 / TotalUsers, 1), "%")
149+
| project Variant, TotalUsers, HeartedUsers, PercentageHearted;
150+
151+
// Step 7: Output
152+
combined_data
153+
| union (total_sum)
154+
```
155+
156+
> [!div class="mx-imgBorder"]
157+
> ![Screenshot of Application Insights showing the results table with four rows; All, Simple, Long, and None with their respective user counts and percentages.](./media/howto-telemetry-javascript/telemetry-results.png)
158+
159+
You see one "FeatureEvaluation" event for each time the quote page was loaded and one "Liked" event for each time the like button was clicked. The "FeatureEvaluation" event has a custom property called `FeatureName` with the name of the feature flag that was evaluated. Both events have a custom property called `TargetingId` with the name of the user that liked the quote.
160+
161+
For more information about the "FeatureEvaluation" event, go to the [Feature flag telemetry reference](./feature-flag-telemetry-reference.md)
162+
163+
## Additional resources
164+
165+
- [Quote of the Day sample](https://github.com/Azure-Samples/quote-of-the-day-javascript)
166+
167+
## Next steps
168+
169+
For the full feature rundown of the JavaScript feature management library, refer to the following document.
170+
171+
> [!div class="nextstepaction"]
172+
> [JavaScript Feature Management](./feature-management-javascript-reference.md)

articles/azure-app-configuration/howto-telemetry-python.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Enable telemetry for feature flags in a Python application (preview)
2+
title: Enable telemetry for feature flags in a Python application
33
titleSuffix: Azure App Configuration
44
description: Learn how to use telemetry in python for feature flags in Azure App Configuration.
55
ms.service: azure-app-configuration
@@ -11,12 +11,12 @@ ms.date: 05/06/2025
1111

1212
# Enable telemetry for feature flags in a Python application
1313

14-
In this tutorial, you use telemetry in your Python application to track feature flag evaluations and custom events. Telemetry allows you to make informed decisions about your feature management strategy. You utilize the feature flag with telemetry enabled created in [Enable telemetry for feature flags](./howto-telemetry.md). Before proceeding, ensure that you create a feature flag named *Greeting* in your Configuration store with telemetry enabled. This tutorial builds on top of [use variant feature flags](./howto-variant-feature-flags-python.md).
14+
In this tutorial, you use telemetry in your Python application to track feature flag evaluations and custom events. Telemetry allows you to make informed decisions about your feature management strategy. You utilize the feature flag with telemetry enabled created in the [overview for enabling telemetry for feature flags](./howto-telemetry.md). Before proceeding, ensure that you create a feature flag named *Greeting* in your Configuration store with telemetry enabled. This tutorial builds on top of the tutorial for [using variant feature flags in a Python application](./howto-variant-feature-flags-python.md).
1515

1616
## Prerequisites
1717

1818
- The variant feature flag with telemetry enabled from [Enable telemetry for feature flags](./howto-telemetry.md).
19-
- The application from [Use variant feature flags](./howto-variant-feature-flags-python.md).
19+
- The application from [Use variant feature flags in a Python application](./howto-variant-feature-flags-python.md).
2020

2121
## Add telemetry to your Python application
2222

@@ -105,46 +105,64 @@ In this tutorial, you use telemetry in your Python application to track feature
105105
export APPLICATIONINSIGHTS_CONNECTION_STRING='applicationinsights-connection-string'
106106
```
107107
108-
1. Run the application, [see step 2 of Use variant feature flags](./howto-variant-feature-flags-python.md#build-and-run-the-app) .
108+
1. Run the application, [see step 2 of Use variant feature flags](./howto-variant-feature-flags-python.md#build-and-run-the-app).
109+
109110
1. Create 10 different users and log into the application. As you log in with each user, you get a different message variant for some of them. ~50% of the time you get no message. 25% of the time you get the message "Hello!" and 25% of the time you get "I hope this makes your day!".
111+
110112
1. With some of the users select the **Like** button to trigger the telemetry event.
113+
111114
1. Open your Application Insights resource in the Azure portal and select **Logs** under **Monitoring**. In the query window, run the following query to see the telemetry events:
112115
113116
```kusto
114-
// Total users
115-
let total_users =
117+
// Step 1: Get distinct users and their Variant from FeatureEvaluation
118+
let evaluated_users =
116119
customEvents
117120
| where name == "FeatureEvaluation"
118-
| summarize TotalUsers = count() by Variant = tostring(customDimensions.Variant);
119-
120-
// Hearted users
121-
let hearted_users =
121+
| extend TargetingId = tostring(customDimensions.TargetingId),
122+
Variant = tostring(customDimensions.Variant)
123+
| summarize Variant = any(Variant) by TargetingId;
124+
125+
// Step 2: Get distinct users who emitted a "Like"
126+
let liked_users =
122127
customEvents
123-
| where name == "FeatureEvaluation"
128+
| where name == "Liked"
124129
| extend TargetingId = tostring(customDimensions.TargetingId)
125-
| join kind=inner (
126-
customEvents
127-
| where name == "Liked"
128-
| extend TargetingId = tostring(customDimensions.TargetingId)
129-
) on TargetingId
130-
| summarize HeartedUsers = count() by Variant = tostring(customDimensions.Variant);
131-
132-
// Calculate the percentage of hearted users over total users
130+
| summarize by TargetingId;
131+
132+
// Step 3: Join them to get only the evaluated users who also liked
133+
let hearted_users =
134+
evaluated_users
135+
| join kind=inner (liked_users) on TargetingId
136+
| summarize HeartedUsers = dcount(TargetingId) by Variant;
137+
138+
// Step 4: Total evaluated users per variant
139+
let total_users =
140+
evaluated_users
141+
| summarize TotalUsers = dcount(TargetingId) by Variant;
142+
143+
// Step 5: Combine results
133144
let combined_data =
134145
total_users
135146
| join kind=leftouter (hearted_users) on Variant
136147
| extend HeartedUsers = coalesce(HeartedUsers, 0)
137148
| extend PercentageHearted = strcat(round(HeartedUsers * 100.0 / TotalUsers, 1), "%")
138149
| project Variant, TotalUsers, HeartedUsers, PercentageHearted;
139-
140-
// Calculate the sum of total users and hearted users of all variants
150+
151+
// Step 6: Add total row
141152
let total_sum =
142153
combined_data
143-
| summarize Variant="All", TotalUsers = sum(TotalUsers), HeartedUsers = sum(HeartedUsers);
144-
145-
// Display the combined data along with the sum of total users and hearted users
154+
| summarize
155+
TotalUsers = sum(TotalUsers),
156+
HeartedUsers = sum(HeartedUsers)
157+
| extend
158+
Variant = "All",
159+
PercentageHearted = strcat(round(HeartedUsers * 100.0 / TotalUsers, 1), "%")
160+
| project Variant, TotalUsers, HeartedUsers, PercentageHearted;
161+
162+
// Step 7: Output
146163
combined_data
147164
| union (total_sum)
165+
148166
```
149167
150168
> [!div class="mx-imgBorder"]

0 commit comments

Comments
 (0)