Analytics

Android

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

public class Tracer : Java.Lang.Object, IO.Uqudo.Sdk.Core.Analytics.ITracer
{
    public void Trace(IO.Uqudo.Sdk.Core.Analytics.Trace trace)
    {
        System.Console.WriteLine("Analytics: " + trace);
    }
}

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

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

Please refer to section Analytics for details.

iOS

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

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:

[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 for details.

Last updated