Business scenarios:
To solve the various behaviors that need to be reported when users browse the application. Including: page entry/exit report, element exposure, element click. The basic reporting capabilities provided by the underlying reporting library are further encapsulated in the upper layer based on service features.
Overall framework:
Basic Report Library:
Based on the basic report library encapsulated by Bencon, all the upper reporting methods call the report method of this basic library. You can also set basic parameters and user information.
Reported data structure:
- SpmArr is the key to page entry and exit. It maintains a stack of pages into which new page elements are pushed with each entry. Note: the page stack is only pushed, not unpushed.
- SpmTimer is a timer for the page dwell time. The time is reset to the current time, and the statistical period is displayed and reported.
Public method of burying point reporting:
- PageEnterEvent Reports the page entry
- MixinPageEnterEvent Reports page entry
- The pageLeaveEnter page is reported
Note:
(1) Distinction between pageEnterEvent and mixinPageEnterEvent: mixinPageEnterEvent adds a page element to the page stack; PageEnterEvent changes the SPM of the first element in the page stack to the value passed in. The reason is that some pages may be reused by the same component (e.g. The login and registration pages will reuse the same component, only distinguishable in style), the SPM of the page needs to be determined after entering a certain logical judgment, providing pageEnterEvent can be manually reported after determining the SPM, without destroying the order of elements in the global maintenance page stack.
Flowchart of global page entry and exit:
Listen globally for wxShow, Wxhide, and WxUnload lifecycle hook functions.
Directive methods used in pages:
- Click Click event reporting. Use method: v-report.click.
- Exposure to the public. Methods of use: V-report.exposure. Not only will a single point of exposure be reported as soon as an element appears, but it will also be reported as long as the element is hidden.
- Goto Report the jump to the element page.