Skip to content

Commit 403d370

Browse files
committed
Remove nullable usage. Other updates.
1 parent b88eb3a commit 403d370

File tree

7 files changed

+10
-20
lines changed

7 files changed

+10
-20
lines changed

examples/EvaluationDataToApplicationInsights/HttpContextTargetingContextAccessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public ValueTask<TargetingContext> GetContextAsync()
3131

3232
string username = httpContext.Request.Cookies["username"];
3333

34-
List<string> groups = new List<string>();
34+
var groups = new List<string>();
3535

3636
//
37-
// Build targeting context based off user info
38-
TargetingContext targetingContext = new TargetingContext
37+
// Build targeting context based on user info
38+
var targetingContext = new TargetingContext
3939
{
4040
UserId = username,
4141
Groups = groups

examples/EvaluationDataToApplicationInsights/Pages/Error.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace EvaluationDataToApplicationInsights.Pages
88
[IgnoreAntiforgeryToken]
99
public class ErrorModel : PageModel
1010
{
11-
public string? RequestId { get; set; }
11+
public string RequestId { get; set; }
1212

1313
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1414

examples/EvaluationDataToApplicationInsights/Pages/Index.cshtml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class IndexModel : PageModel
1010
private readonly IVariantFeatureManager _featureManager;
1111
private readonly TelemetryClient _telemetry;
1212

13-
public string? Username { get; set; }
13+
public string Username { get; set; }
1414

1515
public IndexModel(
1616
IVariantFeatureManager featureManager,
@@ -31,7 +31,6 @@ public async Task<IActionResult> OnGet()
3131

3232
//
3333
// Use application's feature manager to get assigned variant for current user
34-
//
3534
Variant variant = await _featureManager
3635
.GetVariantAsync("ImageRating", HttpContext.RequestAborted);
3736

examples/EvaluationDataToApplicationInsights/Program.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@
99

1010
var builder = WebApplication.CreateBuilder(args);
1111

12-
//
13-
// Use Azure App Configuration as an application configuration provider
14-
//
15-
builder
16-
.Configuration
17-
.AddAzureAppConfiguration((options) =>
18-
{
19-
options.Connect(builder.Configuration["AzureAppConfigurationConnectionString"]);
20-
});
21-
2212
//
2313
// What a web app using app insights looks like
2414
//

examples/EvaluationDataToApplicationInsights/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ These logs show what would be emitted to a connected Application Insights resour
2121

2222
## Connecting to Application Insights
2323

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.
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.
2525

2626
## About the App
2727
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:
@@ -69,7 +69,7 @@ Sample steps to try out the app:
6969

7070
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.
7171
1. When the page is loaded, the "ImageRating" feature is evaluated which [defines three variants](./appsettings.json). Events can be seen in the Output window. (There may be a small delay as events are batched)
72-
1. Select a rating for the loaded image and click vote. A 'Vote' event will be emitted.
72+
1. Select a rating for the loaded image and click vote. A "Vote" event will be emitted.
7373
1. Go to Checkout and click "Check Out", which emits a custom event and a custom metric. This event and metric will be shown in the logs as well.
7474
1. If connected to Application Insights, head to the resource in the portal. Events and metrics will be there as well.
7575
1. Try going to Logs > New Query and run the query "customEvents". This should show the custom events emitted.

examples/EvaluationDataToApplicationInsights/Telemetry/MyTelemetryInitializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ public MyTelemetryInitializer(IHttpContextAccessor httpContextAccessor)
1717

1818
public void Initialize(ITelemetry telemetry)
1919
{
20-
HttpContext? httpContext = _httpContextAccessor.HttpContext;
20+
HttpContext httpContext = _httpContextAccessor.HttpContext;
2121

2222
if (httpContext == null)
2323
{
2424
return;
2525
}
2626

27-
string? username = httpContext.Request.Cookies["username"];
27+
string username = httpContext.Request.Cookies["username"];
2828

2929
if (username != null)
3030
{

examples/EvaluationDataToApplicationInsights/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"AllowedHosts": "*",
99
"ApplicationInsights": {
10+
"ConnectionString": "<connection-string>"
1011
},
1112
"FeatureManagement": {
1213
"ImageRating": {

0 commit comments

Comments
 (0)