Ejemplo n.º 1
0
 /// <summary>
 /// Execute action on event, using telemetryManifestContext as a provider of the necessary information.
 /// Return true if it is allowed to execute next actions.
 /// Return false action forbids the event.
 /// By default OptOut set IsEventDropped to the true, and exclude all properties.
 /// </summary>
 /// <param name="eventProcessorContext"></param>
 /// <returns>Indicator, whether current action is not explicitely forbid current event</returns>
 public bool Execute(IEventProcessorContext eventProcessorContext)
 {
     if (!eventProcessorContext.HostTelemetrySession.IsOptedIn)
     {
         TelemetryEvent telemetryEvent = eventProcessorContext.TelemetryEvent;
         if (!telemetryEvent.IsOptOutFriendly && !optoutFriendlyEvents.Contains(telemetryEvent.Name))
         {
             eventProcessorContext.IsEventDropped = true;
         }
         foreach (string item in new List <string>(telemetryEvent.Properties.Keys))
         {
             if ((!telemetryEvent.IsOptOutFriendly || TelemetryEvent.IsPropertyNameReserved(item) || TelemetryContext.IsPropertyNameReserved(item)) && !optoutFriendlyProperties.Contains(item))
             {
                 eventProcessorContext.ExcludePropertyFromEvent(item);
             }
         }
     }
     return(true);
 }
 /// <summary>
 /// Implementation of the ProcessPropertyName
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="eventProcessorContext"></param>
 protected override void ProcessPropertyName(string propertyName, IEventProcessorContext eventProcessorContext)
 {
     eventProcessorContext.ExcludePropertyFromEvent(propertyName);
 }