ConfigureServices to track authenticated users

The following code snippet shows how to configure AddApplication Insights Telemetry.

public void ConfigureServices(IServiceCollection services)
{
    // ...
    services.AddSingleton<ITelemetryInitializer, CustomAppInsightsInitializer>(); // server side to track the requests and dependencies
    ApplicationInsightsServiceOptions options = new ApplicationInsightsServiceOptions()
    {
        EnableAuthenticationTrackingJavaScript = true, // enable client side to track pageviews
        ConnectionString = "InstrumentationKey={key};IngestionEndpoint=https://westeurope-1.in.applicationinsights.azure.com/"
    };
    services.AddApplicationInsightsTelemetry();

    services.AddRazorPages(options =>
        // ...
}

Comments

Leave a Comment

All fields are required. Your email address will not be published.