Name: android_viewtracker
Owner: Alibaba
Description: A data collection library for click and exposure event with the UI.
Created: 2017-08-10 08:46:24.0
Updated: 2018-05-15 07:32:28.0
Pushed: 2017-10-26 13:41:05.0
Homepage: https://github.com/alibaba/android_viewtracker
Size: 1459
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
:book: English Documentation | :book: Chinese Documentation
ViewTracker
is used to collect the mobile client of click and exposure event log automatically. It has been used in tmall App production environment from March 2016.
Android
& iOS
(the github repo of iOS
SDK).KISS
) Principle: Avoid code complexity, class name, package name etc have good readability.SRP
): A piece of code function that explicitly performs a single task, such as click and exposure.OCP
): Maximize extensibility for user, such as you can replace the implementation of IDataCommit
interface data submission; providing receiver of dynamic config, you can integrate with your own config system.onCreate
onLayout
/onFling
/disPatchWindowFocusChanged
/dispatchVisibilityChanged
onGestureListener
accessibilityDelegate
Data collection is closely related to data analysis statistics, the collection Specification of different events is critical.
2101
button-1
key1=value,key2=value
2201
button-1
500
exposureIndex=1,key1=value
To add a dependency using Gradle
:
ile('com.tmall.android:viewtracker:1.0.0@aar')
When the application starts, call the following:
DK initilization
param mContext global context
param mTrackerOpen click event switch,yes means open
param mTrackerExposureOpen exposure event switch,yes means open
param printLog debug log switch,yes means open
kerManager.getInstance().init(mContext, mTrackerOpen, mTrackerExposureOpen, printLog);
Implement the IDataCommit interface to set up data submission.
s DataCommit implments IDataCommit {
...
// your implementation here
...
kerManager.getInstance().setCommit(new DataCommit());
CAUTION:
You should implement the interface IDataCommit
in production environment, because the collected log data need be saved on your own server-side.
Tag needs to be bound to the view that needs to be collected. Look at the following situations.
ng viewName = "button-1";
.setTag(TrackerConstants.VIEW_TAG_UNIQUE_NAME, viewName);
The extended information is bound to the view
Map<String, String> args = new HashMap<String, String>();
.put(key, value);
.setTag(TrackerConstants.VIEW_TAG_PARAM, args);
All the views of the page are required to be reported,you can look at the following code.
Map<String, String> args = new HashMap<String, String>();
.put(key, value);
indow().getDecorView().setTag(TrackerConstants.DECOR_VIEW_TAG_COMMON_INFO, args);
The server-side click event configuration JSON
format is as follows:
"masterSwitch": true, // Click event switch
"sampling":100 // Click event sampling rate
The server-side exposure event configuration JSON
format is as follows:
"masterSwitch": true, // exposure event switch
"timeThreshold": 100, // Valid exposure time threshold
"dimThreshold": 0.8, // Valid exposure area threshold
"exposureSampling": 100, // Exposure event sampling rate
"batchOpen":false //Batch report switch
After receiving the server configuration, the application sends the broadcast, and the SDK can receive and dynamically modify the configuration.
t click config from server-side
Object config = new JSONObject();
et exposure config from server-side
Object exposureConfig = new JSONObject();
end broadcast
nt intent = new Intent(ConfigReceiver.ACTION_CONFIG_CHANGED);
nt.putExtra(ConfigReceiver.VIEWTRACKER_CONFIG_KEY, config.toString());
nt.putExtra(ConfigReceiver.VIEWTRACKER_EXPOSURE_CONFIG_KEY, exposureConfig.toString());
ext.sendBroadcast(intent);
As each page has attached a TrackerFrameLayout
, in the UI main thread of the event processing methods have exposure time calculation operation, may have a certain impact on the page fluency, so the need for performance testing.
The test the buried two ways of uses the viewtracker
collection and the original code to submit for the FPS effect.
Android 5.0
5.32.0
HomePage
Index | Traditional Code | use ViewTracker
——— | ——————- | ————-
Number Of Test | 20 | 20
MAX_FPS | 60 | 63
MIN_FPS | 50 | 47
AVG_FPS | 54.81 | 53.90
Result: ViewTracker
has no significant effect on FPS
.
ViewTracker
is available under the Apache License 2.0. See the LICENSE file for more info.
Because the QR code of WeChat Group is valid for a short period , you can join us by search Sunshine07de
in WeChat.