Transactions let you keep track of any process inside your application with a beginning and an end. For example, a transaction could be a process such as registration, login, or a purchase.
A transaction is basically an event that starts and then finishes in one of three ways:
- The transaction is completed normally, resulting in a status of "SUCCESS".
- The transaction is cancelled by the user, possibly because the process took too much time to complete, resulting in a status of "CANCEL".
- The transaction failed because the app crashed, resulting in a status of "FAIL".
Use the following methods to work with transactions:
- To start a transaction, use the transactionStart(name) method as follows:
- To stop a transaction, use the transactionStop(id) method as follows:
- To cancel a transaction, use the transactionCancel(id, reason) method as follows:
String txID = Mint.transactionStart("Test1");
A transaction ID is returned when you create a transaction. Use this transaction ID if you need to cancel or stop the transaction.
Mint.transactionCancel(txID, "This is the reason");
To identify slow transactions that negatively affect the user experience, monitor how long transactions take to complete by going to the Transactions dashboard in Splunk MINT Management Console.
Add custom data to transactions
You can add extra custom data to specific transactions as a data map or as a key-value pair. Custom data can only be viewed using the Splunk MINT App.
- To add custom data as a data map to a transaction, use the transactionStart(name, customData), transactionStop(id, customData), and transactionCancel(id, reason, customData) methods. For example, to add custom data to a transaction stop:
- To add custom data as a key-value pair to a transaction, use the transactionStart(name, keyName, keyValue), transactionStop(id, keyName, keyValue), and transactionCancel(id, reason, keyName, keyValue) methods. For example, to add custom data to a transaction stop:
HashMap<String, Object> mydata = new HashMap<String, Object>(); mydata.put("hotel", "Bob's B&B"); mydata.put("member", "Elite"); Mint.transactionStop(txID, mydata);
Mint.transactionStop(txID, "member", "Elite");
View custom data
To view the custom data for transactions, open the Splunk MINT App and run a search. For example, the following search lists the names of started transactions with the values of the custom "member" field:
sourcetype=mint:trstart extraData.member=* | table tr_name, extraData.member
For more about running searches in MINT, see Searches in the Splunk MINT App User Guide.
Customize session handling
Add and report events
This documentation applies to the following versions of Splunk MINT™ SDK for Android: 5.2.x