THIS IS ARCHIVED DOCUMENTATION

NullReferenceException on Tracking.Current When Executing a Request for a Quick View

Coveo for Sitecore (September 2016)

Symptoms

When trying to fetch the content of a page to populate the Quick View, a 500 error is thrown with a NullReferenceException on Tracking.Current.

Cause

When xDB Tracking is disabled, Tracking.Current is set to null . Every page trying to log xDB analytics when they’re disabled will get a NullReferenceException.

This particular error is caused by the ExcludeCoveoUserAgentProcessor which aborts the Sitecore startAnalytics pipeline when the User Agent is Coveo Sitecore Search Provider to disable tracking in certain scenarios.

This is to ensure that Coveo for Sitecore doesn’t log xDB analytics when fetching the HTML content for the Quick View.

For more information on why the pipeline is canceled, see Disable xDB tracking for single requests.

Resolution

There are two ways to solve this problem: adding null-checks or disabling the processor.

Add Null-Checks

Ensure that every call to Tracking is wrapped by Tracking.IsActive.

Since other scenarios could disable Tracking, this is the recommended resolution.

Disable the Processor

This re-enables analytics logging in your xDB instance. 

Create a new Coveo.SearchProvider.EnableCoveoUserAgentForXDB.config and add the following node in it:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <startAnalytics>
        <processor type="Coveo.Analytics.Processors.ExcludeCoveoUserAgentProcessor, Coveo.Analytics">
          <patch:delete />
        </processor>
      </startAnalytics>
    </pipelines>
  </sitecore>
</configuration>