﻿using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;

namespace Papika.SubProcessors
{
    /// <summary>
    /// Telemetry type used to track page views.
    /// </summary>
    public class PageView : ISubProcessor
    {
        public Enums.Option Options { get; set; } = Enums.Option.NoFilter;

        public PageView()
        {
        }

        public PageView(Enums.Option options)
        {
            Options = options;
        }

        public bool IsTelemetryItemAllowed(ITelemetry item)
        {
            var pageView = item as PageViewTelemetry;

            if (pageView == null)
                return false;

            if (!Tools.IsTelemetryLocationAllowed(item, Options))
                return false;

            return true;
        }
    }
}
