# Analytics

**Android**

To enable the analytics feature, first you need to create a class that implements the uqudo Tracer interface as shown below:

<pre class="language-csharp"><code class="lang-csharp"><strong>public class Tracer : Java.Lang.Object, IO.Uqudo.Sdk.Core.Analytics.ITracer
</strong>{
    public void Trace(IO.Uqudo.Sdk.Core.Analytics.Trace trace)
    {
        System.Console.WriteLine("Analytics: " + trace);
    }
}
</code></pre>

After that you can pass an instance of the class in the intizialization of the SDK as described below:

```csharp
var tracer = new Tracer();
IO.Uqudo.Sdk.Core.UqudoSDK.Init(this, tracer: tracer);
```

Please refer to section [Analytics](/docs/kyc/uqudo-sdk/integration/android/analytics.md) for details.

**iOS**

To enable the analytics feature, first you need to create a class that implements the uqudo Tracer interface as shown below:

```csharp
using System;
using System.Diagnostics;
using UqudoSDK;
namespace <Your Project Namespace>
{
    public class Tracer : UQTracer
    {
    public override void Trace(UQTrace trace)
    {
        string sessionId = trace.SessionId;
        string statusMessage = trace.StatusMessage;
        string timestamp = trace.Timestamp.ToString();
        string category = GetStringFromIntPtr(trace.Category);
        string eventStr = GetStringFromIntPtr(trace.Event);
        string page = GetStringFromIntPtr(trace.Page);
        string status = GetStringFromIntPtr(trace.Status);
        string statusCode = GetStringFromIntPtr(trace.StatusCode);
        string output = $"Trace(sessionId={sessionId}, category={category}, event={eventStr}, page={page}, status={status}, statusCode={statusCode}, statusMessage={statusMessage}, documentType={trace.DocumentType.ToString()}, timestamp={timestamp})";
        Debug.WriteLine(output);

    }
    private string GetStringFromIntPtr(IntPtr ptr)
    {
        foreach (var field in typeof(Constants).GetProperties())
        {
            if ((IntPtr)field.GetValue(null) == ptr)
            {
                int underscoreIndex = field.Name.IndexOf('_');
                return underscoreIndex != -1 ? field.Name.Substring(underscoreIndex + 1) : field.Name;
            }
        }
        return "";
    }

}
}
```

After that you can pass an instance of the class in the intizialization of the SDK as described below:

```csharp
[Export("application:didFinishLaunchingWithOptions:")]
public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    var tracer = new Tracer();
    new UQBuilderController(trace: tracer);
    return true;
}
```

Please refer to section [Analytics](/docs/kyc/uqudo-sdk/integration/ios/analytics.md) for details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uqudo.com/docs/kyc/uqudo-sdk/integration/xamarin/analytics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
