CN112306723A - Operation information acquisition method and device applied to small program - Google Patents

Operation information acquisition method and device applied to small program Download PDF

Info

Publication number
CN112306723A
CN112306723A CN201910695924.0A CN201910695924A CN112306723A CN 112306723 A CN112306723 A CN 112306723A CN 201910695924 A CN201910695924 A CN 201910695924A CN 112306723 A CN112306723 A CN 112306723A
Authority
CN
China
Prior art keywords
applet
running
function
information
small program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910695924.0A
Other languages
Chinese (zh)
Inventor
迟潇潇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910695924.0A priority Critical patent/CN112306723A/en
Publication of CN112306723A publication Critical patent/CN112306723A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/324Display of status information
    • G06F11/327Alarm or error message display

Abstract

The invention discloses a running information acquisition method and device applied to an applet, and relates to the technical field of computers. One embodiment of the method comprises: in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet; analyzing the characteristics of the applet running function, and adding codes corresponding to the characteristics into the running function to obtain a first running function; and acquiring the running information of the small program through the first running function in the running process of the small program. According to the method, the running information in the running process of the small program is obtained by hijacking the original App and Page methods of the small program and inserting and obtaining the running information codes, and when the abnormal running condition of the small program occurs subsequently, the problem can be conveniently reproduced by a subsequent developer based on the running information.

Description

Operation information acquisition method and device applied to small program
Technical Field
The invention relates to the technical field of computers, in particular to a running information acquisition method and device applied to an applet.
Background
The difference in the actual operating environment of each applet results from the difference in the developers of the applet. Due to the design of the applet itself, the specification of the code, the logic of the service itself or the network status, an abnormal operation situation often occurs. For general exceptions, the execution of the whole system may be affected less, but for some special occasions, such as the first page, important pages cannot be opened, which may cause a larger effect.
Usually, the exceptions are difficult to find in the test stage, and need to be fed back by the user in actual use, for example, "open white screen", "point xx button does not react", "go to xx page", and the like, and the developer needs to analyze the reason of the applet running exception according to the exception information fed back by the user.
However, these exceptions occur at random times, and it may happen that the developers find the applet can operate normally when checking the exception. At this time, developers are required to inquire information such as the mobile phone model, the network state, the program version and the like of the user to reproduce the problems encountered by the user, the whole process is time-consuming and labor-consuming, and the obtained result is not necessarily accurate.
Aiming at the problem, an optimal mode is to provide an automatic monitoring system which can capture the abnormity encountered in the running process of the small program and relevant abnormal data, so that developers can accurately reproduce the problem. The exception monitoring mode used in the existing small program mainly comprises the following steps:
1) checking abnormal data related to each small program captured by a management background by relying on the management background provided by a third-party platform (such as WeChat, Baidu, Paibao, byte jumping and the like);
2) an exception capture code is inserted into a position where an exception is likely to occur in advance, for example, a try catch mode is used for exception capture, and then a background interface is called to report exception data.
In the process of implementing the invention, the inventor finds that the prior art has at least the following problems:
1) the abnormal data is stored in a server of a third-party platform and is not stored in a server of a developer developing a certain small program:
firstly, the subsequent checking of abnormal data needs to be carried out according to rules set by a third-party platform, and the problem of difficulty in obtaining exists;
secondly, only part of abnormal data may be displayed in a server of the third-party platform, and some abnormal data are not displayed to the outside, so that the problems of incomplete data and difficult reproduction required by abnormal operation of the small program are caused;
2) for exception capture code addition:
firstly, the abnormal position needs to be estimated, and the condition of code insertion abnormity or omission exists, so that the effect of completely capturing the abnormity cannot be achieved;
inserting abnormal capture codes into the business logic can pollute the existing business logic and lead to difficulty in updating and maintaining subsequent codes.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for acquiring running information applied to an applet, which can at least solve the problem in the prior art that information related to an exception is not easy to acquire.
In order to achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an operation information obtaining method applied to an applet, including:
in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet;
analyzing the characteristics of the applet running function, and adding codes corresponding to the characteristics into the running function to obtain a first running function;
and acquiring the running information of the small program through the first running function in the running process of the small program.
Optionally, the running function includes a first life cycle function, and the first life cycle function is a first life cycle function in the applet initialization stage;
adding a code corresponding to the feature to the running function to obtain a first running function, further comprising: adding an acquired configuration information code to the first life cycle function to obtain a second life cycle function;
before the obtaining of the running information of the applet through the first running function in the running process of the applet, the method further includes: and acquiring configuration information corresponding to the identifier of the applet through the second life cycle function.
Optionally, after the obtaining of the operation information of the applet through the first operation function, the method further includes: and sequencing the acquired running information according to the execution sequence of the running functions to generate a running record of the small program.
Optionally, after the obtaining of the running information of the applet, the method further includes: if the small program is monitored to be abnormal in operation, an abnormal monitoring function is triggered to capture abnormal information, and then the captured abnormal information and the operation information are uploaded.
Optionally, the uploading the captured abnormal information and the operation information includes: and reading a service address corresponding to the identifier of the applet, and transmitting the abnormal information and the running information to the service address.
In order to achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an operation information acquiring apparatus applied to an applet, including:
the function hijack module is used for determining and hijacking the running function of the applet according to the identification of the applet in the process of initializing the applet;
the code adding module is used for analyzing the characteristics of the applet running function and adding codes corresponding to the characteristics into the running function to obtain a first running function;
and the information acquisition module is used for acquiring the running information of the small program through the first running function in the running process of the small program.
Optionally, the running function includes a first life cycle function, and the first life cycle function is a first life cycle function in the applet initialization stage;
the code adding module is further configured to: adding an acquired configuration information code to the first life cycle function to obtain a second life cycle function; and acquiring configuration information corresponding to the identifier of the applet through the second life cycle function.
Optionally, the information obtaining module is further configured to: and sequencing the acquired running information according to the execution sequence of the running functions to generate a running record of the small program.
Optionally, the system further includes an anomaly monitoring module, configured to: if the small program is monitored to be abnormal in operation, an abnormal monitoring function is triggered to capture abnormal information, and then the captured abnormal information and the operation information are uploaded.
Optionally, the anomaly monitoring module is configured to: and reading a service address corresponding to the identifier of the applet, and transmitting the abnormal information and the running information to the service address.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an operation information acquisition electronic device applied to an applet.
The electronic device of the embodiment of the invention comprises: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize any one of the operation information acquisition methods applied to the small program.
To achieve the above object, according to a further aspect of the embodiments of the present invention, there is provided a computer-readable medium on which a computer program is stored, the program implementing any of the above-described operation information acquisition methods applied to an applet when executed by a processor.
According to the scheme provided by the invention, one embodiment of the invention has the following advantages or beneficial effects: the method comprises the steps of hijacking the original App and Page of the applet, inserting and acquiring the running information code to acquire running information in the running process of the applet, and facilitating follow-up developers to reproduce problems based on the running information when the applet runs abnormally in the follow-up process.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a main flow diagram of an operation information acquisition method applied to an applet according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of an alternative method for acquiring running information applied to an applet according to an embodiment of the present invention;
fig. 3 is a schematic flow chart of another alternative method for acquiring running information applied to an applet according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating an alternative method for acquiring running information of an applet according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of error reporting information code displayed in a developer tool provided by an embodiment of the present invention;
fig. 6 is a code diagram for splicing the exception information and the operation information into json data according to the embodiment of the present invention;
fig. 7 is a flowchart illustrating an operation information acquisition method, which is specifically applied to an applet, according to an embodiment of the present invention;
fig. 8 is a schematic diagram of main blocks of an operation information acquisition apparatus applied to an applet according to an embodiment of the present invention;
FIG. 9 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
FIG. 10 is a block diagram of a computer system of a mobile device or server suitable for use in implementing embodiments of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the applet according to the embodiment of the present invention refers to an applet in a third-party platform such as WeChat, Baidu, byte jumping, QQ browser, Paibao, and the like, but not to an application program in an operating system (different scripts and lifecycle designs are embedded in different application programs). The invention is mainly explained in detail by taking small programs in WeChat as examples.
Referring to fig. 1, a main flowchart of an operation information obtaining method applied to an applet according to an embodiment of the present invention is shown, including the following steps:
s101: in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet;
s102: analyzing the characteristics of the applet running function, and adding codes corresponding to the characteristics into the running function to obtain a first running function;
s103: and acquiring the running information of the small program through the first running function in the running process of the small program.
Problems that arise during the use of an applet by a user often arise when the user accidentally goes to a step. However, for the problem reproduction performed by the subsequent developer, all the steps operated by the user need to be repeated, so the invention mainly considers how to acquire the specific information of the user for operating the applet.
The applet runs according to the lifecycle, and thus must enter the callback function of the lifecycle. The invention injects corresponding codes into each life cycle function of the small program in the initial stage of the small program so as to obtain the operation information of the small program in each life cycle of a user, namely the operation information of the small program responding to the operation of the user.
In the above embodiment, in step S101, for the WeChat applet, there are 2 lifecycle functions:
1) the lifecycle of the App comprises three lifecycle callback functions of onLannch, onShow and onHide and an oneror abnormal monitoring function; the life cycle function is a function which can be automatically executed by a corresponding instance at a certain time point, is generally well defined before use, and the calling sequence is unrelated to the writing sequence of a developer in the code; wherein App is used to describe the entire application;
2) the lifecycle of Page, including five lifecycle callback functions of onLoad, onReady, onShow, onHide and onUnload and event handling function; wherein, Page represents a Page of application, and is responsible for Page display and interaction.
The life cycle of APP and the life cycle of Page are mutually crossed, and although the life cycle of Page has no oneerror function, the oneerror function can be relied on for monitoring abnormal information.
For step S102, the added code may be "acquire running information" code for acquiring running information in each lifecycle that the applet experiences during running.
The operating functions in different life cycles of the applet have different characteristics, so that the acquired operating information is different, and therefore, although the operating functions in different life cycles are all codes for acquiring the operating information, codes with characteristics of different formats, numerical values and the like can be added to the operating functions in different life cycles to obtain the first operating function after the codes are added.
For example, onLaunch is used to listen to applet initialization, so code 1 corresponding to this feature may be added to obtain the applet configuration information at this stage, as described with particular reference to subsequent fig. 2. onShow is used to trigger when an applet starts or goes from background to foreground, so code 2 corresponding to this feature can be added to interpret the applet switch normal information.
It should be noted that the oneerror function is mainly used for monitoring the running process of the applet in each life cycle, and is triggered when an exception occurs. The oneror function usually has no abnormal operation, so the invention can choose not to add codes in the function, and the lifecycle function and the event processing function except the oneror function are collectively called as the operation function. However, if code is added to the oneror function, all lifecycle functions including oneror are called run functions.
And for the first operation function, the original code and the added code are combined. For example, an applet that introduces an SDK (Software Development Kit) adds code to obtain login information of a user when initializing an onLaunch, but if not merged, the onLaunch function in that SDK will overwrite the onLaunch function of the importing party, resulting in affecting the original business logic.
Further, in order not to affect the execution logic of the original code of the applet, the APP and Page methods of the original applet need to be saved and assigned to originApp variables. Therefore, the codes of the whole program can not change when the information is changed, and only the information state when the current function is triggered can be obtained.
For step S103, by adding a code to each execution function of the applet, the execution order of the applet execution functions, system information, geographical location, network information, and other execution information of the user can be obtained.
An object may be created to store the running information, including the current time, the name of the current legal in front, the Page path, the Page parameters, the scene number, the method source (the from field is used to distinguish the same name method in App and Page, for example, there is only onShow method, from: ' App ' in App, from: ' Page ' in Page ').
When the small program runs to the running function, the object is placed into the thread array, and the finally obtained array comprises the execution sequence of the running function by the user and the information of the small program running in response to the user operation.
Further, the thread array is usually created during the startup of the applet, so as to record the actual running process of the applet. In the initial phase, the array is empty.
In addition, the user has a certain operation sequence for the operation function, and the operation information can be sequenced according to the sequence to generate an operation record associated with the user, so that subsequent operators can conveniently reproduce problems according to the operation record.
For example, the user operation has A, B, C, B four steps, but a bug appears when repeating step B, and a developer needs to perform problem reproduction in this order to analyze the cause of the operation abnormality when repeating step B.
According to the method provided by the embodiment, the running information is conveniently recorded in real time in the running process of the applet by adding the codes to the running function of the applet, so that an information basis is provided for problem reproduction of follow-up developers; when the system is used, only the SDK file needs to be copied into the applet project, the file is introduced into a logic layer App Service (a JavaScript engine is used for providing the operating environment of a JavaScript code of a developer and the special function of the applet) and parameters are configured, other codes do not need to be added, the original code of the applet cannot be polluted, and the later-period code updating and maintenance are facilitated.
Referring to fig. 2, a schematic flow chart of an optional operation information obtaining method applied to an applet according to an embodiment of the present invention is shown, including the following steps:
s201: in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet; the operation functions comprise three lifecycle functions of onLannch, onShow and onHide;
s202: adding an acquired configuration information code and an acquired operation information code into an onLannch life cycle function, and respectively adding an acquired operation information code into two life cycle functions of onShow and onHide;
s203: acquiring configuration information corresponding to the identification of the applet and running information of the applet in the onLanch lifecycle through the onLanch lifecycle function added with the code;
s204: respectively acquiring running information of the applet in the corresponding life cycle through two life cycle functions of onShow and onHide after the code is added;
s205: and sequencing the acquired running information according to the execution sequence of the running functions to generate a running record of the small program.
In the above embodiment, for step S205, refer to the description of step S103 shown in fig. 1, and no further description is provided herein.
In the above embodiment, for step S201, the execution environment of the applet is divided into a rendering layer and a logic layer.
Each applet needs to call an App method in a logic layer App Service to register an applet instance, and receives an Object parameter so as to bind a life cycle callback function, abnormal monitoring, a page non-existence monitoring function and the like.
TABLE 1 Object parameter description
Figure BDA0002149359420000101
The whole applet has only one App instance and is shared by all pages. The developer can acquire a globally unique App example through a getApp () method, acquire data on the App or call a function registered on the App by the developer.
With respect to steps S202 and S203, it can be seen from table 1 that onLaunch is mainly used for initialization of the listening applet.
For an onLannch lifecycle callback function in Object parameters of the App method, corresponding configuration information with a true field can be obtained by reading a configuration table config; such as system information, geographic location, network environment, applet unique identification, user unique identification, etc.
For geographical location information, some service scenarios are distinguished according to geographical locations. For example, xx small programs, merchants of Beijing stations are different from merchants of Shanghai stations, merchants of X areas and merchants of Y areas of the Beijing stations are different, some business logics can be triggered only by the Beijing stations, and some logics can be triggered only by the Shanghai stations, and the information can be conveniently checked through geographical positions.
In addition to the above information, the configuration information may also include version information of a third-party platform where the applet is located, for example, a version number of the wechat, and after the version of the wechat is updated, if the applet is opened again, the updated version number is obtained.
The obtained configuration information may be stored in a local corresponding field, such as system data systemlnfo, geographical location data locationInfo, for facilitating subsequent reading.
For steps S203 and S204, an abnormal operation condition may occur in each lifecycle of the applet, such as a system bug in an initialization stage, and a bug when switching from a foreground to a background.
Therefore, the operation information code needs to be added to all three lifecycle functions of onLaunch, onShow and onHide in App to obtain the information state when the applet operates to the current function; such as the order of execution of the programs in the applet, system information, exception information, geographical location and network information, etc.
The method provided by the embodiment can be used for adding an acquired configuration information code besides an acquired operation information code for the applet App method so as to obtain information such as system information, a geographic position, a network environment, an applet unique identifier and a user unique identifier, and provides a data basis for problem reproduction of follow-up developers by combining operation information.
Referring to fig. 3, a schematic flow chart of another optional operation information obtaining method applied to an applet according to an embodiment of the present invention is shown, including the following steps:
s301: in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet; the operation function comprises five life cycle tempering and event processing functions of onLoad, onReady, onShow, onHide and onUnload;
s302: adding and acquiring an operation information code into the operation function to obtain a first operation function;
s303: in the running process of the small program, obtaining the running information of the small program through the first running function;
s304: and sequencing the acquired running information according to the execution sequence of the running functions to generate a running record of the small program.
In the above embodiment, for step S304, refer to the description of step S103 shown in fig. 1, and no further description is provided herein.
In the above embodiment, for step S301, for each Page in the applet, a Page method registration Page example needs to be called in a JavaScript file corresponding to the Page.
TABLE 2 Page parameters
Properties Description of the invention
data Initial data of page
onLoad Lifecycle function-monitor page loading
onReady Life cycle function-monitoring page primary rendering completion
onShow Life cycle function-monitor page display
onHide Life cycle function-monitoring page hiding
onUnload Life cycle function-monitor page unload
onPullDownRefresh Page-related event handling function-listening for user drop-down actions
onReachBottom Processing function of page pull bottom-touching event
In step S302, in order not to affect the original code execution logic, the original Page method needs to be saved, and the original Page method is assigned to the originPage variable. And inserting an acquisition operation information code into each function, transmitting an Object parameter of the added code to an originPage method, and completing the insertion of the acquisition program execution sequence code in the Page.
In step S303, a Page in the applet is registered by the Page method, an Object parameter is received, and initial data, a lifecycle callback, an event handling function, and the like of the Page are specified. And (4) hijacking the transfer method of the Page Object parameter, and recording the running process of the applet.
As shown in fig. 1 and fig. 2, an object may be created to store basic information of the current page running process, including: current time, current function name, current page path, current page parameters, scene number, method source.
And the objects are put into the thread array, so that the subsequent problems can be conveniently reproduced. The obtained running information can also be sorted and combined according to the execution sequence of the running functions.
The method provided by the embodiment is directed at the applet page, and the operation record of the user operating the applet page can be obtained by adding the operation information code into the operation function, so that a data basis is provided for the reproduction of the subsequent problems.
Referring to fig. 4, a schematic flow chart of still another optional operation information obtaining method applied to an applet according to an embodiment of the present invention is shown, including the following steps:
s401: in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet;
s402: adding and acquiring an operation information code into the operation function to obtain a first operation function;
s403: in the running process of the small program, obtaining the running information of the small program through the first running function;
s404: arranging the acquired running information in sequence according to the execution sequence of the running functions to generate a running record of the small program;
s405: if the small program is monitored to be abnormal in operation, triggering an abnormal monitoring function to capture abnormal information;
s406: and reading a service address corresponding to the identifier of the applet, and transmitting the abnormal information and the running record to the service address.
In the above embodiment, the steps S401 to S404 can be described with reference to fig. 1 to 3, and are not described again here.
In the above embodiment, in step S405, the oneerror function is triggered when a script exception occurs in the applet or when an API (Application Programming Interface) call fails.
An exception is captured in the oneerror method in the App Object parameter, and the retrieved exception information is stored in the error field locally. The abnormality information here may include: the program self error-reporting prompt, the abnormal occurrence time, the page where the abnormal occurrence occurs and the page parameter where the abnormal occurrence occurs.
For example, calling the property of an unclaimed variable results in an error:
Figure BDA0002149359420000131
error information displayed in the developer tool is shown in fig. 5.
The page has no oneerror function, and only records the running sequence of the small programs. Given that the App's lifecycle and the pages' lifecycles are interleaved, for example, the first page written in the pages field is the first page of the applet, i.e., the first page seen by the open applet. Therefore, the anomaly monitoring operation can be performed by oneerror in App.
For step S406, the server address config, serverurl configured in the config is read, so as to add and report all information (exception information, running information, configuration information, etc.) to the server address, for example, the server address of the developer (and the third party platform).
For the convenience of subsequent processing, all the obtained information may be spliced into json format data, and then sent to the server config.serverul through a post request, as shown in fig. 6.
The acquired information cannot be independent of the code, and the information needs to be stored in a variable form. The data are converted into json format data, and finally merged into a json object to be sent to the server address, and the whole method can be realized based on javascript.
In addition, the information can be provided for the access person in the form of an SDK, and the file is introduced and the config configuration is added when the information is used.
According to the method provided by the embodiment, when an abnormal condition occurs in the running of the small program, the abnormal information capturing operation can be triggered; the captured abnormal information and the operation record of the user operation are sent to the applet platform management background, and meanwhile, the server address of the applet developer can also be sent to reduce communication between the applet developer and the applet platform.
Referring to fig. 7, a flowchart of an operation information obtaining method specifically applied to an applet according to an embodiment of the present invention is shown, including the following steps:
s701: in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet; the operation function comprises three lifecycle callback functions of onLaunch, onShow and onHide in the registered applet, and five lifecycle callback and event processing functions of onLoad, onReady, onShow, onHide and onUnload in the applet page;
s702: adding the acquired configuration information code and the acquired operation information code into the onLannch life cycle function, and adding the acquired operation information code into the other functions;
s703: reading a configuration table of the applet through the onLannch added with the code to obtain configuration information of the applet;
s704: respectively acquiring running information in the running process of the applet through three lifecycle callback functions of onLannch, onShow and onHide after the code is added;
s705: adding an acquired running information code into five life cycle call-back and event processing functions of onLoad, onReady, onShow, onHide and onUnload;
s706: acquiring running information in the running process of the small program page through five life cycle reconciliation and event processing functions of onLoad, onReady, onShow, onHide and onUnload after the code is added;
s707: arranging the acquired running information in sequence according to the execution sequence of the running functions to generate a running record of the small program;
s708: if the small program is monitored to be abnormal in operation, triggering an abnormal monitoring function to capture abnormal information;
s709: and reading a service address corresponding to the identifier of the applet, and transmitting the abnormal information and the running record to the service address.
The SDK is supplemented, and the SDK, import error report from '/error report.js' is introduced into an applet logic layer App Service file.
Configuring a config parameter in the App Service. The currently configurable parameters include, but are not limited to, the following fields, and the extension may continue subsequently. Configuration example:
errorReport.config={
serverUrl:'https://m.jd.com/errorReport'
true,// true optionally with true
location:false,
systemInfo:false,
appid:true,
openid:true,
secrect:'ahskldkjf133'
}
Table 3 example of configuration information
Figure BDA0002149359420000161
Compared with the prior art, the method provided by the embodiment of the invention has the following beneficial effects:
1) the method comprises the steps of hijacking the original App and Page methods of the applet, and inserting and acquiring an operation information code in functions of onLauch, onShow, onHide and Page method parameters in App method parameters to acquire operation information in the running process of the applet;
2) for the applet app method, a configuration information code can be added to the onLaunch function in the initialization process to obtain configuration information when the applet runs;
3) based on the 1) and 2), when the situation of the abnormal operation of the small program occurs subsequently, the problem can be conveniently reproduced by a developer based on the operation information;
4) monitoring the abnormity in the running process of the small program through an oneror function, realizing 100% abnormity capture and avoiding embedding points;
5) the third-party platform usually cannot process the abnormal problem of the applet and usually needs the applet developer to repair the problem, so that the obtained abnormal information, the applet running information and the configuration information are transmitted to the service end of the applet, and the developer can conveniently obtain all information related to the exception of the applet;
6) when the method is used, only the SDK file needs to be copied into the applet project, the file is introduced into the logic layer AppService and parameters are configured, other codes do not need to be added, the original codes of the applet cannot be polluted, and the updating and the maintenance of the codes at the later stage are facilitated.
Referring to fig. 8, a schematic diagram of main modules of an operation information obtaining apparatus 800 applied to an applet according to an embodiment of the present invention is shown, including:
a function hijacking module 801, configured to determine and hijack an operating function of an applet according to an identifier of the applet in a process of initializing the applet;
a code adding module 802, configured to analyze a feature of the applet running function, and add a code corresponding to the feature to the running function to obtain a first running function;
an information obtaining module 803, configured to obtain, through the first operation function, operation information of the applet in an operation process of the applet.
In the implementation device of the present invention, the operation function includes a first lifecycle function, and the first lifecycle function is a first lifecycle function in the applet initialization stage;
the code adding module 802 is further configured to: adding an acquired configuration information code to the first life cycle function to obtain a second life cycle function; and acquiring configuration information corresponding to the identifier of the applet through the second life cycle function.
In the apparatus for implementing the present invention, the information obtaining module 803 is further configured to: and sequencing the acquired running information according to the execution sequence of the running functions to generate a running record of the small program.
The apparatus for implementing the present invention further includes an anomaly monitoring module 804 (not shown in the figure), configured to: if the small program is monitored to be abnormal in operation, an abnormal monitoring function is triggered to capture abnormal information, and then the captured abnormal information and the operation information are uploaded.
In the device for implementing the present invention, the anomaly monitoring module 804 is configured to: and reading a service address corresponding to the identifier of the applet, and transmitting the abnormal information and the running information to the service address.
In addition, the detailed implementation of the device in the embodiment of the present invention has been described in detail in the above method, so that the repeated description is not repeated here.
FIG. 9 illustrates an exemplary system architecture 900 to which embodiments of the invention may be applied.
As shown in fig. 9, the system architecture 900 may include end devices 901, 902, 903, a network 904, and a server 905 (by way of example only). Network 904 is the medium used to provide communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 901, 902, 903 to interact with a server 905 over a network 904 to receive or send messages and the like. Various communication client applications can be installed on the terminal devices 901, 902, 903.
The terminal devices 901, 902, 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 905 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 901, 902, 903. The background management server can analyze and process the received data such as the product information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that the operation information acquiring method applied to the applet provided by the embodiment of the present invention is generally executed by the server 905, and accordingly, the operation information acquiring apparatus applied to the applet is generally disposed in the server 905.
It should be understood that the number of terminal devices, networks, and servers in fig. 9 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 10, a block diagram of a computer system 1000 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 10 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 10, the computer system 1000 includes a Central Processing Unit (CPU)1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM 1003, various programs and data necessary for the operation of the system 1000 are also stored. The CPU 1001, ROM 1002, and RAM 1003 are connected to each other via a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output section 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication part 1009 and/or installed from the removable medium 1011. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 1001.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a function hijack module, a code adding module and an information acquisition module. The names of these modules do not in some cases constitute a limitation to the modules themselves, and for example, the information acquisition module may also be described as an "applet operation information acquisition module".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet;
analyzing the characteristics of the applet running function, and adding codes corresponding to the characteristics into the running function to obtain a first running function;
and acquiring the running information of the small program through the first running function in the running process of the small program.
According to the technical scheme of the embodiment of the invention, compared with the prior art, the method has the following beneficial effects:
1) the method comprises the steps that an operation information code is inserted and acquired through hijacking an original App and a Page method of the applet, so that operation information in the applet operation process is acquired;
2) for the applet app method, a configuration information code can be added to the onLaunch function in the initialization process to obtain configuration information when the applet runs;
3) based on the 1) and 2), when the situation of the abnormal operation of the small program occurs subsequently, the problem can be conveniently reproduced by a developer based on the operation information;
4) monitoring the abnormity in the running process of the small program through an oneror function, realizing 100% abnormity capture and avoiding embedding points;
5) the third-party platform usually cannot process the abnormal problem of the applet and usually needs the applet developer to repair the problem, so that the obtained abnormal information, the applet running information and the configuration information are transmitted to the service end of the applet, and the developer can conveniently obtain all information related to the exception of the applet;
6) when the method is used, only the SDK file needs to be copied into the applet project, the file is introduced into the logic layer App Service, parameters are configured, other codes do not need to be added, the original codes of the applet cannot be polluted, and updating and maintenance of the codes at the later stage are facilitated.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (8)

1. An operation information acquisition method applied to an applet is characterized by comprising the following steps:
in the process of initializing the applet, determining the running function of the applet and hijacking according to the identification of the applet;
analyzing the characteristics of the applet running function, and adding codes corresponding to the characteristics into the running function to obtain a first running function;
and acquiring the running information of the small program through the first running function in the running process of the small program.
2. The method of claim 1, wherein the run function comprises a first lifecycle function, the first lifecycle function being a first lifecycle function in the applet initialization phase;
adding a code corresponding to the feature to the running function to obtain a first running function, further comprising:
adding an acquired configuration information code to the first life cycle function to obtain a second life cycle function;
before the obtaining of the running information of the applet through the first running function in the running process of the applet, the method further includes:
and acquiring configuration information corresponding to the identifier of the applet through the second life cycle function.
3. The method according to claim 1, wherein after obtaining the operating information of the applet through the first operating function, the method further comprises:
and sequencing the acquired running information according to the execution sequence of the running functions to generate a running record of the small program.
4. The method according to claim 1 or 3, further comprising, after the obtaining the running information of the applet:
if the small program is monitored to be abnormal in operation, an abnormal monitoring function is triggered to capture abnormal information, and then the captured abnormal information and the operation information are uploaded.
5. The method of claim 4, wherein uploading the captured exception information and the run information comprises:
and reading a service address corresponding to the identifier of the applet, and transmitting the abnormal information and the running information to the service address.
6. An operation information acquisition apparatus applied to an applet, comprising:
the function hijack module is used for determining and hijacking the running function of the applet according to the identification of the applet in the process of initializing the applet;
the code adding module is used for analyzing the characteristics of the applet running function and adding codes corresponding to the characteristics into the running function to obtain a first running function;
and the information acquisition module is used for acquiring the running information of the small program through the first running function in the running process of the small program.
7. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
8. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201910695924.0A 2019-07-30 2019-07-30 Operation information acquisition method and device applied to small program Pending CN112306723A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910695924.0A CN112306723A (en) 2019-07-30 2019-07-30 Operation information acquisition method and device applied to small program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910695924.0A CN112306723A (en) 2019-07-30 2019-07-30 Operation information acquisition method and device applied to small program

Publications (1)

Publication Number Publication Date
CN112306723A true CN112306723A (en) 2021-02-02

Family

ID=74485214

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910695924.0A Pending CN112306723A (en) 2019-07-30 2019-07-30 Operation information acquisition method and device applied to small program

Country Status (1)

Country Link
CN (1) CN112306723A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338813A (en) * 2022-01-07 2022-04-12 挂号网(杭州)科技有限公司 Network request display method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515248A (en) * 2008-02-21 2009-08-26 国际商业机器公司 Tracking method and tracking system for object-oriented program
US20140380282A1 (en) * 2013-06-20 2014-12-25 Microsoft Corporation Monitoring mobile application performance
CN106778235A (en) * 2016-11-24 2017-05-31 北京瑞星信息技术股份有限公司 Linux file operation control method and device
CN109388537A (en) * 2018-08-31 2019-02-26 阿里巴巴集团控股有限公司 Operation information tracking, device and computer readable storage medium
CN109976973A (en) * 2019-02-19 2019-07-05 深圳点猫科技有限公司 Abnormality monitoring method and electronic equipment on a kind of small routine line

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515248A (en) * 2008-02-21 2009-08-26 国际商业机器公司 Tracking method and tracking system for object-oriented program
US20140380282A1 (en) * 2013-06-20 2014-12-25 Microsoft Corporation Monitoring mobile application performance
CN106778235A (en) * 2016-11-24 2017-05-31 北京瑞星信息技术股份有限公司 Linux file operation control method and device
CN109388537A (en) * 2018-08-31 2019-02-26 阿里巴巴集团控股有限公司 Operation information tracking, device and computer readable storage medium
CN109976973A (en) * 2019-02-19 2019-07-05 深圳点猫科技有限公司 Abnormality monitoring method and electronic equipment on a kind of small routine line

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338813A (en) * 2022-01-07 2022-04-12 挂号网(杭州)科技有限公司 Network request display method and device, electronic equipment and storage medium
CN114338813B (en) * 2022-01-07 2023-12-01 挂号网(杭州)科技有限公司 Display method and device of network request, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
WO2020181839A1 (en) Page data testing method, apparatus, computer device, and storage medium
US9183072B1 (en) Error troubleshooting using a correlated knowledge base
CN107644075B (en) Method and device for collecting page information
CN110659210A (en) Information acquisition method and device, electronic equipment and storage medium
CN110688305B (en) Test environment synchronization method, device, medium and electronic equipment
CN114328250A (en) Automatic self-checking method, medium and device for software system
CN108228611B (en) Document information copying method and device
CN112306723A (en) Operation information acquisition method and device applied to small program
CN112306826A (en) Method and apparatus for processing information for terminal
CN112241362A (en) Test method, test device, server and storage medium
CN114356290A (en) Data processing method and device and computer readable storage medium
CN114428815A (en) Data storage method and device, electronic equipment and computer readable medium
CN113110846A (en) Method and device for acquiring environment variable
CN113094048A (en) Data display rule determining method, display method, device, equipment and medium
CN113760631A (en) Page loading duration determination method, device, equipment and storage medium
CN117130945B (en) Test method and device
CN113760723B (en) Business process debugging method and device
CN111026466A (en) File processing method and device, computer readable storage medium and electronic equipment
CN112261072A (en) Service calling method, device, equipment and storage medium
CN110489341B (en) Test method and device, storage medium and electronic equipment
CN117762812A (en) Method and device for processing log information
CN117472428A (en) Intranet APP control method, electronic equipment and storage medium
CN117573130A (en) Code processing method, device, electronic equipment and storage medium
CN115203056A (en) SDK test method, medium and device
CN111740876A (en) Application program, test method, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination