title: How to integrate server side Application Insights telemetry into my Umbraco / Articulate web site ideally?
body: <p>I have created an Umbraco web site by doing the following</p>
  
  <ol>
  <li>Open Visual Studio</li>
  <li>Create a new empty MVC project</li>
  <li>Added the <a href="https://www.nuget.org/packages/UmbracoForms.Core/" rel="nofollow">current Umbraco nuget package</a></li>
  <li>Hosted the project in Azure</li>
  <li>Successfully executed Umbraco installer</li>
  <li>Installed the <a href="https://our.umbraco.org/projects/starter-kits/articulate" rel="nofollow">current Articulate package</a></li>
  </ol>
  
  <p>Now I would like to integrate <a href="https://azure.microsoft.com/en-us/services/application-insights/" rel="nofollow">Application Insights</a>. The client side part is very easy, I just need to add some JavaScript code into the master view.</p>
  
  <p>For the server side part I need to add this code:</p>
  
  <pre><code>using System;
  using System.Web.Mvc;
  using Microsoft.ApplicationInsights;
  
  namespace MVC2App.Controllers
  {
      [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)] 
      public class AiHandleErrorAttribute : HandleErrorAttribute
      {
          public override void OnException(ExceptionContext filterContext)
          {
              if (filterContext != null &amp;&amp; filterContext.HttpContext != null &amp;&amp; filterContext.Exception != null)
              {
                  //If customError is Off, then AI HTTPModule will report the exception
                  if (filterContext.HttpContext.IsCustomErrorEnabled)
                  {  
                      // Note: A single instance of telemetry client is sufficient to track multiple telemetry items.
                      var ai = new TelemetryClient();
                      ai.TrackException(filterContext.Exception);
                  } 
              }
              base.OnException(filterContext);
          }
      }
  }
  // then register AiHandleErrorAttribute in FilterConfig:
  public class FilterConfig
  {
     public static void RegisterGlobalFilters(GlobalFilterCollection filters)
     {
       filters.Add(new AiHandleErrorAttribute());
     }
  }
  </code></pre>
  
  <p>My question in detail is the following:</p>
  
  <p>How do I integrate this code ideally touching as less as possible in the Umbraco core to make updates in the future as easy as possible? What is the best approach to integrate the code?</p>
  
  <p>Do I need to touch the Umbraco core or is it possible just to change the Articulate code? Or even better: Can I create my own Umbraco package which can add Application Insights feaature to my Umbraco instance (maybe both client and server side part)?</p>