Code point burying method and device

By configuring a point buried plug-in for the initial code, automatically identifying and injecting a point buried code, the problems of high cost and error-prone front-end point buried point development in the existing technology are solved, and automated front-end point buried operation is realized, reducing the cost and error rate.

CN119829411AInactive Publication Date: 2025-04-15SHANGHAI BILIBILI TECH CO LTD

Patent Information

Application Number
CN202411960006.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing front-end point buried solution relies on developers to write code manually, resulting in high development costs, error-prone and difficult to maintain.

Method used

By configuring a buried point plug-in for the initial code, the target event attributes are automatically identified and the buried point code is injected to realize automated front-end buried point operations.

Benefits of technology

It reduces development costs and maintenance costs, reduces the error rate of buried point operations, and realizes automated front-end buried point operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829411A_ABST
    Figure CN119829411A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a code point burying method. The method comprises the following steps: acquiring an initial code; a burying point plug-in is configured for the initial code; determining whether a target event attribute exists in the initial code or not through the buried point plug-in; and under the condition that the target event attribute exists in the initial code, injecting a point burying code into a corresponding target function code in the initial code through the point burying plug-in to obtain a target code with a point burying function. According to the technical scheme of the embodiment of the invention, automatic front-end point burying operation can be realized, manual coding by developers is not needed, the development cost and the maintenance cost are reduced, and the error rate of point burying operation is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a code embedding method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] Front-end tracking can help product teams understand how users interact with products, thereby optimizing product features and improving user experience. It is an important tool for analyzing user behavior and understanding user needs. Currently, front-end tracking solutions on the market mainly rely on developers to manually write code and implant relevant code snippets in specific locations. This has high development costs, is prone to errors, and is difficult to maintain.

[0003] It should be noted that the above content is not necessarily prior art, nor is it intended to limit the scope of patent protection of this application. Summary of the invention

[0004] The embodiments of the present application provide a code embedding method, apparatus, computer device, computer-readable storage medium, and computer program product to solve or alleviate one or more of the technical problems raised above.

[0005] One aspect of an embodiment of the present application provides a code tracking method, the method comprising: Get the initial code; Configure a tracking plug-in for the initial code; Determine, by means of the tracking plug-in, whether there is a target event attribute in the initial code; and In the case where the target event attribute exists in the initial code, the embedding code is injected into the corresponding target function code in the initial code through the embedding plug-in to obtain the target code with the embedding function.

[0006] Optionally, the tracking plug-in is configured with a parameter entry, the parameter entry is used to receive target configuration data, the target configuration data includes a target front-end element and a name of the target event attribute; determining whether the target event attribute exists in the initial code through the tracking plug-in includes: According to the initial code, obtaining an abstract syntax tree corresponding to the initial code; Traversing the abstract syntax tree to determine a plurality of front-end elements; In the case where the front-end element is a target front-end element, it is determined whether the target event attribute exists in the target front-end element.

[0007] Optionally, injecting the tracking code into the corresponding target function code in the initial code through the tracking plug-in to obtain the target code with the tracking function includes: Injecting the embedding code into the target function code to obtain a modified abstract syntax tree; The target code is obtained according to the modified abstract syntax tree.

[0008] Optionally, injecting the tracking code into the corresponding target function code in the initial code through the tracking plug-in to obtain the target code with the tracking function includes: Modifying the objective function code according to the type of the objective function code; Injecting the embedded code into the modified target function code to obtain the modified abstract syntax tree; The target code is obtained according to the modified abstract syntax tree.

[0009] Optionally, the method further comprises: When the target code is obtained based on the modified abstract syntax tree, the initial code is replaced by the target code.

[0010] Optionally, the tracing plug-in is configured to: start the tracing plug-in when a tracing trigger event is detected; wherein the tracing trigger event includes a compilation event for the initial code.

[0011] Another aspect of an embodiment of the present application provides a code embedding device, the device comprising: Acquisition module, used to obtain the initial code; A configuration module, used to configure a tracking plug-in for the initial code; A determination module, used to determine whether a target event attribute exists in the initial code through the tracking plug-in; and The injection module is used to inject the embedding code into the corresponding target function code in the initial code through the embedding plug-in when the target event attribute exists in the initial code, so as to obtain the target code with the embedding function.

[0012] Another aspect of an embodiment of the present application provides a computer device, including: at least one processor; and a memory communicatively coupled to the at least one processor; Wherein: the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.

[0013] Another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method described above is implemented.

[0014] Another aspect of an embodiment of the present application provides a computer program product, including a computer program, which implements the method described above when executed by a processor.

[0015] The embodiment of the present application adopts the above technical solution, which may include the following advantages: configuring a tracking plug-in for the code that needs to be tracked, and automatically injecting the tracking code at the target event attribute through the tracking plug-in. In this way, the front-end tracking operation can be automated, without the need for developers to perform manual coding, thus reducing the development cost and maintenance cost, as well as the error rate of the tracking operation. BRIEF DESCRIPTION OF THE DRAWINGS The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.

[0016] Figure 1 The following schematically shows the operating environment of the code tracking method according to the first embodiment of the present application; Figure 2 The flowchart of the code tracking method according to the first embodiment of the present application is schematically shown; Figure 3 Schematically shows Figure 2 Flow chart of sub-steps of step S204; Figure 4 Schematically shows Figure 2 Flow chart of sub-steps of step S206; Figure 5 Schematically shows Figure 2 Another sub-step flow chart of step S206; Figure 6 The following schematically shows an exemplary application flow chart according to the first embodiment of the present application; Figure 7 A block diagram of a code embedding device according to the second embodiment of the present application is schematically shown; Figure 8 A schematic diagram of the hardware architecture of a computer device according to Embodiment 3 of the present application is shown; and Fig. 9 The following is a schematic diagram of a method for using the embedding plug-in in an embodiment of the present application. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0018] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying 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 combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0019] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.

[0020] First, the following terms are explained: Tracking: It is a method of data collection in the field of software development and data analysis. It refers to embedding specific code snippets in software applications or websites to record user behavior and application operation status.

[0021] Front-end: is a branch of software development that includes creating and maintaining the user interface (UI) and user experience (UX). Front-end developers are responsible for building the front-end portion of websites and web applications, which is the part that users can directly interact with.

[0022] Plugin: A software component that can extend or modify the functionality of a main program (host). Plugins are designed to be modular and can be dynamically loaded and unloaded without modifying the main program code.

[0023] Front-end event handling attributes: refers to the attributes in HTML elements that are used to specify the function that should be executed when a specific event occurs. These attributes allow developers to bind event listeners directly to HTML elements instead of manually adding listeners in the relevant code.

[0024] Abstract Syntax Tree: Abstract Syntax Tree, referred to as AST, is a data structure used to represent the structure of programming language source code. AST can present the grammatical structure of the code in the form of a tree diagram, where each node represents a construct in the code (such as an expression, statement, etc.).

[0025] Code injection: refers to dynamically adding additional code to the application code in order to record data such as user behavior or application performance.

[0026] Compilation: is a process in computer science used to convert source code written in a programming language (usually a high-level language) into another language (usually a low-level language). The main purpose is to generate an executable program, or convert the code into another form so that it can run in a different environment or platform.

[0027] Git: is an open source distributed version control system used to handle project version management, helping developers track code changes, collaborate, and manage different versions of projects.

[0028] springboot-aop-plugin: is a tool based on the Spring Boot framework. In backend development, as the complexity of business logic increases, there are many cross-cutting concerns, such as logging, security checks, transaction management, etc. If these cross-cutting concerns are scattered in various business methods, the code will be highly coupled and poorly maintainable. The purpose of springboot-aop-plugin is to separate these cross-cutting concerns from the core business logic and handle them in a more maintainable way.

[0029] reactAOP function: is a technique for implementing AOP in React applications.

[0030] AOP: The abbreviation of Aspect Oriented Programming, which means aspect-oriented programming, is a technology that achieves unified maintenance of program functions through pre-compilation and dynamic proxy during runtime. It can dynamically add functions to the program without modifying the source code during compilation or runtime.

[0031] Vite: is a modern front-end building tool that leverages native ES module features and provides fast cold start and hot update capabilities.

[0032] Babel: is a JavaScript compiler that is primarily used to convert modern JavaScript code into backward-compatible JavaScript code so that it can run in both current and older browsers or environments.

[0033] React: is an open source JavaScript library for building user interfaces, developed and maintained by Facebook, focusing on building the user interface part of single-page applications (SPA).

[0034] Vue: is an open source front-end JavaScript framework. It is a progressive framework for building user interfaces. It can be easily integrated into some functions of the project or used to build complete front-end applications.

[0035] NPM: Node Package Manager, is the default package manager for Node.js, used to manage and install the dependencies required by Node.js programs.

[0036] vite.config.ts file: It is Vite's configuration file, which is used to define the project's build and development behavior.

[0037] HTML elements: Also known as HTML tags, they are the basic building blocks of HTML and are used to tell the browser how to display content. Each HTML element consists of a start tag and an end tag, and the content between them is the content of the element.

[0038] HTML: HyperText Markup Language is a standard markup language used to create web pages and online information.

[0039] XML: eXtensible Markup Language, which is a markup language used to store and transmit data.

[0040] The transform hook is a key concept used in JavaScript build tools and compilers to modify code, allowing developers to manipulate and transform the Abstract Syntax Tree (AST) after the code is parsed into it and before code generation.

[0041] @babel / traverse: is a core module in the Babel JavaScript compiler toolchain, providing the ability to traverse and manipulate the abstract syntax tree (AST).

[0042] JSXOpeningElement node: is one of the Babel AST (abstract syntax tree) node types, used to represent the opening tag of an element in JSX.

[0043] @babel / generator: It is one of the core modules in the Babel tool chain, used to regenerate the transformed abstract syntax tree (AST) into JavaScript code.

[0044] Secondly, in order to facilitate those skilled in the art to understand the technical solutions provided in the embodiments of the present application, the relevant technologies are described below: In the daily development of software projects, active point tracking at the front end is a very common function. It can accurately obtain data closely related to the business. These accurately collected data can provide support for subsequent in-depth business analysis. Developers can also customize the dimensions of the data according to business scenarios. The technology for implementing the active point tracking function mainly includes relying on developers to manually write code to implant data collection code snippets at specific locations, and automatic point tracking at the back end based on the back end springboot-aop-plugin plug-in. However, the inventors found that the development cost of manual point tracking at the front end is high, prone to errors, and difficult to maintain, while the back end springboot-aop-plugin plug-in only supports back end Java projects, not front end projects.

[0045] To this end, the embodiment of the present application provides a code tracking technical solution. In this technical solution, by developing a vite plug-in, combined with Babel's code parsing capabilities, through some algorithmic logic, specific HTML tags and events are identified, and specific codes are injected into the identified event processing function to achieve the effect of active front-end tracking. As a result, the tracking code can be automatically inserted during the compilation phase of the front-end project without the developer having to manually modify the project source code. See below for details.

[0046] Finally, for ease of understanding, an exemplary operating environment is provided below.

[0047] like Figure 1 As shown, the environment diagram includes a development platform 2, a server 4, and a client 6, wherein: The development platform 2 can be a workstation, a personal computer, a virtual instance in a cloud platform, etc., providing a development environment and a development interface for users. The development platform 2 can run Windows system, IOS system or Unix system, etc. After the development platform 2 develops an application (installation package), it can be distributed through the server 4.

[0048] Server 4, as a storage platform, can be composed of multiple computing devices. The multiple computing devices can include virtualized computing instances. Virtualized computing instances can include virtual machines, such as simulations of computer systems, operating systems, servers, etc. The computing device can load the virtual machine based on a virtual image and / or other data that defines specific software (e.g., operating system, dedicated application, server) for simulation. As the demand for different types of processing services changes, different virtual machines can be loaded and / or terminated on one or more computing devices. A hypervisor can be implemented to manage the use of different virtual machines on the same computing device.

[0049] Server 4 can provide services such as storage and distribution of application programs.

[0050] The server 4 may be configured to communicate with the development platform 2 , the client 6 , etc. via a network.

[0051] The client 6 can provide a user access page, and can also automatically download an installation package from the server 4 to perform software updates, etc.

[0052] The following uses the development platform 2 as the execution subject to introduce the technical solution of the present application through multiple embodiments. It should be noted that these embodiments can be implemented in a variety of different forms and should not be interpreted as being limited to the embodiments described here.

[0053] Embodiment 1 Figure 2 The flowchart of the code tracking method according to the first embodiment of the present application is schematically shown.

[0054] like Figure 2 As shown, the code tracking method may include steps S200 to S206, wherein: Step S200, obtaining an initial code; Step S202, configuring a tracking plug-in for the initial code; Step S204, determining whether the target event attribute exists in the initial code through the tracking plug-in; and Step S206, when the target event attribute exists in the initial code, the embedding code is injected into the corresponding target function code in the initial code through the embedding plug-in to obtain the target code with the embedding function.

[0055] The code tracking method provided in this embodiment can automatically create tracking points in the front-end code without the need for developers to perform manual coding, thereby reducing development costs and maintenance costs, as well as the error rate of tracking operations.

[0056] The following combination Figure 2, each step in steps S200~S206 and other optional steps are described in detail.

[0057] Step S200 , get the initial code.

[0058] The initial code can be code written manually by the developer, code checked out from a version control system (such as Git), or code imported from a third-party library or framework. Depending on the actual situation, the initial code can also be code obtained from other available channels.

[0059] In some embodiments, the initial code may be written in scripting languages ​​such as JavaScript and Python, or in markup languages ​​such as HTML and XML. According to actual needs, the initial code may also be written in other available languages.

[0060] It should be noted that, in the process of obtaining the initial code, requirements for the format of the initial code, etc. may be set as needed, and the initial code may be subjected to security or compatibility testing when necessary.

[0061] Step S202 , configure a tracking plug-in for the initial code.

[0062] The tracking plug-in can be a vite plug-in generated and exported by the reactAOP function. It can also be a tracking plug-in generated or exported by other methods.

[0063] In some embodiments, the process of configuring the tracking plug-in may include first installing the NPM package of the tracking plug-in in the project to which the initial code belongs (such as a React or Vue project), and then introducing the dependency packages required by the tracking plug-in in the project's configuration file (such as the vite.config.ts file) and performing relevant configuration. Fig. 9 In other embodiments, the tracking plug-in may be configured by other methods or processes.

[0064] In this embodiment, a tracking plug-in is used instead of manual tracking operations to realize automatic insertion of tracking code without the need for developers to manually modify project source code, thereby reducing development and maintenance costs, as well as the error rate of tracking operations.

[0065] Step S204 , determine whether the target event attribute exists in the initial code through the tracking plug-in.

[0066] The target event attribute can be front-end event processing attributes such as onClick (click), onLoad (page load), or onFocus (focus element). Of course, it can also be other available native event attributes or custom event attributes.

[0067] In this embodiment, the plug-in can be used to automatically detect and identify target event attributes, thereby reducing the need for manual intervention, helping to avoid missing or erroneous addition of tracking code, and ensuring the integrity and reliability of data collection.

[0068] In an optional embodiment, the tracking plug-in is configured with a parameter entry, and the parameter entry is used to receive target configuration data, and the target configuration data includes the name of the target front-end element and the target event attribute. Figure 3 As shown, step S204 includes: S300: According to the initial code, an abstract syntax tree corresponding to the initial code is obtained.

[0069] S302, traversing the abstract syntax tree to determine a plurality of front-end elements.

[0070] S304: When the front-end element is a target front-end element, determine whether the target event attribute exists in the target front-end element.

[0071] In some embodiments, the target front-end element may be an HTML element such as a button or a form.

[0072] In this embodiment, an abstract syntax tree can be constructed in combination with Babel's code parsing capabilities, and specific elements and events can be identified through predetermined algorithm logic. As a result, the tracking plug-in can accurately locate all locations in the initial code where tracking is required, thereby achieving automated and efficient tracking processing, reducing errors and omissions in manual operations, and improving development efficiency and code quality. At the same time, the configuration data received through the parameter entry enables the plug-in to flexibly adapt to different tracking requirements and improve the user experience of developers.

[0073] Step S206 , when the target event attribute exists in the initial code, the embedding code is injected into the corresponding target function code in the initial code through the embedding plug-in to obtain the target code with the embedding function.

[0074] The tracking code can include tracking statements for collecting data or log statements for development or debugging. According to actual needs, the tracking code can also include other available code statements. The tracking code can be generated by code generation tools such as @babel / generator. According to actual conditions, other tools or manual writing of tracking code can also be used.

[0075] In some embodiments, the target function code may be a function code associated with the target event attribute and used to respond to the user triggering the target event attribute. In other embodiments, the target function code may also be other codes.

[0076] Inject tracking code into the identified event processing function to achieve the effect of active tracking on the front end. This can improve the automation level of tracking operations and provide stable and efficient data tracking capabilities for front-end applications.

[0077] There are many ways to obtain the target code, two of which are provided below.

[0078] Method 1: Figure 4 As shown, step S206 includes: S400, injecting the embedding code into the target function code to obtain a modified abstract syntax tree.

[0079] S402: Obtain the target code according to the modified abstract syntax tree.

[0080] In specific implementation, the target code can be generated through @babel / generator or other methods.

[0081] In this embodiment, the target code is generated by an abstract syntax tree, which can ensure the integrity and accuracy of the code structure, facilitate automated processing and optimization, and improve the processing efficiency of the tracking plug-in.

[0082] Method 2: Figure 5 As shown, step S206 includes: S500: modify the target function code according to the type of the target function code.

[0083] S502: Inject the embedded code into the modified target function code to obtain the modified abstract syntax tree.

[0084] S504: Obtain the target code according to the modified abstract syntax tree.

[0085] In specific implementation, the target function code may include multiple types such as function expressions, identifiers, call expressions, and member expressions.

[0086] In this embodiment, before injecting the embedding code, the target function code is adaptively modified to ensure the correct injection and execution of the embedding code, avoid interference with the original logic, and improve the compatibility and maintainability of the code.

[0087] In an optional embodiment, the method further comprises: When the target code is obtained based on the modified abstract syntax tree, the initial code is replaced by the target code.

[0088] In this embodiment, the initial code is completely replaced with the target code that has completed the embedding, which can avoid directly modifying the file of the initial code, thereby reducing the intrusion into the code base, reducing the difficulty of maintenance, and improving the flexibility of code management.

[0089] In an optional embodiment, the tracing plug-in is configured to: start the tracing plug-in when a tracing trigger event is detected; wherein the tracing trigger event includes a compilation event for the initial code.

[0090] The compilation event may include starting a local development environment of the project to which the initial code belongs, or packaging the project to which the initial code belongs.

[0091] In this embodiment, the tracking plug-in is triggered during the compilation phase of the initial code to automatically insert the tracking code, which can ensure that all compiled codes contain the required tracking points, thereby eliminating the need to dynamically modify the code at runtime and reducing runtime performance overhead. At the same time, inserting at compile time allows developers to see the effect of tracking points at an early stage of the development cycle, facilitating early testing and verification.

[0092] In order to make this application easier to understand, the following Figure 6 An exemplary application is provided.

[0093] S11, obtaining a development project O, wherein the development project O includes a front-end code A (ie, an initial code).

[0094] S12, install the NPM package of the tracking plug-in in the development project O, and introduce the required dependency packages.

[0095] S13, passing the target configuration data through the parameter entry of the tracking plug-in, setting the location where the tracking plug-in needs to track to be the onCLick event attribute (i.e., the target event attribute) in the button element (i.e., the target front-end element).

[0096] S14, start the development project O in the local development environment, and trigger the tracking plug-in to perform tracking.

[0097] S15, the tracking plug-in uses the transform hook to parse the incoming front-end code A and generate an abstract syntax tree.

[0098] S16, the tracking plug-in uses @babel / traverse to traverse the abstract syntax tree and find all JSXOpeningElement nodes (i.e. front-end elements).

[0099] S17, the tracking plug-in finds the target front-end element M named button in all JSXOpeningElement nodes.

[0100] S18, the tracking plug-in calls the processElement function to find the onCLick event attribute in the target front-end element M.

[0101] S19, the tracking plug-in modifies the clickHandler function (ie, the target function code) associated with the onCLick event attribute, and inserts the tracking code into the modified clickHandler function.

[0102] S20, the tracking plug-in calls @babel / generator to generate target code with tracking function according to the modified abstract syntax tree.

[0103] S21, the tracking plug-in uses the target code to replace the front-end code A in the development project O.

[0104] Embodiment 2 Figure 7 The block diagram of the code embedding device according to the second embodiment of the present application is schematically shown. The device can be divided into one or more program modules, one or more program modules are stored in a storage medium, and are executed by one or more processors to complete the embodiment of the present application. The program module referred to in the embodiment of the present application refers to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment. Figure 7 As shown, the device 1000 may include: an acquisition module 1100, a configuration module 1200, a determination module 1300, and an injection module 1400, wherein: An acquisition module 1100 is used to acquire an initial code; Configuration module 1200, used to configure a tracking plug-in for the initial code; A determination module 1300 is used to determine whether a target event attribute exists in the initial code through the tracking plug-in; and The injection module 1400 is used to inject the tracking code into the corresponding target function code in the initial code through the tracking plug-in when the target event attribute exists in the initial code, so as to obtain the target code with the tracking function.

[0105] As an optional embodiment, the tracking plug-in is configured with a parameter entry, the parameter entry is used to receive target configuration data, the target configuration data includes the name of the target front-end node and the target event attribute, and the determination module 1300 is further used to: According to the initial code, obtaining an abstract syntax tree corresponding to the initial code; Traversing the abstract syntax tree to determine a plurality of front-end nodes; In the case where the front-end node is a target front-end node, it is determined whether the target event attribute exists in the target front-end node.

[0106] As an optional embodiment, the injection module 1400 is further used for: Injecting the embedding code into the target function code to obtain a modified abstract syntax tree; The target code is obtained according to the modified abstract syntax tree.

[0107] As an optional embodiment, the injection module 1400 is further used for: Modifying the target function code according to the type of the target event attribute; Injecting the embedded code into the modified target function code to obtain the modified abstract syntax tree; The target code is obtained according to the modified abstract syntax tree.

[0108] As an optional embodiment, the code embedding device 1000 is further used for: When the target code is obtained based on the modified abstract syntax tree, the initial code is replaced by the target code.

[0109] As an optional embodiment, the tracing plug-in is configured to: start the tracing plug-in when a tracing trigger event is detected; wherein the tracing trigger event includes a compilation event for the initial code.

[0110] Embodiment 3 Figure 8 The schematic diagram of the hardware architecture of a computer device 10000 suitable for implementing the code embedding method according to the third embodiment of the present application is shown. In some embodiments, the computer device 10000 (development platform 2) can be a terminal device such as a smart phone, a tablet computer, a personal computer, a vehicle terminal, a game console, a virtual device, a workbench, a robot, etc. In other embodiments, the computer device 10000 can be a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Figure 8 As shown, the computer device 10000 includes but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other through a system bus. Among them: The memory 10010 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 10010 can be an internal storage module of the computer device 10000, such as a hard disk or memory of the computer device 10000. In other embodiments, the memory 10010 can also be an external storage device of the computer device 10000, such as a plug-in hard disk equipped on the computer device 10000, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 10010 can also include both the internal storage module of the computer device 10000 and its external storage device. In this embodiment, the memory 10010 is generally used to store the operating system and various application software installed in the computer device 10000, such as the program code of the code embedding method, etc. In addition, the memory 10010 can also be used to temporarily store various data that have been output or will be output.

[0111] In some embodiments, the processor 10020 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other chips. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication with the computer device 10000. In this embodiment, the processor 10020 is used to run the program code stored in the memory 10010 or process data.

[0112] The network interface 10030 may include a wireless network interface or a wired network interface, and the network interface 10030 is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 10000 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.

[0113] It should be pointed out that Figure 8 Only a computer device having components 10010 - 10030 is shown, but it should be understood that implementation of all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.

[0114] In this embodiment, the code embedding method stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (such as processor 10020) to complete the embodiment of the present application.

[0115] Embodiment 4 An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the code embedding method in the embodiment.

[0116] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Of course, the computer-readable storage medium may also include both an internal storage unit of a computer device and an external storage device thereof. In this embodiment, the computer-readable storage medium is generally used to store an operating system and various application software installed on a computer device, such as the program code of the code embedding method in the embodiment, etc. In addition, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.

[0117] Embodiment 5 An embodiment of the present application also provides a computer program product, including a computer program, which implements the method in the above embodiment when executed by a processor.

[0118] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by general-purpose computer devices, they can be concentrated on a single computer device, or distributed on a network composed of multiple computer devices, optionally, they can be implemented by executable program codes of computer devices, so that they can be stored in a storage device and executed by the computer device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0119] It should be noted that the above are only preferred embodiments of the present application, and the patent protection scope of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A code embedding method, characterized in that: For the front end, the method includes: Get the initial code; Configure a tracking plug-in for the initial code; Determine, by means of the tracking plug-in, whether there is a target event attribute in the initial code; and In the case where the target event attribute exists in the initial code, the embedding code is injected into the corresponding target function code in the initial code through the embedding plug-in to obtain the target code with the embedding function.

2. The method according to claim 1, characterized in that The tracking plug-in is configured with a parameter entry, and the parameter entry is used to receive target configuration data, and the target configuration data includes the name of the target front-end element and the target event attribute; Determining whether a target event attribute exists in the initial code by using the tracking plug-in includes: According to the initial code, obtaining an abstract syntax tree corresponding to the initial code; Traversing the abstract syntax tree to determine a plurality of front-end elements; In the case where the front-end element is a target front-end element, it is determined whether the target event attribute exists in the target front-end element.

3. The method according to claim 2, characterized in that Injecting the tracking code into the target function code corresponding to the initial code through the tracking plug-in to obtain the target code with the tracking function, including: Injecting the embedding code into the target function code to obtain a modified abstract syntax tree; The target code is obtained according to the modified abstract syntax tree.

4. The method according to claim 2, characterized in that: Injecting the tracking code into the target function code corresponding to the initial code through the tracking plug-in to obtain the target code with the tracking function, including: Modifying the objective function code according to the type of the objective function code; Injecting the embedded code into the modified target function code to obtain the modified abstract syntax tree; The target code is obtained according to the modified abstract syntax tree.

5. The method according to claim 2, 3 or 4, characterized in that: The method further comprises: When the target code is obtained based on the modified abstract syntax tree, the initial code is replaced by the target code.

6. The method according to claim 1, characterized in that The tracing plug-in is configured to: start the tracing plug-in when a tracing trigger event is detected; wherein the tracing trigger event includes a compilation event for the initial code.

7. A code embedding device, characterized in that: The device comprises: Acquisition module, used to obtain the initial code; A configuration module, used to configure a tracking plug-in for the initial code; A determination module, used to determine whether a target event attribute exists in the initial code through the tracking plug-in; and The injection module is used to inject the embedding code into the corresponding target function code in the initial code through the embedding plug-in when the target event attribute exists in the initial code, so as to obtain the target code with the embedding function.

8. A computer device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method and device for adding burying points, processor, storage medium and program product

    CN114047924A

  • Method and device for performing dynamic point burying on component based on aop and application

    CN114706563A

  • Front-end point burying method and device based on abstract syntax tree

    CN115994069A

  • Automatic point burying method and device, computer readable storage medium and electronic equipment

    CN116841602A

Cited By

  • Data access monitoring method based on full-link micro-code implantation and dynamic threshold

    CN122526920A