With the advent of the era of big data, data mining has become more and more important.Front end point buried as a more mature data access method is widely used.Currently buried point is divided into two ways, and will come with no points.Sets a buried point is easy to understand, is called the SDK API, in the code inserts buried point related code, user behavior acquisition.Because we are in development projects, buried point are manually, every business needs change to buried point everywhere, and no burial code, which does not need to be manually inserted into the code, just prior to related configuration, the SDK automatically collect user behavior, avoided because of the change of demand, and buried the great degree error causes such as to bury some heavy and complicated work.This paper mainly introduces the technical implementation of codeless capture technology.
The Implementation Process of Codeless Capture
1. Visual view circle, the page will appear floating circle, drag the circle to want to configure the control of events, play box will pop up input event.
2. In the previous step play box type in the name of the event the custom, the name will and view viewPath bind.ViewPath is the unique identifier view, in the heart of the below in detail.
3. The user clicks on the controls, whether controls binding events, such as binding events to upload.
The Technical Points in the Process
The Implementation of Visual View Selection
Custom UIWindow subclass, as suspended small circle, add UIPanGestureRecognizer gestures, according to the displacement of hand gestures, to set the displacement of suspension box.Gestures stops for floating window center coordinates.
Traverse the child views on the main window, find the window containing the suspension center and can respond to user interaction of the layer view, is the user can select the view.
Refer to iOS control message transmission chain, a core method.UIView hitTest: (CGPoint) point withEvent: UIEvent *) event.This API automatically traverse child views, find a point of view, the event nil.Since the event parameters is nil, eventually found the view is not necessarily can respond to user gestures view, if you can’t response to traverse the father view, until you find the view can respond to user behavior.
Selecting the View Binding Events
View a unique identifier viewPath generated, the above steps have been given a select the view.How do you determine the view viewPath is key.ViewPath need the whole application only, just can be the difference between different events.Because it is no, so can attribute to analysis from the view itself.We can put the App’s understanding of the concept of spanning tree view structure, root node of the tree is UIWindow, one of the branches of the tree is composed of UIViewController and UIView, leaf nodes are UIView.Then from the root node to leaf node path can be seen as the only one.Also is the viewPath view.Achieve logic, introduces below viewPath consists of two parts, the first part is a node path, another part of the matching node index.Node path is made up of each node Class patchwork, node index, index in a node in the parent node, such as child views in the parent view’s subviews array subscript.This is the logic diagram of the traverse the nodes.
Index of computing nodes, this step, there is a special view to note, reusable view index is associated with a data source, such as UITableViewCell, such a view of the index cannot use the parent view’s subviews subscript instead, you should use subscript representative of data sources, such as cell indexPath. Section: indexPath. Row.Here is a simple view and reusable view viewPath example.TestViewController UIView – UIButton & 0-0-0 and TableViewController UITableView – UITableViewCell & 0-0-1-0.
How to detect the user triggers the binding event ID view is also the point, the use of core technology is the Method the runtime Swizzle.To introduce the following according to different types of controls, how to hook the corresponding method.
1. The UIControl type control hook – (void) sendAction (SEL) to: (id) target forEvent: UIEvent *) event
2. UIScrollView, UITextView UITableView, UICollectionView types of controls, hook – (void) setDelegate: (id first) the delegate method, and then the hooks to collect event agent method, such as textViewDidBeginEditing, tableview: (UITableView *) tableview didSelectRowAtIndexPath: (indexPath NSIndexPath *), etc.
3. View the hooks with gesture events – (void) addGestureRecognizer method, and add new objects to gesture in the method to realize the target and action, – (void) addTarget (id) target action (SEL) action.
Codeless capture technology is the analysis of the above points, first of all, through visual select the view to need binding events, and generate a unique identifier viewPath, through the hook system control method, get the user’s view, the views generated viewPath list with local events, events will upload viewPath corresponding than success.