Telemetry
Telemetry data lets you track how your users are interacting with your app. For instance, you can see where users are spending most of their time, or determine which types of challenges are the most engaging to users based on a few metrics.
There are telemetry methods called for challenge requests out of the box, as described below, but custom telemetry events can also be recorded.
By default, telemetry data is recorded for the following events automatically by the library:
Event | Explanation |
---|---|
REQUEST_FETCHED | When the data of a challenge request is requested by the library. The library automatically records this. |
REQUEST_PROCESSED | When a challenge request is acted upon by a user. The library automatically records this. |
In addition to these, there are optional telemetry events. These require additional external library calls:
Event | Explanation |
---|---|
NOTIFICATION_CLICKED | This is to be used when a notification is interacted with ("clicked" or "tapped" on) by the user. Call requestNotificationActedOn() and pass the "privakeyId" and "requestGuid" parameters from the notification data. |
REQUEST_VIEWED | This event should be recorded when the user views a challenge request data in the app. In order to do so, it requires two calls: requestViewStart() - when the request has begun to be displayed to the user, takes in a Request object. requestViewEnd() - when the request goes off screen, takes in a Request object. The calls requires a request object because an internal timer in the library is tracked. The time (and therefore the telemetry data) is only valid if the request is the same (IE the user began viewing a request, and then stopped viewing that same request). An event will be created that tracks how long the request was viewed. |
NOTIFICATION_RECEIVED | This is to be used when a challenge request notification is received by the app. Call requestNotificationReceived() and pass the data body of the notification as the parameter. |
If you would like to send custom telemetry events you can use the library method recordTelemetry.
In the following simple example, the code tracks telemetry on which button users opt to select for a particular campaign, either button A, or B, in order to find out which option is more popular across the user base. The telemetry event in this case is custom, and is valued "buttonClicked". The attribute sent is {"button" = theButton}, or put another way, the identifier of the button. The campaign id is also sent along, so that the choices can be aggregated by campaign.
import com.privakey.cx.core.database.entity.TelemetryEntity;
import com.privakey.cx.callbacks.RecordTelemetryCallback;
// other imports
// class definition, etc
// Track which campaign this option is for.
private String mCampaignId;
public void onButtonAPressed() {
recordButtonPressedTelemetry("A");
}
public void onButtonBPressed() {
recordButtonPressedTelemetry("B");
}
public void recordButtonPressedTelemetry(String theButton) {
// Get library instance
PrivakeyCX privakeyCX = PrivakeyCX.getInstance();
// Prepare the telemetry event
TelemetryEntity event = TelemetryEntity(userPrivakeyId, "buttonClicked");
event.addAttributes("button", theButton);
event.addAttributes("campaignId", mCampaignId);
// Prepare the callback (optional - can pass null if no callback needed)
RecordTelemetryCallback callback = new RecordTelemetryCallback() {
@Override
public void onRecordTelemetryResult(String result) {
// custom logic to run after the telemetry is sent to the Auth Service
}
};
// Tell the library to record the telemetry
privakeyCX.recordTelemetry(event, callback);
}
Updated about 5 years ago