-
Notifications
You must be signed in to change notification settings - Fork 0
HappyTracker
Ade Fruandta edited this page Oct 18, 2018
·
5 revisions
For documented purpose our tracking code, we announce HappyTracker.
Sometimes we have problem to answer "is there property source in event View Home Screen?". To answer that question we should search in many class in our code and trace one by one line. HappyTracker help us to maintenance our code and documentation our tracker. How HappyTracker works?
First, we create TrackerAdapter who extend from Adapter
public class TrackerAdapter extends Adapter {
@Override
protected void onIdentify(Properties properties) {
super.onIdentify(properties);
// do what should you do for your tracking
}
@Override
protected void onEvent(String event, Properties properties) {
super.onEvent(event, properties);
// do what should you do for your tracking
}
}Like retrofit, we create an Interface who provide TrackerAdapter
@Provider(TrackerAdapter.class)
public interface TrackerEvent {
// it will be call onIdentify at Adapter
@Identify
void identify(@Property("user_id") String userId);
// it will be call onSaveProperties at Adapter
// Save properties for event "View Home Screen"
@SaveProperties("View Home Screen")
void savePropertiesViewHomeScreen(@Property("source") String source);
// Track "View Home Screen"
// optional true -> if source is null then doesn't included into properties in onEvent
// overwrite true -> if property source already in saveProperties than will be using saveProperties
@Event("View Home Screen")
void viewHomeScreen(@Property(value = "source", optional = true, overwrite = false) String source);
}Finally, we can use Tracker Tracker.create(context, TrackerEvent.class).viewHomeScreen(source)
- Event
- value: key or value your event
- Identify
- Property
- value: key your property
- optional: if property is optional and value is null then not included in properties
- overwrite: if property is overwrite then existing property will be replace
- Provider
- value: class your adapter
- SaveProperties
- value: key or value event who want save properties
dependencies {
implementation "com.github.happyfresh.HappySupportAndroid:happytracker:$latest_version"
}