Setting Custom Data for Xamarin

Discussed here is setting user attributes, tags, as well as logging user events and their relevant APIs for your Xamarin apps.

User Attributes

You can assign custom attributes to your users and they will show up on your Instabug dashboard with each report. Those attributes can later be used to filter the reports on the dashboard.

2888

User Attributes - Dashboard

To add a new user attribute use the following method.

//iOS
Instabug.SetUserAttribute("18", "Age");
Instabug.SetUserAttribute("True", "LoggedIn");

//Android 
Instabug.SetUserAttribute("Age", "18");
Instabug.SetUserAttribute("LoggedIn", "True");

📘

Disclaimers:

  • Each Bug or Crash Report could have up to 100 user attributes only.
  • The character limit for the Keys and Values is 90 characters each.

You can also retrieve the current value of a certain user attribute, or retrieve all user attributes.

//iOS
//Get all the created user attributes
Instabug.UserAttributes();
//Get the value of a ceratin user attribute
Instabug.UserAttributeForKey("Age");

//Android
//Get the value of a ceratin user attribute
String value = Instabug.GetUserAttribute("Age");

Then remove the current value of a certain user attribute.

//iOS
//Remove a user attribute
Instabug.RemoveUserAttributeForKey("Age");

//Android
//Remove a user attribute
Instabug.RemoveUserAttribute("Age");
//Remote all user attributes 
Instabug.ClearAllUserAttributes();

User Events

You can log custom user events throughout your application. Events are automatically going to be included with each report.

//iOS
Instabug.LogUserEventWithName("User Event");

//Android
Instabug.LogUserEvent("My Event");

Tags

You can add custom tags to the reports sent by the SDK. Those tags can later be used to filter reports or set custom rules on the Instabug dashboard.

2888

Tags - Dashboard

The example below demonstrates how to add tags to a report.

//iOS
string[] tags = { "tag1", "tag2" };
NSArray nsArray = NSArray.FromObjects(tags);		
Instabug.AppendTags(nsArray);

//Android
Instabug.AddTags("Tag1","Tag2","Tag3");

You can also get all the currently set tags as follows.

//iOS
NSArray tags = Instabug.GetTags();

//Android
IList<string> tags = Instabug.Tags;

📘

Adding tags before sending reports

Sometimes it's useful to be able to add a tag to a bug report before it's been sent. In these cases, the perfect solution would be use the event handlers of the bug reporting class. You can find more details here.

Last, you can reset all the tags.

//iOS
Instabug.ResetTags();

//Android
Instabug.ResetTags();

Managing Tags

If you'd like to remove a particular tag from your dashboard to prevent it from appearing again when entering a new tag manually, you can do so by navigating to the tags page under the settings options and remove the tag. You can also edit and rename the tag.


What’s Next

You now have more information than ever about each bug report, so we suggest you read up more on bug reporting. Also, did you know that you can use custom user attributes and events to target surveys?