Method, device, processor, storage medium and program product for adding embedding points
By converting executable files to abstract syntax trees and adding tracking call functions based on preset configurations, the method addresses the limitation of existing tracking technologies, enabling efficient and accurate tracking point addition in front-end page code.
Patent Information
- Application Number
- CN202111358296.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-16
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2041-11-16
AI Technical Summary
Existing tracking technologies, such as those described in CN110737589A, are limited in their ability to track front-end page code, particularly for Android and iOS platforms, and do not efficiently add tracking points to front-end pages.
A method involving converting executable files to abstract syntax trees, traversing these trees to identify function declarations, and adding tracking call functions based on preset configurations, including target function arrays and annotation texts, to automatically embed tracking points in front-end page code.
This method enables efficient and accurate addition of tracking points without manual intervention, ensuring comprehensive tracking and flexible reporting rules, improving data collection efficiency and accuracy.
Smart Images

Figure CN114047924B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, processor, storage medium and program product for adding embedding points. Background Art
[0002] Tracking analysis is a common data collection method for website analysis. Tracking is a good private deployment data collection method, which is divided into three methods: primary, intermediate, and advanced. The purpose of tracking is to obtain basic user information and behavior and track the use of products on the user side, and to indicate the direction of product optimization based on monitoring data. Therefore, how to track in the code is an urgent problem that technicians need to solve.
[0003] In the prior art CN110737589A, a method, device, medium and electronic device for automatic tracking are provided. In this patent application, the injection point information of the tracking point marked by the annotator is obtained, and the injection point is identified according to the injection point information; the source code of the network application is tracked at the injection point by the tool of the mobile UI framework to generate a mixed bytecode; and the compiled code is generated according to the mixed bytecode. However, this prior art is aimed at the Flutter meta information tracking function of the Android and iOS platforms, and cannot realize the tracking operation of the front-end page code. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, device, processor, storage medium and program product for adding embedding points to front-end pages quickly and accurately.
[0005] In order to achieve the above-mentioned object, the first aspect of the present application provides a method for adding a buried point, comprising:
[0006] Get the executable file to which the tracking point is to be added;
[0007] Converting the executable file to obtain an abstract syntax tree corresponding to the executable file;
[0008] Traversing the abstract syntax tree to determine function declarations contained in the abstract syntax tree;
[0009] Obtain the function name and preset burying configuration file of the function declaration, wherein the preset burying configuration file includes a target burying function array and a burying calling function;
[0010] When it is determined that the target embedding function array contains the function name, the embedding calling function is added to the function corresponding to the function name.
[0011] In an embodiment of the present application, the preset tracing configuration file also includes target annotation text, and the method also includes: when it is determined that the target tracing function array does not contain the function name, obtaining the annotation text contained in the function corresponding to the function name; when the annotation text contains the target annotation text, adding the preset tracing call function to the function corresponding to the function name.
[0012] In an embodiment of the present application, the type of comment text includes at least one of a pre-function comment, an inline comment, and a tail comment; the method also includes: when any type of comment text includes the target comment text, determining that the comment text includes the target comment text.
[0013] In an embodiment of the present application, the method also includes: adding the buried call function to the function corresponding to the function name, generating an updated abstract syntax tree; converting the updated abstract syntax tree into an updated executable file through the first database.
[0014] In an embodiment of the present application, the preset burying point configuration file also includes burying point reporting rules corresponding to each burying point call function; the method also includes: after converting the updated abstract syntax tree into an updated executable file through the first database, deploying the updated executable file; when the burying point call function in the updated executable file is called, acquiring the burying point data collected and uploaded by the terminal according to the burying point reporting rules corresponding to the burying point call function.
[0015] In an embodiment of the present application, when a burrowing point calling function is called, the burrowing point data collected and uploaded by the terminal according to the burrowing point reporting rules corresponding to the burrowing point calling function include: when multiple burrowing point calling functions are called, the corresponding burrowing point data is collected by the terminal according to the burrowing point reporting rules corresponding to each burrowing point calling function and cached in the local database; the acquisition terminal uploads multiple burrowing point data stored in the local database according to a preset reporting period.
[0016] In an embodiment of the present application, the tracking point reporting rules include user information, terminal device identification, calling time of the tracking point calling function, application name when the tracking point calling function is called, and at least one of the access address.
[0017] In an embodiment of the present application, converting the executable file to obtain an abstract syntax tree corresponding to the executable file includes: converting the executable file through a second database to obtain an abstract syntax tree package corresponding to the executable file.
[0018] In an embodiment of the present application, adding a buried point calling function to a function corresponding to a function name includes: adding a buried point calling function to the body of the function corresponding to the function name, and updating the parameters of the buried point calling function to the function name.
[0019] In an embodiment of the present application, adding the buried point call function to the function corresponding to the function name also includes: converting the buried point call function into the corresponding abstract syntax tree through a third database; adding the converted buried point call function to the function corresponding to the function name.
[0020] A second aspect of the present application provides a processor configured to execute the above-mentioned method of adding tracking points.
[0021] A third aspect of the present application provides a device for adding buried points, including the above-mentioned processor.
[0022] A fourth aspect of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned method of adding tracking points.
[0023] A fifth aspect of the present application provides a computer program product, including a computer program, which implements the above-mentioned method of adding tracking points when executed by a processor.
[0024] The above method of adding tracking points obtains the executable file to which the tracking points are to be added, converts the executable file to obtain the abstract syntax tree corresponding to the executable file, and traverses the abstract syntax tree to determine the function declarations contained in the abstract syntax tree. When it is determined that the target tracking point function array contains the function name, the tracking point call function is automatically added to the function corresponding to the function name. This method of adding tracking points does not require manual participation, improves the efficiency of adding tracking points, and will not miss any points. It can accurately and comprehensively track the functions that need to add tracking points. In addition, the tracking point reporting rules can be flexibly configured to meet the requirements of multiple aspects for tracking point data reporting.
[0025] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:
[0027] Figure 1 The following is a schematic diagram showing a flow chart of a method for adding buried points according to an embodiment of the present application;
[0028] Figure 2 A schematic diagram of the process of adding buried points according to an embodiment of the present application is schematically shown;
[0029] Figure 3The following is a schematic diagram showing a flow chart of a method for adding buried points according to another embodiment of the present application;
[0030] Figure 4 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0032] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0033] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by this application. It should be noted that in the solutions involved in this application, the acquisition and use of data are in compliance with the relevant national laws and regulations.
[0034] Figure 1 The flowchart of the method for adding buried points according to the embodiment of the present application is schematically shown. Figure 1 As shown, in an embodiment of the present application, a method for adding a buried point is provided. This embodiment is mainly illustrated by applying the method to a terminal, and includes the following steps:
[0035] Step 102, obtain the executable file to which the embedding point is to be added.
[0036] Step 104: convert the executable file to obtain an abstract syntax tree corresponding to the executable file.
[0037] Step 106: traverse the abstract syntax tree to determine the function declarations included in the abstract syntax tree.
[0038] Step 108, obtaining the function name of the function declaration and a preset tracing configuration file, wherein the preset tracing configuration file includes a target tracing function array and a tracing calling function.
[0039] Step 110, when it is determined that the target tracking function array contains the function name, the tracking call function is added to the function corresponding to the function name.
[0040] Tracking is a common data collection method for website analysis, such as analyzing basic indicators such as UV, PV, and click volume, evaluating the effect of activities / new functions when they are quickly launched and iterated, and checking the number of clicks on a certain control. The purpose of tracking is to obtain basic information and behavior of website users and track the use of products; optimize products based on tracking data, locate website problems, optimize website performance, and improve user experience. Website page display requires three files, namely html (responsible for page data), css (responsible for page style), and JavaScript file (responsible for page interaction, such as click events). Among them, the executable file in this embodiment can refer to a JavaScript file, so this method can automatically add tracking code to the JavaScript file of the website page. After obtaining the executable file to be added with tracking, the terminal can convert the executable file to obtain an abstract syntax tree corresponding to the executable file. Abstract syntax tree, referred to as AST (Abstract Syntax Tree), is an abstract representation of the syntax structure of the source code. It represents the syntax structure of the programming language in a tree form, and each node on the tree represents a structure in the source code.
[0041] Further, in one embodiment, converting the executable file to obtain an abstract syntax tree corresponding to the executable file includes: converting the executable file through a second database to obtain an abstract syntax tree corresponding to the executable file. When converting the executable file, the babel technology can be used to convert it. Babel is a JavaScript compiler that can perform syntax parsing on the executable file and generate a corresponding AST syntax tree. Specifically, the executable file, i.e., the JavaScript file, can be converted into AST using a specific database, babel / parser.
[0042] In JavaScript, functions have the following three representations:
[0043] (1) Function declaration: In JavaScript, you can use the function keyword to define a function. The following code is a function declaration, and the function name is functionName:
[0044] 1. function functionName(parameters){
[0045] 2. Code to be executed
[0046] 3.}
[0047] (2) Function expression: You can assign a function definition to a variable. As shown in the following code, the variable x is a function, but the function has no function name:
[0048] var x=function(a,b){return a*b};
[0049] (3) Arrow Function: Arrow Function is a new function added in ES6. As shown in the following code, the arrow function has no function name:
[0050] x=>x*x;
[0051] From the above, it can be seen that only function declarations have function names. After adding the buried point calling function, it is usually necessary to count the number of clicks or click time of the event triggered by a specific function. Therefore, in this embodiment, buried points can be performed for the function declaration in the executable file. Therefore, after the processor converts the executable file and obtains the abstract syntax tree corresponding to the executable file, it can traverse the abstract syntax tree to determine the function declaration contained in the abstract syntax tree. The processor can also obtain the function name of the function declaration and the preset buried point configuration file, wherein the preset buried point configuration file includes the target buried point function array and the buried point calling function. Then, the function name of the function declaration contained in the abstract syntax tree can be matched with the function name contained in the target buried point function array. If the match is successful, that is, it is determined that the target buried point function array contains the function name of the function declaration contained in the abstract syntax tree, the processor can add the buried point calling function to the function corresponding to the function name, so as to implement the buried point operation for the executable file.
[0052] Developers can configure the tracking reporting rules for tracking call functions according to business needs. When reporting tracking data, be as detailed and timely as possible. Detailed means collecting as comprehensive attributes and dimensions as possible, saving data details as much as possible, and making the accumulated data assets of higher quality. For example, report time data from dimensions such as user information, time, browser, and function name. The user name can be obtained from the web page cookie, and the time refers to the trigger time (which can be obtained using the Date method), browser information (which can be obtained using the navigator object, which is based on object-oriented thinking and supports browser information of various browsers (including mobile phones)), function name (tracking function calls can be passed in through parameters), and the URL of the page where the tracking function is located. Time means that the timeliness of data collection should be improved as much as possible under the condition that technical conditions and costs permit, so as to improve the timeliness of subsequent data applications. The data collected by tracking can be reported in batches. For example, save the data collected each time in the browser's local cache (the browser's local cache), report the tracking data (all data in the local cache) to the server every 5 seconds, and clear the local cache after reporting the data. The data collected by the tracking point can be reported in real time, and the statistical data will be sent to the server every time the function is triggered.
[0053] In one embodiment, the tracking point reporting rules include at least one of the user information, the device identification of the terminal, the calling time of the tracking point calling function, the application name when the tracking point calling function is called, and the access address. Among them, the user information may refer to the login information of the user who is currently using the browser or accessing the web page. The device identification of the terminal may refer to the identification of the terminal device used by the user, such as the device ID of the mobile phone used by the user. The calling time of the tracking point calling function refers to the time when the user triggers the calling of the tracking point calling function through a certain operation when accessing the front-end page. The application name when the tracking point calling function is called refers to the name of the browser used by the user when accessing the page or other application names that can access the front-end html page, etc. The access address may refer to the URL (website) of the front-end page.
[0054] In one embodiment, adding the buried point calling function to the function corresponding to the function name includes: adding the buried point calling function to the body of the function corresponding to the function name, and updating the parameters of the buried point calling function to the function name.
[0055] When performing a tracking operation on a selected function, you can add a tracking call function to the body of the function and update the parameters of the tracking call function to the function name. In this way, when this function is called, the tracking call function will also be triggered at the same time. In this way, the tracking call function can collect and report tracking data according to the corresponding tracking reporting rules.
[0056] Furthermore, in one embodiment, adding the buried call function to the function corresponding to the function name also includes: converting the buried call function into a corresponding abstract syntax tree through a third database; and adding the converted buried call function to the function corresponding to the function name.
[0057] Since the code file in the executable file has been converted into an abstract syntax tree (AST), and AST is a tree-shaped JSON structure object, this JSON object contains source code information. Therefore, when adding the embedded call function to the function in the abstract syntax tree, the embedded call function can be first converted into the corresponding abstract syntax tree through a preset third database, and then added to the function. Among them, the third database can be a babel / template database.
[0058] In one embodiment, the method further includes: adding the buried call function to the function corresponding to the function name, generating an updated abstract syntax tree; and converting the updated abstract syntax tree into an updated executable file through the first database.
[0059] After converting the tracking call function into the corresponding abstract syntax tree through the third database, and adding the converted tracking call function to the function corresponding to the function name, the updated abstract syntax tree can be obtained. The third database can be a babel / parser database. Afterwards, the updated abstract syntax tree can be converted into an updated executable file through the preset first database. The updated executable file can be deployed to the server to implement the tracking operation. After the deployment is successful, it is equivalent to that the front-end web page code has been updated, and the tracking function has been added to the web page code, and the user's operations on the web page can be collected and recorded. Figure 2 As shown, first get the executable file, that is Figure 2 The code is then converted into an abstract syntax tree (AST), and then a tracking plug-in that can execute the above-mentioned method of adding tracking points is used to add tracking points to the AST, that is, add a tracking point call function to obtain an updated AST, that is, the NEWAST in the figure. Subsequently, the NEW AST is converted into an executable file, that is, the NEW CODE. In this way, it is possible to add tracking points to the functions that are predetermined in the code and need to be tracked, so as to collect the required user operation data.
[0060] Furthermore, in one embodiment, the preset tracking configuration file also includes tracking reporting rules corresponding to each tracking call function. The method also includes: after converting the updated abstract syntax tree into an updated executable file through the first database, deploying the updated executable file; when the tracking call function in the updated executable file is called, acquiring tracking data collected and uploaded by the terminal according to the tracking reporting rules corresponding to the tracking call function.
[0061] After the updated executable file is deployed on the server, that is, the executable file to which the burying point calling function is added has already added the burying point. Then, when the user enters the front-end webpage corresponding to the executable file again on the terminal, the terminal can collect and record the user's operation according to the burying point reporting rule corresponding to the burying point calling function, and can upload the collected user operation data to the processor. In one embodiment, when the burying point calling function is called, obtaining the burying point data collected and uploaded by the terminal according to the burying point reporting rule corresponding to the burying point calling function includes: when multiple burying point calling functions are called, the terminal collects the corresponding burying point data according to the burying point reporting rule corresponding to each burying point calling function and caches it in the local database; obtaining the terminal uploads multiple burying point data stored in the local database according to the preset reporting cycle. Such as the click rate of a user for a certain login operation, the number of clicks on a certain picture, etc., statistics on which type of pictures users in a certain province are more inclined to click, etc. The dimension of this statistic can be customized according to the actual needs of the burying point reporting rules in the preset burying point configuration file. After the terminal collects the user's operation data, it can first save the collected data in the local database of the browser, such as localstrage. And the data can be uploaded according to the preset reporting cycle. For example, the collected buried data is uploaded every 5 seconds. Of course, the terminal can also upload the collected buried data in real time, that is, each time the data is collected, it is reported in real time to improve the timeliness of the data. Furthermore, in order to avoid the local database of the browser being occupied too much and affecting subsequent cache operations, the terminal can clear the cached data in the local database after each reporting of the buried data.
[0062] In one embodiment, the preset tracking configuration file also includes target comment text, and the method further includes: when it is determined that the target tracking function array does not include the function name, obtaining the comment text included in the function corresponding to the function name; when the comment text includes the target comment text, adding the preset tracking call function to the function corresponding to the function name. In one embodiment, the type of comment text includes at least one of a pre-function comment, an inline comment, and a tail comment; the method further includes: when any type of comment text includes the target comment text, determining that the comment text includes the target tracking function.
[0063] When it is determined that the target burying function array of the preset burying configuration file contains the function name of the function declaration contained in the abstract syntax tree, the burying call function can be added to the function corresponding to the function name. When the target burying function array does not contain the function name of the function declaration contained in the abstract syntax tree, the comment text contained in the function corresponding to each function name can continue to be obtained. There are two types of JavaScript comments, namely single-line comments and multi-line comments. According to the position of the comment text, the type of comment text can be divided into pre-function comments, in-line comments and tail comments. In this embodiment, the type of comment text includes at least one of pre-function comments, in-line comments and tail comments. The above method also includes: in the case where any type of comment text contains the target comment text, it is determined that the comment text contains the target comment text. The comment text that can be pre-specified, if the comment text of the function corresponding to the function declaration contained in the abstract syntax tree contains the pre-specified comment text, that is, the target comment text, then it means that the function belongs to the function that needs to add burying points, and the preset burying call function can be added to the function corresponding to the function name.
[0064] Specifically, Figure 3 As shown, a method for adding tracking points is also provided. First, the tracking point plug-in parameters can be obtained, that is, the preset tracking point configuration file can be obtained. The preset tracking point configuration file includes a target tracking point function array, a tracking point call function, a target comment text, and a tracking point reporting rule corresponding to each tracking point call function. Get the executable file and convert it to obtain the abstract syntax tree corresponding to the executable file. Then traverse the function declarations in the abstract syntax tree and obtain the function name corresponding to each function declaration. If the function name is in the target tracking point function array, that is, the target tracking point function array contains the function name, then a pre-set tracking point call function can be added for the function. If the function name is not in the target tracking point function array, that is, the target tracking point function array does not contain the function name, then the comment text of the function corresponding to the function declaration can continue to be detected to determine whether its comment text contains the target comment text. For example, the target comment text can be "track-enable".
[0065] Assume that the target tracking function array contains the two function names test1 and test2, and the function name of the function is also test1 and test2, that is, the function name of the function declaration in the abstract syntax tree is in the target tracking function array. In this case, the code for the tracking call function can be automatically added, such as adding it to the 12th and 17th lines of the code. Further, the code also includes the function names of test3 and test4. Although they are not included in the target tracking function array, because their comment text contains the target comment text: "track-enable", the code for the tracking call function will also be automatically added to the functions of test3 and test4, such as adding it to the 24th and 29th lines of the code. Further, in this scheme, according to the above-mentioned method of adding tracking points, the corresponding tracking plug-in can be developed using webpack technology and babel technology to implement the above-mentioned method of adding tracking points, so as to automatically complete the tracking operation of the code. Among them, Webpack is a front-end resource loading / packaging tool. It will perform static analysis based on the dependencies of the modules, and then generate corresponding static resources for these modules according to the specified rules. Babel is a toolchain that converts code written in ECMAScript 2015+ syntax into backwards-compatible JavaScript syntax so that it can run in current and older versions of browsers or other environments.
[0066] The above method of adding tracking points obtains the executable file to which the tracking points are to be added, converts the executable file to obtain the abstract syntax tree corresponding to the executable file, and traverses the abstract syntax tree to determine the function declarations contained in the abstract syntax tree. When it is determined that the target tracking point function array contains the function name, the tracking point call function is automatically added to the function corresponding to the function name. This method of adding tracking points does not require manual participation, improves the efficiency of adding tracking points, and will not miss any points. It can accurately and comprehensively track the functions that need to add tracking points. In addition, the tracking point reporting rules can be flexibly configured to meet the requirements of multiple aspects for tracking point data reporting.
[0067] Figure 1-3 FIG. 1 is a flow chart of a method for adding a tracking point in one embodiment. It should be understood that although Figure 1-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-3At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0068] An embodiment of the present application provides a storage medium on which a program is stored, and when the program is executed by a processor, the above-mentioned method of adding tracking points is implemented.
[0069] An embodiment of the present application provides a processor, which is used to run a program, wherein the method of adding tracking points is executed when the program is running.
[0070] In one embodiment, the present application also provides a device for adding buried points, which includes the above-mentioned processor, and the processor is used to run a program, wherein the above-mentioned method for adding buried points is executed when the program is running.
[0071] The processor includes a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the above method of adding tracking points can be implemented by adjusting kernel parameters.
[0072] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0073] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store data reported by the buried point, etc. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a method for adding buried points is implemented.
[0074] Those skilled in the art will understand that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0075] In one embodiment, the device for adding buried points provided in the present application can be implemented in the form of a computer program, and the computer program can be Figure 4 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the device for adding buried points. The computer program composed of various program modules enables the processor to execute the steps of the method for adding buried points in various embodiments of the present application described in this specification.
[0076] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: obtaining an executable file to which a burying point is to be added; converting the executable file to obtain an abstract syntax tree corresponding to the executable file; traversing the abstract syntax tree to determine the function declaration contained in the abstract syntax tree; obtaining the function name of the function declaration and a preset burying point configuration file, the preset burying point configuration file including a target burying point function array and a burying point calling function; when it is determined that the target burying point function array contains the function name, adding the burying point calling function to the function corresponding to the function name.
[0077] In one embodiment, the preset tracing configuration file also includes target comment text, and the method also includes: when it is determined that the target tracing function array does not contain the function name, obtaining the comment text contained in the function corresponding to the function name; when the comment text contains the target comment text, adding the preset tracing call function to the function corresponding to the function name.
[0078] In one embodiment, the type of comment text includes at least one of a pre-function comment, an inline comment, and a tail comment; the method further includes: when any type of comment text includes the target comment text, determining that the comment text includes the target comment text.
[0079] In one embodiment, the method further includes: adding the buried call function to the function corresponding to the function name, generating an updated abstract syntax tree; and converting the updated abstract syntax tree into an updated executable file through the first database.
[0080] In one embodiment, the preset burying point configuration file also includes burying point reporting rules corresponding to each burying point calling function; the method also includes: after converting the updated abstract syntax tree into an updated executable file through the first database, deploying the updated executable file; when the burying point calling function in the updated executable file is called, acquiring the burying point data collected and uploaded by the terminal according to the burying point reporting rules corresponding to the burying point calling function.
[0081] In one embodiment, when a burying point calling function is called, the burying point data collected and uploaded by the terminal according to the burying point reporting rules corresponding to the burying point calling function include: when multiple burying point calling functions are called, the corresponding burying point data is collected by the terminal according to the burying point reporting rules corresponding to each burying point calling function and cached in the local database; the terminal uploads multiple burying point data stored in the local database according to a preset reporting period.
[0082] In one embodiment, the tracking point reporting rules include user information, terminal device identification, calling time of the tracking point calling function, application name when the tracking point calling function is called, and at least one of the access address.
[0083] In one embodiment, converting the executable file to obtain an abstract syntax tree corresponding to the executable file includes: converting the executable file through a second database to obtain an abstract syntax tree package corresponding to the executable file.
[0084] In one embodiment, adding the buried point calling function to the function corresponding to the function name includes: adding the buried point calling function to the body of the function corresponding to the function name, and updating the parameters of the buried point calling function to the function name.
[0085] In one embodiment, adding the buried point calling function to the function corresponding to the function name also includes: converting the buried point calling function into the corresponding abstract syntax tree through a third database; and adding the converted buried point calling function to the function corresponding to the function name.
[0086] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the method steps of adding buried points.
[0087] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0088] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0089] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0090] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0091] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0092] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0093] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0094] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0095] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for adding buried points, characterized in that: The method comprises: Get the executable file to which the tracking point is to be added; Converting the executable file to obtain an abstract syntax tree corresponding to the executable file; Traversing the abstract syntax tree to determine function declarations contained in the abstract syntax tree; Obtain the function name and preset burying configuration file of the function declaration, wherein the preset burying configuration file includes a target burying function array, a burying calling function, a target annotation text, and a burying reporting rule corresponding to each burying calling function; When it is determined that the target embedding function array includes the function name, adding the embedding call function to the function corresponding to the function name to generate an updated abstract syntax tree; Converting the updated abstract syntax tree into an updated executable file through a first database; Deploying the updated executable file; When the burying point calling function in the updated executable file is called, acquiring the burying point data collected and uploaded by the terminal according to the burying point reporting rule corresponding to the burying point calling function; When it is determined that the target embedding function array does not contain the function name, obtaining the comment text contained in the function corresponding to the function name; In the case where the target annotation text is included in the annotation text, the preset embedding call function is added to the function corresponding to the function name.
2. The method according to claim 1, characterized in that The type of the comment text includes at least one of a pre-function comment, an inline comment, and a tail comment, and the method further includes: In the case that any type of annotation text includes the target annotation text, it is determined that the annotation text includes the target annotation text.
3. The method according to claim 1, characterized in that In the case where the burying point calling function is called, acquiring the burying point data collected and uploaded by the terminal according to the burying point reporting rule corresponding to the burying point calling function includes: When multiple burying point calling functions are called, the terminal collects the corresponding burying point data according to the burying point reporting rules corresponding to each burying point calling function and caches it in the local database; Acquire the multiple buried point data stored in the local database uploaded by the terminal according to a preset reporting period.
4. The method according to claim 1, characterized in that: The burying point reporting rules include user information, terminal device identification, calling time of the burying point calling function, application name when the burying point calling function is called, and at least one of the access address.
5. The method according to claim 1, characterized in that The converting the executable file to obtain an abstract syntax tree corresponding to the executable file includes: The executable file is converted through a second database to obtain an abstract syntax tree package corresponding to the executable file.
6. The method according to claim 1, characterized in that The step of adding the buried point calling function to the function corresponding to the function name comprises: The buried point calling function is added to the body of the function corresponding to the function name, and the parameters of the buried point calling function are updated to the function name.
7. The method according to any one of claims 1 to 6, characterized in that: The step of adding the buried point calling function to the function corresponding to the function name also includes: Converting the buried call function into a corresponding abstract syntax tree through a third database; Add the converted buried point calling function to the function corresponding to the function name.
8. A processor, characterized in that: The method is configured to execute the method for adding buried points according to any one of claims 1 to 7.
9. A device for adding buried points, characterized in that: The apparatus comprises a processor according to claim 8.
10. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the method for adding tracking points according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the method for adding buried points according to any one of claims 1 to 7.
