Walkthrough: Tracking requests from Sitecore to xConnect


How to track requests from Sitecore to xConnect.

The ISendRequestHandler interface injects logic to run before and after a request is sent to xConnect. Any client that wants to track and log requests to xConnect must implement the ISendRequestHandler interface and register it in the configuration file.

This walkthrough describes how to:

  • Implement the ISendRequestHandler interface

  • Register the handler

Implement the ISendRequestHandler interface

To implement the ISendRequestHandler interface:

  • Create a new class that extends ISendRequestHandler. For example:

    public class TestSendRequestHandler : ISendRequestHandler 
          public async Task PreHandle(HttpRequestMessage request) 
           public async Task PostHandle(HttpResponseMessage response, TimeSpan? duration) 

Register the handler

To register the handler in the configuration file:

  1. Create an XML file under the App_Data\Config\Sitecore\Collection folder (you can specify any filename).

  2. Register the handler using the following code (substituting the name of the handler):

                    <Type>Sitecore.Xdb.UnitTests.RequestLoggingFixture.TestSendRequestHandler, Sitecore.Xdb. UnitTests</Type>
                    <As>Sitecore.Xdb.Common.Web.ISendRequestHandler, Sitecore.Xdb.Common.Web</As>