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.
Support multiple scenes, e.g. slides, automatic scrolling, window switch, tab switch, page jump, front and back switch.
Support extension, e.g. data submission, customization for the exposure rules, sampling rate, etc.
0.2 Design Principles
Keep It Simple, Stupid(KISS) Principle: Avoid code complexity, class name, package name etc have good readability.
Single Responsibility Principle(SRP): A piece of code function that explicitly performs a single task, such as click and exposure.
Open/Closed Principle(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.
After receiving the server configuration, the application sends the broadcast, and the SDK can receive and dynamically modify the configuration.
//get click config from server-side
JSONObject config = new JSONObject();
// get exposure config from server-side
...
JSONObject exposureConfig = new JSONObject();
// send broadcast
...
Intent intent = new Intent(ConfigReceiver.ACTION_CONFIG_CHANGED);
intent.putExtra(ConfigReceiver.VIEWTRACKER_CONFIG_KEY, config.toString());
intent.putExtra(ConfigReceiver.VIEWTRACKER_EXPOSURE_CONFIG_KEY, exposureConfig.toString());
context.sendBroadcast(intent);
4 Performance Testing
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.
4.1 The Goal Of Testing
The test the buried two ways of uses the viewtracker collection and the original code to submit for the FPS effect.
4.2 The Environment Of Testing
Phone Model: xiaomi2
System Version: Android 5.0
App: Tmall Android
App Version: 5.32.0
Page: HomePage
4.3 The Results Of Testing
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: ViewTrackerhas no significant effect on FPS.
ViewTracker-Android
0 Abstract
ViewTrackeris 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.0.1 Functions
Android&iOS(the github repo ofiOSSDK).0.2 Design Principles
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 ofIDataCommitinterface data submission; providing receiver of dynamic config, you can integrate with your own config system.0.3 Basic Architecture
0.4 Flow Chart
1 Life-Cycle
1.1 System Properties
onCreateonLayout/onFling/disPatchWindowFocusChanged/dispatchVisibilityChangedonGestureListener1.2 View Properties
accessibilityDelegate2 Collection Specification
Data collection is closely related to data analysis statistics, the collection Specification of different events is critical.
2.1 The Specification Of Click Event
2101button-1key1=value,key2=value2.2 The Specification Of Exposure Event
2201button-1500exposureIndex=1,key1=value3 Developer Guide
3.1 Dependency configuration
To add a dependency using
Gradle:3.2 Initialization
3.2.1 Startup Initialization(required)
When the application starts, call the following:
3.2.2 Data Submission(optional)
Implement the IDataCommit interface to set up data submission.
CAUTION:
You should implement the interface
IDataCommitin production environment, because the collected log data need be saved on your own server-side.3.3 Tag Binding
Tag needs to be bound to the view that needs to be collected. Look at the following situations.
3.3.1 The Tag Of Click & Exposure(required)
3.3.2 The Tag Of Extended Information(optional)
The extended information is bound to the view
3.3.3 The Tag Of Page Common Information(optional)
All the views of the page are required to be reported,you can look at the following code.
3.3.4 The Tag Of Run-time Information(optional)
The server-side click event configuration
JSONformat is as follows:The server-side exposure event configuration
JSONformat is as follows:After receiving the server configuration, the application sends the broadcast, and the SDK can receive and dynamically modify the configuration.
4 Performance Testing
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.4.1 The Goal Of Testing
The test the buried two ways of uses the
viewtrackercollection and the original code to submit for the FPS effect.4.2 The Environment Of Testing
Android 5.05.32.0HomePage4.3 The Results Of Testing
ViewTrackerResult:
ViewTrackerhas no significant effect onFPS.5 Authors
6 License
ViewTrackeris available under the Apache License 2.0. See the LICENSE file for more info.7 WeChat Group
Because the QR code of WeChat Group is valid for a short period , you can join us by search
Sunshine07dein WeChat.