<commit_before>// Copyright (c) <NAME>, 2017. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.

namespace MartinCostello.LondonTravel.Site.Telemetry
{
    using System;
    using System.Collections.Generic;
    using Microsoft.ApplicationInsights.Extensibility;

    /// <summary>
    /// A class representing a filter for HTTP requests to Application Insights. This class cannot be inherited.
    /// </summary>
    /// <remarks>
    /// Based on <c>https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/db53106c5d85546a2508ecb9dcd6bf1106fb29fa/Src/DependencyCollector/Shared/Implementation/ApplicationInsightsUrlFilter.cs</c>.
    /// </remarks>
    internal sealed class ApplicationInsightsUrlFilter
    {
        private const string QuickPulseServiceEndpoint = "https://rt.services.visualstudio.com/QuickPulseService.svc";
        private const string TelemetryServiceEndpoint = "https://dc.services.visualstudio.com/v2/track";

        private readonly TelemetryConfiguration _configuration;
        private readonly Uri _telemetryServiceEndpointUri = new Uri(TelemetryServiceEndpoint);

        private KeyValuePair<string, string> _cachedEndpointLeftPart;

        internal ApplicationInsightsUrlFilter(TelemetryConfiguration configuration)
        {
            _configuration = configuration;
            _cachedEndpointLeftPart = GetEndpointLeftPart();
        }

        private string EndpointLeftPart
        {
            get
            {
                string currentEndpointAddressValue = null;

                if (_configuration != null)
                {
                    string endpoint = _configuration.TelemetryChannel.EndpointAddress;

                    if (!string.IsNullOrEmpty(endpoint))
                    {
                        currentEndpointAddressValue = endpoint;
                    }
                }

                if (_cachedEndpointLeftPart.Key != currentEndpointAddressValue)
                {
                    _cachedEndpointLeftPart = GetEndpointLeftPart(currentEndpointAddressValue);
                }

                return _cachedEndpointLeftPart.Value;
            }<commit_msg>Fix NullReferenceException<commit_after>// Copyright (c) <NAME>, 2017. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.

namespace MartinCostello.LondonTravel.Site.Telemetry
{
    using System;
    using System.Collections.Generic;
    using Microsoft.ApplicationInsights.Extensibility;

    /// <summary>
    /// A class representing a filter for HTTP requests to Application Insights. This class cannot be inherited.
    /// </summary>
    /// <remarks>
    /// Based on <c>https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/db53106c5d85546a2508ecb9dcd6bf1106fb29fa/Src/DependencyCollector/Shared/Implementation/ApplicationInsightsUrlFilter.cs</c>.
    /// </remarks>
    internal sealed class ApplicationInsightsUrlFilter
    {
        private const string QuickPulseServiceEndpoint = "https://rt.services.visualstudio.com/QuickPulseService.svc";
        private const string TelemetryServiceEndpoint = "https://dc.services.visualstudio.com/v2/track";

        private readonly TelemetryConfiguration _configuration;
        private readonly Uri _telemetryServiceEndpointUri = new Uri(TelemetryServiceEndpoint);

        private KeyValuePair<string, string> _cachedEndpointLeftPart;

        internal ApplicationInsightsUrlFilter(TelemetryConfiguration configuration)
        {
            _configuration = configuration;
            _cachedEndpointLeftPart = GetEndpointLeftPart();
        }

        private string EndpointLeftPart
        {
            get
            {
                string currentEndpointAddressValue = null;

                if (_configuration != null)
                {
                    string endpoint = _configuration.TelemetryChannel?.EndpointAddress;

                    if (!string.IsNullOrEmpty(endpoint))
                    {
                        currentEndpointAddressValue = endpoint;
                    }
                }

                if (_cachedEndpointLeftPart.Key != currentEndpointAddressValue)
                {
                    _cachedEndpointLeftPart = GetEndpointLeftPart(currentEndpointAddressValue);
                }

                return _cachedEndpointLeftPart.Value;
            }
{'fraction_non_alphanumeric': 0.07231864708500223, 'fraction_numerical': 0.01335113484646195, 'mean_word_length': 2.369565217391304, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1889283', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1016, 'n_words': 235}