You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/BlazorServerApp/README.md
+32-21Lines changed: 32 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,34 +17,44 @@ This app demonstrates how to use the Feature Management library in Blazor apps.
17
17
This app uses two feature flags: "BrowserEnhancement" and "Beta".
18
18
19
19
```json
20
-
"FeatureManagement": {
21
-
"BrowserEnhancement": {
22
-
"EnabledFor": [
23
-
{
24
-
"Name": "Browser",
25
-
"Parameters": {
26
-
"AllowedBrowsers": [ "Edge" ]
27
-
}
20
+
"feature_management": {
21
+
"feature_flags": [
22
+
{
23
+
"id": "BrowserEnhancement",
24
+
"enabled": true,
25
+
"conditions": {
26
+
"client_filters": [
27
+
{
28
+
"name": "Browser",
29
+
"parameters": {
30
+
"AllowedBrowsers": [ "Edge" ]
28
31
}
32
+
}
29
33
]
34
+
}
30
35
},
31
-
"Beta": {
32
-
"EnabledFor": [
33
-
{
34
-
"Name": "Targeting",
35
-
"Parameters": {
36
-
"Audience": {
37
-
"DefaultRolloutPercentage": 50,
38
-
"Exclusion": {
39
-
"Groups": [
40
-
"Guests"
41
-
]
42
-
}
43
-
}
36
+
{
37
+
"id": "Beta",
38
+
"enabled": true,
39
+
"conditions": {
40
+
"client_filters": [
41
+
{
42
+
"name": "Targeting",
43
+
"parameters": {
44
+
"Audience": {
45
+
"DefaultRolloutPercentage": 50,
46
+
"Exclusion": {
47
+
"Groups": [
48
+
"Guests"
49
+
]
44
50
}
51
+
}
45
52
}
53
+
}
46
54
]
55
+
}
47
56
}
57
+
]
48
58
}
49
59
```
50
60
@@ -65,6 +75,7 @@ This app uses [cookie authentication](https://learn.microsoft.com/en-us/aspnet/c
65
75
Rather than `HttpContext`, the [`AuthenticationStateProvider`](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-8.0#authenticationstateprovider-service) service is used to obtain the user authentication state information for setting targeting context. The details can be found in the [`MyTargetingContextAccessor`](./MyTargetingContextAccessor.cs).
66
76
67
77
## Service Registration
78
+
68
79
Blazor applications like this one typically pull ambient contextual data from scoped services. For example, the `UserAgentContext`, `AuthenticationStateProvider` and `ITargetingContextAccessor` are all scoped services. This pattern *breaks* if the feature management services are added as singleton, which is typical in non-blazor web apps.
Copy file name to clipboardExpand all lines: examples/EvaluationDataToApplicationInsights/README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,9 +24,11 @@ These logs show what would be emitted to a connected Application Insights resour
24
24
To flow these events to Application Insights, [setup a new Application Insights resource in Azure](https://learn.microsoft.com/en-us/azure/azure-monitor/app/create-workspace-resource). Once setup, from `Overview` copy the `Connection String` and place it in `appsettings.json` at ApplicationInsights > ConnectionString. After restarting the app, events should now flow to Application Insights. This [document](https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core?tabs=netcorenew%2Cnetcore6#enable-application-insights-server-side-telemetry-no-visual-studio) provides more details on connecting a .NET application to Application Insights.
25
25
26
26
## About the App
27
+
27
28
This app uses [Application Insights for ASP.NET Core](https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core?tabs=netcorenew%2Cnetcore6). This means there is an App Insights SDK in the C# code and a separate App Insights SDK the Javascript. Lets cover what they're doing:
28
29
29
30
### Javascript App Insights SDK
31
+
30
32
See [Enable cliend-side telemetry for web applications](https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core?tabs=netcorenew%2Cnetcore6#enable-client-side-telemetry-for-web-applications)
31
33
32
34
For ASP.NET, this is added to _ViewImports.cshtml
@@ -47,11 +49,13 @@ These cookies are used to correlate telemetry from the browser with telemetry fr
47
49
*The Javascript SDK is not required, but is useful for collecting browser telemetry and generating these cookies out of the box.*
48
50
49
51
### Targeting Id
52
+
50
53
In order to connect evaluation events with other metrics from the user, a targeting id needs to be emitted. This can be done multiple ways, but the recommended way is to define a telemetry initializer. This initializer allows the app to modify all telemetry going to Application Insights before it's sent.
51
54
52
55
This example uses the provided `TargetingHttpContextMiddleware` and `TargetingTelemetryInitializer`. The middleware adds `TargetingId` (using the targeting context accessor) to the HTTP Context as a request comes in. The initializer checks for the `TargetingId` on the HTTP Context, and if it exists, adds `TargetingId` to all outgoing Application Insights Telemetry.
53
56
54
57
## Sample App Usage
58
+
55
59
Sample steps to try out the app:
56
60
57
61
1. Run the app. When the app is first started a User Id and Session Id will be generated. The username cookie will be set to a random integer, and the ai_user and ai_session cookies will be expired.
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20
+
</p>
21
+
<p>
22
+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23
+
It can result in displaying sensitive information from exceptions to end users.
24
+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
0 commit comments