top of page
Search
Writer's pictureBlotski Dzmitry

Logrocket for Xamarin.Android


Hi everyone!


A while ago, one of my clients sent me an email with the request. He wanted to implement a real time analytics into the app. He suggested using LogRocket, as that solution has been already used on their website.


LogRocket Identifies technical and UI issues using artificial intelligence, allows you to view session replays to understand exactly what went wrong. He helps you track exactly what users have encountered in your application, as well as DOM playback, console and network logs, errors and performance data. Also LogRocket proactively seek the most impactful user issues with JavaScript error, network errors, stack traces, automatic triaging, and alerting and much more.


However, we faced the problem: LogRocket doesn’t have a package for both Xamarin Native. As a result, it was decided to create its own Xamarin wrapper for LogRocket.


Installation


LogRocket packages



Step 1 — Adding references to LogRocket


If you are a new LogRocket user, you’ll need to create an account and start your free trial period.


Android


Permissions


We include the INTERNET permission by default as we need it to make network requests:



	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.INTERNET" />

Step 2 — Initialize LogRocket


First, you’ll need to get your LogRocket app ID.


First, add the key to the AppID property in the SDKConfig object.

SDKConfig config = new SDKConfig
{
    AppID = "<APP_SLUG>"
};

Then call the static Init method from the SDKInit class.

SDKInit.Init(this.Application, BaseContext, config);


Step 3 — Create a user


Finally, you’ll need to create a user, like this:


Add user information to the dictionary. You can get more information here Identify Users.

IDictionary<string, string> userData = new Dictionary<string, string>
{
    { "name", "Jane Smith" },
    { "email", "janesmith@gmail.com" },
    { "subscriptionPlan", "premium" }
};

It remains only to initialize the user.

SDK.Identify("<USER_ID>", userData);

That’s it — now you’ve got a working LogRocket app. However, you will need to register your users before you can receive analytics in your app. For more information, see the section LogRocket for Android.


The full version of LogRocket installing guide is available here — https://docs.logrocket.com/reference/getting-started-with-sdks


By Dzmitry Blotski from Igniscor


  • Xamarin

  • LogRocket

  • Nuget

  • Libraries

  • Xamarin Forms


61 views0 comments

Comments


bottom of page