You can tag an event to monitor custom activities in
your mobile app by inserting a call to the tagging API.
A custom activity for
mobile apps starts and ends when the app reports specific events which match
the events of an activity's signature file. If Aternity already reports these
events by default, you do not need to add manual API calls. However, for
some custom activities, you must manually tag and report those
events using API calls.
After tagging an event, you can optionally add contextual
data if needed, then use reportTag
to send the event to the
server.
Reporting custom events from an Android app which mark the start and end of an
activity
For example, to
measure the response time between the start of a sign in and its
response, if those events are not automatically reported, insert
an API to tag the sign in action, and add another API call to
tag its response. When you report each tag to Aternity, it matches them to the custom activity already in place, and then reports
the response time in the dashboards. To create your own
custom activities, contact Customer Services.
The tag APIs return a
newly created AternityContext
object, which
you then send to the server using
reportTag
.
Tagging a custom event with the API
Tag an event in your app using one of the following tagging APIs:
-
tagApplication
tags an event which occurred in your app, like the
start of a sign in. You specify the start of the event with
Aternity.Phase.Start
, and the end with
Aternity.Phase.End
.
-
tagCancelled
tags a user interruption during the activity, like
tapping Cancel on the screen. This is a different type of
Aternity.Phase.End
, where the end is the interruption by the user.
Depending on the activity definition, this could result in an incomplete
activity.
-
tagError
reports an error during the activity. This is a different
type of Aternity.Phase.End
, where the end is the occurrence of an
error. You can add
contextual details, like an error message or code, which can be picked up by
the signature as part of its logic.
If the app reports a start event but does not report an end event, the activity ends with a
timeout.
Before You Begin
Before you begin, ensure you have already done the following:
Method Definition
The tag APIs return a
newly created AternityContext
object, which
you then send to the server using
reportTag
. These methods are defined as part of the Aternity
class.
public AternityContext tagApplication(java.lang.String tagName,
Aternity.Phase phase)
public AternityContext tagCancelled(java.lang.String tagName)
public AternityContext tagError(java.lang.String tagName)
reportTag
is a method belonging to the AternityContext
object:
public void reportTag()
Parameter |
Description |
tagName
|
Enter the name of the custom event which you are tagging.
|
phase
|
Choose whether this marks the start or end of the event:
You can theoretically bypass using Aternity.Phase.End to signify
the start and end of an activity. You could send two different
tagNames with a Aternity.Phase.Start , where
the activity signature finds and uses those tags to mark the start and end of the
activity.
|
Example
//Create an AternityContext object called "download_start" which tags the start of "Download" activity
AternityContext download_start =
Aternity.getInstance().tagApplication("Download", Aternity.Phase.Start);
//Report the start of the activity using reportTag, referring to the AternityContext
download_start.reportTag();
//Report the end of the activity using tagApplication and reportTag
AternityContext download_end =
Aternity.getInstance().tagApplication("Download", Aternity.Phase.End);
download_end.reportTag();
//When user taps Cancel, tell the server that the activity is canceled.
//Optionally add contextuals here too.
AternityContext download_cancel = Aternity.getInstance().tagCancelled("Download");
download_cancel.reportTag();
//Tag and report an error to the server.
//Optionally add contextuals here too.
AternityContext download_error = Aternity.getInstance().tagError("Download");
download_error.setContextValue ("reason", "Server unavailable"));
download_error.reportTag();