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
I am trying to customize the automatic track page view events. Need to modify the name param from "not_specified" to something else and also add some custom data to the properties param of the IPageViewTelemetry
In an attempt at this I created a custom telemetryInitializer class
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
public class CustomTelemetryInitializer : ITelemetryInitializer
{
private readonly IServiceProvider _serviceProvider;
public CustomTelemetryInitializer(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public void Initialize(ITelemetry telemetry)
{
if (telemetry is PageViewTelemetry pageViewTelemetry)
{
if (string.IsNullOrEmpty(pageViewTelemetry.Name) || pageViewTelemetry.Name == "not_specified")
{
pageViewTelemetry.Name = "QA Name";
}
pageViewTelemetry.Properties["CompanyName"] = "Pancakes";
}
}
}
// in program.cs
builder.Services.AddBlazorApplicationInsights(config =>
{
config.ConnectionString = builder.Configuration["ApplicationInsights:ConnectionString"];
config.AutoTrackPageVisitTime = true;
}, async applicationInsights =>
{
var telemetryItem = new TelemetryItem()
{
Tags = new Dictionary<string, object?>()
{
{ "ai.cloud.role", "SPA" },
{ "ai.cloud.roleInstance", "Blazor Server" },
}
};
await applicationInsights.AddTelemetryInitializer(telemetryItem);
});
builder.Services.AddSingleton<ITelemetryInitializer, CustomTelemetryInitializer>();
This does intercept some telemetry from the app, but not the ones triggered by this library, I realize that BlazorApplicationInsights' implementation of AddTelemetryInitializer receives a TelemetryItem instead of a ITelemetryInitializer.
Thank you in advance for any assistance!
The text was updated successfully, but these errors were encountered:
Hello,
I am trying to customize the automatic track page view events. Need to modify the name param from "not_specified" to something else and also add some custom data to the properties param of the IPageViewTelemetry
In an attempt at this I created a custom telemetryInitializer class
This does intercept some telemetry from the app, but not the ones triggered by this library, I realize that BlazorApplicationInsights' implementation of AddTelemetryInitializer receives a TelemetryItem instead of a ITelemetryInitializer.
Thank you in advance for any assistance!
The text was updated successfully, but these errors were encountered: