A method, apparatus, electronic device, and storage medium for embedding data points.

By adding tracking object identifiers to instantiated classes or class properties using decorators and property descriptors during page initialization, the problems of inaccurate information and high maintenance costs caused by code-based tracking methods are solved, thereby improving code readability and flexibility.

CN114138594BActive Publication Date: 2026-04-03上海瑞家信息技术有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-08
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In existing technologies, code-based event tracking requires development within the method, resulting in inaccurate information collection, high maintenance costs, poor readability, and difficulty in flexible updates.

Method used

By using decorators and property descriptors during page initialization, tracking object identifiers can be added to instantiated classes or class properties to achieve tracking behavior, avoiding setting tracking directly inside class code and reducing code redundancy and coupling.

Benefits of technology

It improves code readability and flexibility, reduces maintenance costs, simplifies the instrumentation update process, and is applicable to all JavaScript languages ​​that support decorators.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138594B_ABST
    Figure CN114138594B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, electronic device, and storage medium for event tracking. The method includes: during page initialization, determining whether a preset set of event tracking object identifiers contains an event tracking object identifier matching a target node, where the target node is an instantiated class or a class attribute within an instantiated class contained in the page; in response to the presence of an event tracking object identifier matching the target node in the set of event tracking object identifiers, adding the event tracking object identified by the matching event tracking object identifier after the target node using a decorator and the attribute descriptor corresponding to the target node. Because this solution adds the event tracking object after the target node where tracking is needed, rather than setting it within the target node, it reduces code redundancy and coupling between code segments, improves code readability, eliminates the need to redevelop class code during event tracking updates, facilitates maintenance, and the use of decorators for event tracking makes it very simple to use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for embedding data points. Background Technology

[0002] Event tracking is a technology and implementation process used in websites or programs to capture, process, and send data on specific user behaviors or events. Essentially, it involves monitoring events during the operation of a software application and identifying and capturing events when relevant ones occur. Generally, event tracking methods include code-based tracking, visual tracking, and full tracking. Code-based tracking can meet any business need and is a necessary supplement to the other two methods. Implementing code-based tracking requires developers to write the tracking data into the methods. Its advantages include more accurate and comprehensive information and reduced data analysis difficulty. However, it reduces readability, requires redeveloping methods to update tracking requirements, and results in high maintenance costs. Summary of the Invention

[0003] This invention provides a method, apparatus, electronic device, and storage medium for embedding data points, in order to solve problems in related technologies.

[0004] The objective of this invention is achieved through the following technical solution:

[0005] In a first aspect, embodiments of the present invention provide a method for embedding data points, including:

[0006] During page initialization, it is determined whether the preset set of tracking object identifiers contains tracking object identifiers that match the target node, where the target node is an instantiated class or a class attribute of an instantiated class contained in the page.

[0007] In response to the fact that the set of tracking object identifiers contains a tracking object identifier that matches the target node, the tracking object identified by the matching tracking object identifier is added after the target node using a decorator and the attribute descriptor corresponding to the target node. The tracking object is used to implement the tracking behavior.

[0008] In one possible implementation, in response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the target node, the tracking object identified by the matching tracking object identifier is added after the target node using a decorator and the attribute descriptor corresponding to the target node, including:

[0009] When the target node is a class attribute in an instantiated class, the class attribute is defined in the prototype object corresponding to the target node. Based on the decorator, the original attribute of the class attribute, and the tracking object identified by the matching tracking object identifier, a first attribute descriptor corresponding to the class attribute is defined. The first attribute descriptor is the attribute descriptor executed when the class attribute is read. The execution result of the defined first attribute descriptor returns the original attribute of the class attribute and the tracking object identified by the tracking object identifier that matches the class attribute.

[0010] In one possible implementation, in response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the target node, the tracking object identified by the matching tracking object identifier is added after the target node using a decorator and the attribute descriptor corresponding to the target node, including:

[0011] When the target node is an instantiated class, determine whether the set of tracking object identifiers contains tracking object identifiers that match the various methods and class attributes in the target node;

[0012] In response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the class attribute in the target node, the tracking object identified by the tracking object identifier that matches the class attribute is added after the class attribute using a decorator and the attribute descriptor corresponding to the class attribute.

[0013] In response to the fact that the set of tracking object identifiers contains tracking points that match the class method in the target node, the tracking object identified by the tracking object identifier that matches the class method is added after the class method using the decorator and the attribute descriptor corresponding to the class method.

[0014] In one possible implementation, the step of using a decorator and the attribute descriptor corresponding to the class method to add an event tracking object identifier matching the class method after the class method includes:

[0015] Based on the decorator, the original method of the method class, and the tracking object identified by the tracking object identifier that matches the method class, the second attribute descriptor corresponding to the method class is modified. The second attribute descriptor is the attribute descriptor executed when the method class is read. The execution result of the modified second attribute descriptor returns the original method of the method class and the tracking object identified by the tracking object identifier that matches the method class.

[0016] In one possible implementation, the tracking object is the tracking object corresponding to the user input event.

[0017] Secondly, embodiments of the present invention provide a device for embedding data points, comprising:

[0018] The determination module is used to determine, during the page initialization process, whether a preset set of tracking object identifiers contains a tracking object identifier that matches a target node, wherein the target node is an instantiated class or a class attribute of an instantiated class contained in the page.

[0019] The event tracking module is used to respond to the event tracking object identifier set containing an event tracking object identifier that matches the target node, by using a decorator and the attribute descriptor corresponding to the target node to add the event tracking object identified by the matching event tracking object identifier after the target node, and the event tracking object is used to implement the event tracking behavior.

[0020] In one possible implementation, the tracking module is specifically configured to, when the target node is a class attribute in an instantiated class, define the class attribute in the prototype object corresponding to the target node, and define a first attribute descriptor corresponding to the class attribute based on the decorator, the original attribute of the class attribute, and the tracking object identified by the matching tracking object identifier. The first attribute descriptor is an attribute descriptor executed when the class attribute is read. The execution result of the defined first attribute descriptor returns the original attribute of the class attribute and the tracking object identified by the tracking object identifier matching the class attribute.

[0021] In one possible implementation, the tracking module is specifically used to determine whether the tracking object identifier set contains tracking object identifiers that match the various methods and class attributes in the target node when the target node is an instantiated class.

[0022] In response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the class attribute in the target node, the tracking object identified by the tracking object identifier that matches the class attribute is added after the class attribute using a decorator and the attribute descriptor corresponding to the class attribute.

[0023] In response to the fact that the set of tracking object identifiers contains tracking points that match the class method in the target node, the tracking object identified by the tracking object identifier that matches the class method is added after the class method using the decorator and the attribute descriptor corresponding to the class method.

[0024] In one possible implementation, the tracking module is specifically used to modify the second attribute descriptor corresponding to the method based on the decorator, the original method of the method, and the tracking object identified by the tracking object identifier matching the method. The second attribute descriptor is the attribute descriptor executed when the method is read. The execution result of the modified second attribute descriptor returns the original method of the method and the tracking object identified by the tracking object identifier matching the method.

[0025] In one possible implementation, the tracking object is the tracking object corresponding to the user input event.

[0026] Thirdly, embodiments of the present invention provide an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data embedding method as described in any one of the first aspects.

[0027] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the data embedding method as described in any one of the first aspects.

[0028] The advantages or beneficial effects of the above technical solution include at least the following: During page initialization, using the instantiated class itself or a class attribute within the class as the target node, it is determined whether the preset set of tracking object identifiers contains a matching tracking object identifier. If the set of tracking object identifiers contains a tracking object identifier that matches the target node, then the target node needs to have tracking added. Using a decorator and the attribute descriptor corresponding to the target node, the tracking object identified by the matching tracking object identifier is added after the target node. This tracking object is used to implement the tracking behavior, thereby achieving tracking. Since this solution adds the tracking object after the target node that needs tracking, rather than setting it inside the target node, compared with related technologies that directly set tracking within the class code, it reduces code redundancy and coupling between codes, improves code readability, and eliminates the need to redevelop the class code when updating tracking, making maintenance easier. Furthermore, using decorators for tracking makes it very simple to use.

[0029] The above overview is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of the invention will become readily apparent from the accompanying drawings and the following detailed description. Attached Figure Description

[0030] Figure 1 This is a flowchart of an exemplary data embedding method provided in an embodiment of the present invention;

[0031] Figure 2 This is a schematic diagram of an exemplary embedded point device provided in an embodiment of the present invention;

[0032] Figure 3 This is a schematic diagram of an exemplary electronic device used to implement the embedding method, provided by an embodiment of the present invention. Detailed Implementation

[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0034] To facilitate understanding of the solutions in the embodiments of the present invention, a conceptual introduction will be given first.

[0035] In object-oriented programming, a class is an abstraction of objects, i.e., a prototype object, while an object is a concrete instance of a class, i.e., an instantiated class. After adding properties and methods to the prototype object, instances will also share the properties and methods added to the prototype object.

[0036] Figure 1 This is a flowchart of an exemplary data embedding method provided by an embodiment of the present invention. For example... Figure 1 As shown, this data embedding method includes at least the following steps:

[0037] Step 101: During page initialization, determine whether the preset set of tracking object identifiers contains tracking object identifiers that match the target node. The target node is an instantiated class or a class attribute of an instantiated class contained in the page.

[0038] Step 102: In response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the target node, use the decorator and the attribute descriptor corresponding to the target node to add the tracking object identified by the matching tracking object identifier after the target node. The tracking object is used to implement the tracking behavior.

[0039] The set of tracking object identifiers contains the identifier of at least one tracking object. Tracking actions implemented through tracking objects can collect data on a webpage, such as the number of times a button on the page is clicked. In implementation, at least one tracking object corresponding to the page can be pre-set as needed, and the tracking object identifiers of at least one tracking object can be obtained to form a set of tracking object identifiers. The tracking object identifier can be the name of the tracking object. In implementation, the name of the tracking object can be pre-included with the name of a matching instantiated class or class attribute. If the tracking object identifier contains the name of the target node, then that tracking object identifier matches the target node.

[0040] In practical applications, during page initialization, if the executed code is an instantiated class or a class property within an instantiated class, it will be used as a target node that may require additional tracking points.

[0041] Decorators are a special type of declaration that can be attached to methods and properties. They can add extra functionality to the existing functionality, that is, add extra functionality to the original behavior of the code in the form of aspect-oriented programming.

[0042] Property descriptors define the details of reading and writing properties, including at least `value`, `get`, and `set`, and are typically defined using the `Object.defineProperty` method. The `Object.defineProperty` method can directly define a new property on an object, modify an existing property of an object, and define the property descriptors `set` and `get`. `value` is the property value, which can be a valid number, object, method, etc., and its initial default value is undefined. `get` is executed when the property is read, returning `value`. `set` is executed when the property is written, updating `value`.

[0043] In this embodiment, during page initialization, the instantiated class itself or a class attribute within the class is used as the target node. It is determined whether a pre-defined set of tracking object identifiers contains a matching tracking object identifier. If the set contains a matching tracking object identifier, the target node needs to have tracking added. Using a decorator and the corresponding attribute descriptor of the target node, the tracking object identified by the matching tracking object identifier is added after the target node. This tracking object is used to implement the tracking behavior, thus achieving tracking. Since this solution adds the tracking object after the target node where tracking is needed, rather than setting it within the target node itself, compared to setting tracking directly within the class code in related technologies, it reduces code redundancy and coupling, improves code readability, and eliminates the need to redevelop the class code when updating tracking, facilitating maintenance. Furthermore, using decorators for tracking makes it very simple to use.

[0044] In an exemplary embodiment, in response to the fact that the set of tracking object identifiers contains a tracking object identifier that matches the target node, the tracking object identified by the matching tracking object identifier is added after the target node using the decorator and the attribute descriptor corresponding to the target node. Specific implementation methods may include:

[0045] When the target node is a class attribute in an instantiated class, the class attribute is defined in the prototype object corresponding to the target node, along with the tracking object identified by the decorator, the original attribute of the class attribute, and the matching tracking object identifier. The first attribute descriptor corresponding to the class attribute is defined. The first attribute descriptor is the attribute descriptor executed when the class attribute is read. The execution result of the defined first attribute descriptor returns the original attribute of the class attribute and the tracking object identified by the tracking object identifier that matches the class attribute.

[0046] In practical applications, for class attributes that need to be tracked, they are decorated using decorators. That is, the decorator defines the first attribute descriptor corresponding to the class attribute. After the class attribute is decorated by the decorator, at runtime, the class attribute will be intercepted and replaced with a combination of the original attribute and the tracking object identified by the matching tracking object identifier.

[0047] Here, the first attribute descriptor corresponding to this class attribute is `get`. In practical applications, for class attributes in an instantiated class, the class before instantiation does not contain the class attributes of the instantiated class. In this embodiment, to implement tracking for class attributes, the class attribute is defined in advance before instantiation, and the default value of `value` is `undefined`, indicating that it is not defined. After the class attribute in the instantiated class is assigned a value, `value` is set to the original attribute of that class attribute. `get` is defined to read `value` and the tracking object identified by the tracking object identifier matching that class attribute. In this way, tracking for class attributes is achieved, making the tracking more comprehensive.

[0048] In an exemplary embodiment, in response to the presence of a matching tracking object identifier in the tracking object identifier set, the tracking object identified by the matching tracking object identifier is added after the target node using a decorator and the attribute descriptor corresponding to the target node. Specifically, this can be implemented as follows: when the target node is an instantiated class, determine whether the tracking object identifier set contains tracking object identifiers matching various methods and class attributes in the target node; in response to the presence of a matching tracking object identifier in the tracking object identifier set, add the tracking object identified by the matching tracking object identifier after the class attribute using a decorator and the attribute descriptor corresponding to the class attribute; in response to the presence of a tracking object identifier in the tracking object identifier set matching a class method in the target node, add the tracking object identified by the matching tracking object identifier after the class method using a decorator and the attribute descriptor corresponding to the class method.

[0049] In practical applications, some classes are pre-encapsulated classes provided by third parties, making it inconvenient to modify their internal code, which poses difficulties for event tracking. To address this, this embodiment provides a method for event tracking classes. Users can select specific attributes and methods within a class for tracking, setting corresponding tracking objects in the tracking set. During implementation, after a class is decorated with a decorator, both class attributes and methods are intercepted. This allows the system to determine if the tracking object identifier set contains tracking object identifiers that match the various methods and class attributes in the target node. If the tracking object identifier set contains tracking object identifiers that match class methods or attributes, the matching tracking object identifier can be added using decorators and attribute descriptors, allowing for convenient event tracking without intruding into the code.

[0050] In an exemplary embodiment, by utilizing the decorator and the attribute descriptor corresponding to the class method, an event tracking object identified by the event tracking object identifier matching the class method is added after the class method. The specific implementation may include: modifying the second attribute descriptor corresponding to the class method based on the decorator, the original method of the class method, and the event tracking object identified by the event tracking object identifier matching the class method. The second attribute descriptor is the attribute descriptor executed when the class method is read. The execution result of the modified second attribute descriptor returns the original method of the class method and the event tracking object identified by the event tracking object identifier matching the class method.

[0051] The second attribute descriptor here can be `value`. For methods, there are no `get` and `set` attribute descriptors. In practical applications, for class methods within an instantiated class, `value` can be directly modified to contain the original method of that class method and the tracking object identified by the matching tracking object identifier. When the class method is executed, the original method can be executed first, followed by the logic of the tracking object. This achieves tracking of class methods in a simple way.

[0052] In the exemplary embodiment, the event tracking object is the event tracking object corresponding to the user input event. If there are multiple input events on the page, multiple event tracking objects can be quickly added on a single page, making it simple and easy to use. The input events can be click events, swipe events, etc., on the page.

[0053] The following uses a specific application scenario as an example to illustrate a more detailed method for embedding data points provided in this embodiment of the invention.

[0054] This solution provides an instrumentation approach that reduces code redundancy and improves readability. It has a degree of universality and is applicable to all JavaScript languages ​​that support decorators. This solution leverages decorators to modify the property descriptors of classes, class properties, and class methods, expanding instrumentation behavior without altering the original behavior. Decorators are used to handle the three types of decorated targets (i.e., target nodes): class properties, class methods, and classes themselves.

[0055] Decorators can provide `target`, `name`, and `descriptor`, where `target` represents the object to be decorated, `name` represents the property name of the object, and `descriptor` represents the property descriptor of the object. When the object to be decorated is a class, `name` and `descriptor` are not required.

[0056] Determine the type of the decoration target and select appropriate methods to add tracking points to the class, class attribute, and class method.

[0057] For class attributes, the class attribute is defined in the prototype object of the instantiated class containing the class attribute. The execution result of the attribute descriptor get that defines the class attribute returns the original attribute of the class attribute and the tracking object identified by the tracking object identifier that matches the class attribute.

[0058] For class methods, directly modify the corresponding property descriptor (descriptor.value) and attach the tracking object to the original method by overriding value.

[0059] For classes, first prepare the pairing relationship between class attributes or class methods and tracking objects. That is, the tracking object identifier set mentioned above contains the identifiers of tracking objects that match class attributes and class methods. Then, add tracking objects by combining the two strategies mentioned above.

[0060] The tracking object identifier set contains tracking objects that have a similar structure to the decorator target. For example, if the decorator target has a submit method, the tracking object also has a submit method. The difference is that the submit method on the tracking object can send tracking points. If the submit method on the decorator target is a method, then the tracking point extension strategy corresponding to the class method is used; if it is a property, then the tracking point extension strategy corresponding to the class property is used.

[0061] The tracking object can be configured with a `tracking` method, which can be executed in the context of the target node. This `tracking` method collects and sends tracking data (e.g., using the `submit` method). Specifically, when sending tracking data, a tracking tool (a tool for sending tracking data) can be called to report the tracking data.

[0062] After completing page initialization and event tracking, wait for the event tracking to be triggered. Throttling is applied to click events, treating consecutive clicks as a single click and sending one event tracking notification. Check if the pre-built event tracking tool is ready. Specifically, check if the code-generating method file exists on the global object `window` (i.e., whether it has been loaded). If ready, report the event tracking; otherwise, cache it in the cache queue and report it when ready again.

[0063] Traditional event tracking methods embed the tracking logic within the code, making it impossible to separate from other logic and impacting program readability. This solution, however, uses decorators to separate event tracking from business logic at the code level, enhancing code readability and mitigating the redundancy and poor readability associated with traditional event tracking. It not only maintains elegant and consistent code, making it more concise and visually distinct from business logic, but also reduces the time spent on event tracking. This solution is universally applicable, not limited to a single JavaScript framework, and suitable for all programs implemented using the Class syntax.

[0064] Furthermore, various tracking tools exist, each with different Application Programming Interfaces (APIs) and data format requirements. Therefore, it's necessary to configure tracking points to match the data format requirements for different tracking tools. This solution, however, converts the tracking data format to a format compatible with the tool before calling it, then passes it to the tool, and finally calls the tool to report the tracking points. Specifically, a format conversion function can be pre-defined outside the tracking object. In the `tracking` method, after collecting tracking points, the pre-defined conversion function is triggered to convert the tracking data format to a format compatible with the tool and pass it to the tool. Then, the tool is called to report the tracking points. This allows for customization and expansion to support multiple tracking tools with different data formats. A single tracking action can automatically adapt to multiple tracking tools with different data formats, making it simple and easy to use.

[0065] Figure 2 This is a schematic diagram of an exemplary embedded device according to an embodiment of the present invention. Figure 2 As shown, the embedded device 200 includes:

[0066] The determination module 201 is used to determine, during the page initialization process, whether the preset set of tracking object identifiers contains tracking object identifiers that match the target node. The target node is an instantiated class or a class attribute in an instantiated class contained in the page.

[0067] The event tracking module 202 is used to respond to the event tracking object identifier containing an event tracking object identifier that matches the target node by using the decorator and the attribute descriptor corresponding to the target node to add the event tracking object identified by the matching event tracking object identifier after the target node. The event tracking object is used to implement the event tracking behavior.

[0068] In one possible implementation, the event tracking module is specifically used to define, when the target node is a class attribute in an instantiated class, the class attribute in the prototype object corresponding to the target node, and the event tracking object identified by the decorator, the original attribute of the class attribute and the matching event tracking object identifier, and define a first attribute descriptor corresponding to the class attribute. The first attribute descriptor is an attribute descriptor that is executed when the class attribute is read. The execution result of the defined first attribute descriptor returns the original attribute of the class attribute and the event tracking object identified by the matching event tracking object identifier of the class attribute.

[0069] In one possible implementation, the event tracking module is specifically used to determine whether the event tracking object identifier set contains event tracking object identifiers that match the various methods and class attributes in the target node when the target node is an instantiated class.

[0070] In response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the class attribute in the target node, the tracking object identified by the tracking object identifier that matches the class attribute is added after the class attribute using the decorator and the attribute descriptor corresponding to the class attribute.

[0071] In response to a case where the set of tracking object identifiers contains tracking points that match the class method in the target node, the tracking object identified by the tracking object identifier that matches the class method is added after the class method using the decorator and the attribute descriptor corresponding to the class method.

[0072] In one possible implementation, the event tracking module is specifically used to modify the second attribute descriptor corresponding to the method based on the decorator, the original method of the method, and the event tracking object identified by the event tracking object identifier that matches the method. The second attribute descriptor is the attribute descriptor that is executed when the method is read. The execution result of the modified second attribute descriptor returns the original method of the method and the event tracking object identified by the event tracking object identifier that matches the method.

[0073] In one possible implementation, the tracking object is the tracking object corresponding to the user input event.

[0074] The functions of each module in each device of the present invention can be found in the corresponding descriptions in the above-described embedding method embodiments, and will not be repeated here.

[0075] Preferably, the present invention also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described data embedding method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0076] Figure 3This is a schematic diagram of the structure of an exemplary electronic device provided in an embodiment of the present invention. For example... Figure 3 As shown, the electronic device may include a processor 301, a communication interface 302, a memory 303, and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other via the communication bus 304. The processor 301 may call the computer program in the memory 303 to execute the data embedding method in any of the above embodiments.

[0077] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described data tracking method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0078] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0079] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the apparatus described in the various embodiments of the present invention.

[0080] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.

[0081] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0082] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0083] In the embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0084] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0085] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0086] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0087] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for embedding data points, characterized in that, include: During page initialization, it is determined whether the preset set of tracking object identifiers contains tracking object identifiers that match the target node, where the target node is an instantiated class or a class attribute of an instantiated class contained in the page. In response to the fact that the set of tracking object identifiers contains a tracking object identifier that matches the target node, the tracking object identified by the matching tracking object identifier is added after the target node using a decorator and the attribute descriptor corresponding to the target node. This includes: when the target node is a class attribute in an instantiated class, defining the class attribute in the prototype object corresponding to the target node; and defining a first attribute descriptor corresponding to the class attribute based on the decorator, the original attribute of the class attribute, and the tracking object identified by the matching tracking object identifier. The first attribute descriptor is the attribute descriptor executed when the class attribute is read. The execution result of the first attribute descriptor after definition returns the original attribute of the class attribute and the tracking object identified by the tracking object identifier that matches the class attribute; when the target node is a class method in an instantiated class, based on the decorator, the original method of the class method and the tracking object identified by the tracking object identifier that matches the class method, the second attribute descriptor corresponding to the class method is modified. The second attribute descriptor is the attribute descriptor executed when the class method is read. The execution result of the modified second attribute descriptor returns the original method of the class method and the tracking object identified by the tracking object identifier that matches the class method. The tracking object adds tracking points by obtaining the execution result returned by the attribute descriptor of the target node, or by attaching the attribute descriptor of the target node that has been directly overridden to the method.

2. The method according to claim 1, characterized in that, In response to the fact that the set of tracking object identifiers contains a tracking object identifier that matches the target node, the tracking object identified by the matching tracking object identifier is added after the target node using a decorator and the attribute descriptor corresponding to the target node, including: When the target node is an instantiated class, determine whether the set of tracking object identifiers contains tracking object identifiers that match the various methods and class attributes in the target node; In response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the class attribute in the target node, the tracking object identified by the tracking object identifier that matches the class attribute is added after the class attribute using a decorator and the attribute descriptor corresponding to the class attribute. In response to the fact that the set of tracking object identifiers contains tracking points that match the class method in the target node, the tracking object identified by the tracking object identifier that matches the class method is added after the class method using the decorator and the attribute descriptor corresponding to the class method.

3. The method according to claim 1, characterized in that, The event tracking object is the event tracking object corresponding to the user input event.

4. A device for embedding points, characterized in that, include: The determination module is used to determine, during the page initialization process, whether a preset set of tracking object identifiers contains a tracking object identifier that matches a target node, wherein the target node is an instantiated class or a class attribute of an instantiated class contained in the page. The event tracking module is configured to, in response to the event tracking object identifier set containing an event tracking object identifier matching the target node, add the event tracking object identified by the matching event tracking object identifier after the target node using a decorator and the attribute descriptor corresponding to the target node. This includes: when the target node is a class attribute in an instantiated class, defining the class attribute in the prototype object corresponding to the target node; and defining a first attribute descriptor corresponding to the class attribute based on the decorator, the original attribute of the class attribute, and the event tracking object identified by the matching event tracking object identifier. The first attribute descriptor is an attribute that is executed when the class attribute is read. The execution result of the first attribute descriptor after definition returns the original attribute of the class attribute and the tracking object identified by the tracking object identifier that matches the class attribute; when the target node is a class method in an instantiated class, the second attribute descriptor corresponding to the class method is modified based on the decorator, the original method of the class method, and the tracking object identified by the tracking object identifier that matches the class method. The second attribute descriptor is the attribute descriptor executed when the class method is read. The execution result of the modified second attribute descriptor returns the original method of the class method and the tracking object identified by the tracking object identifier that matches the class method. The tracking object adds tracking points by obtaining the execution result returned by the attribute descriptor of the target node, or by attaching the attribute descriptor of the target node that has been directly overridden to the method.

5. The apparatus according to claim 4, characterized in that, The event tracking module is specifically used to determine whether the event tracking object identifier set contains event tracking object identifiers that match the various methods and class attributes in the target node when the target node is an instantiated class. In response to the fact that the set of tracking object identifiers contains tracking object identifiers that match the class attribute in the target node, the tracking object identified by the tracking object identifier that matches the class attribute is added after the class attribute using a decorator and the attribute descriptor corresponding to the class attribute. In response to the fact that the set of tracking object identifiers contains tracking points that match the class method in the target node, the tracking object identified by the tracking object identifier that matches the class method is added after the class method using the decorator and the attribute descriptor corresponding to the class method.

6. The apparatus according to claim 4, characterized in that, The event tracking object is the event tracking object corresponding to the user input event.

7. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the embedding method as described in any one of claims 1 to 3.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the data embedding method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Buried point setting method and device, computer equipment and storage medium

    CN112363943A