Adding custom data
User email
When you already have your users identified within your app, you might want to add their email automatically attached to the bug report. Bugsee provides APIs for setting, getting and clearing the email.
!Java
// setting email
Bugsee.setEmail("name@example.com");
// getting email, null will be returned if email was not set.
String email = Bugsee.getEmail();
// clearing email
Bugsee.setEmail(null);
!Kotlin
// setting email
Bugsee.setEmail("name@example.com")
// getting email, null will be returned if email was not set.
val email = Bugsee.getEmail()
// clearing email
Bugsee.setEmail(null)
User/Session attributes
Besides email, any arbitrary attributes can be attached to the report as well. Issues are searchable by these attributes in the Bugsee dashboard as well.
!Java
Bugsee.setAttribute("name", "John Doe");
Bugsee.setAttribute("age", 23);
Bugsee.setAttribute("married", false);
!Kotlin
Bugsee.setAttribute("name", "John Doe")
Bugsee.setAttribute("age", 23)
Bugsee.setAttribute("married", false)
Once set, attributes persist until the application is uninstalled from the device. They can be cleared however using the following API.
!Java
// Clear a single attribute by name
Bugsee.clearAttribute("name");
// .. or clear all of them
Bugsee.clearAllAttributes();
!Kotlin
// Clear a single attribute by name
Bugsee.clearAttribute("name")
// .. or clear all of them
Bugsee.clearAllAttributes()
Custom traces
Traces may be useful when you want to trace how a specific variable or state changes over time right before the problem happens.
!Java
// Number value
Bugsee.trace("credit_balance", 15);
// String value
Bugsee.trace("current_location", "USA");
// Boolean value
Bugsee.trace("logged_in", true);
!Kotlin
// Number value
Bugsee.trace("credit_balance", 15)
// String value
Bugsee.trace("current_location", "USA")
// Boolean value
Bugsee.trace("logged_in", true)
Custom events
Events are identified by a string and can have an optional dictionary of parameters that will be stored and passed along with the report.
!Java
// Without any additional parameters
Bugsee.event("payment_processed");
// ...our with additional custom parameters
HashMap<String, Object> params = new HashMap<>();
params.put("amount", 125);
params.put("currency", "USD");
Bugsee.event("event with params", params);
!Kotlin
// Without any additional parameters
Bugsee.event("payment_processed")
// ...our with additional custom parameters
val params: HashMap<String, Any> = hashMapOf(
"amount" to 125,
"currency" to "USD"
)
Bugsee.event("event with params", params)
File attachments
File attachments can also be added to the report right before it is sent out. The attachment will be available for download right from the issue viewer. Currently both the amount of attachments and their size is limited. Max of 3 attachments, 3MB each (size increased from 1MB starting from v3.5.0).
You should set your implementation of ReportAttachmentsProvider interface to Bugsee using Bugsee.setReportAttachmentsProvider() method. It is recommended to call this method before Bugsee.launch(), because during Bugsee.launch() method execution will start to send reports created earlier. You can attach files, strings and byte arrays using CustomAttachment.fromDataFilePath(), CustomAttachment.fromDataString(), CustomAttachment.fromDataBytes(), accordingly.
!Java
Bugsee.setReportAttachmentsProvider(new ReportAttachmentsProvider() {
@Override
public ArrayList<CustomAttachment> getAttachments(Report report) {
ArrayList<CustomAttachment> resultList = new ArrayList<>();
// If it is a Blocker or crash.
if (report.getType() == Report.Type.Crash || report.getSeverity() == IssueSeverity.Blocker) {
// myFilePath is a path to file, which should be attached to the report.
CustomAttachment attachment = CustomAttachment.fromDataFilePath(myFilePath);
attachment.setFileName("detailed_info.txt");
attachment.setName("Detailed Info");
resultList.add(attachment);
}
return resultList;
}
});
!Kotlin
Bugsee.setReportAttachmentsProvider { report ->
val resultList: ArrayList<CustomAttachment> = ArrayList()
// If it is a Blocker or crash.
if (report.type == IssueType.Crash || report.severity == IssueSeverity.Blocker) {
// myFilePath is a path to file, which should be attached to the report.
val attachment = CustomAttachment.fromDataFilePath(myFilePath)
attachment.setFileName("detailed_info.txt")
attachment.name = "Detailed Info"
resultList.add(attachment)
}
resultList
}
View hierarchy
By default, Bugsee automatically captures view hierarchy upon bug or error report generation. This feature is controlled by the ViewHierarchyEnabled
launch option (Refer to configuration section for more details on launch options).
You can also trigger view hierarchy capture manually using the following API:
!Java
Bugsee.captureViewHierarchy();
!Kotlin
Bugsee.captureViewHierarchy()
This API can be called multiple times and all the captured view hierarchies will be attached to the next report. Be aware, that depending on the depth of your view hierarchy and the number of snapshots, the resulting size of the report bundle may be significantly increased.
Also note, that if ViewHierarchyEnabled
launch option is set to false
, this API will have no effect.