Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for collecting a multi-platform user behavior log, an electronic device, and a computer readable medium, which can reduce the maintenance cost of a js (javascript) script, have a clear overall architecture and strong maintainability, improve readability, perform special service independent module processing, continue to be extensible, add service modules for different application scenarios, and implement rapid and accurate function extension by adjusting a configuration file in real time.
To achieve the above object, according to an aspect of the embodiments of the present invention, a method for collecting a multi-platform user behavior log is provided.
A method for collecting a multi-platform user behavior log comprises the following steps: acquiring scripts of a plurality of platforms for acquiring user behavior logs, and extracting information for acquiring basic service logs and information for acquiring platform-specific service logs from the scripts; generating a basic log acquisition module according to the information of the acquired basic service log, and generating a special service log acquisition module according to the information of the service log specific to the acquisition platform; when a user behavior log is collected for a preset platform in the plurality of platforms, a corresponding special service log collection module is configured according to the special service of the preset platform, and a script for collecting the user behavior log of the preset platform is generated according to the basic log collection module and the configured special service log collection module.
Optionally, the information for acquiring the basic service log includes a minimum set of basic fields for acquiring the user behavior by the scripts, and further includes service logic and corresponding reporting fields shared by the scripts; the information of the service log specific to the acquisition platform comprises service logic specific to each script in the plurality of scripts and a corresponding reporting field.
Optionally, the script for collecting the user behavior log of the preset platform collects the log according to a log reporting mode specified by one of the scripts.
Optionally, the plurality of platforms includes a fixed client platform and a mobile client platform.
Optionally, the fixed client platform includes a PC end platform, and the mobile client platform includes a mobile phone M end platform.
Optionally, the corresponding special service log collection module is configured according to the special service of the preset platform through a configuration file, and the configuration file further includes a specified execution sequence of the configured special service log collection module, and information of function description and logic description of the configured basic log collection module and each special service log collection module.
According to another aspect of the embodiment of the invention, a device for acquiring a multi-platform user behavior log is provided.
An acquisition apparatus for a multi-platform user behavior log, comprising: the extraction module is used for acquiring scripts of the plurality of platforms for acquiring the user behavior logs and extracting information for acquiring basic service logs and information for acquiring platform-specific service logs from the plurality of scripts; the generating module is used for generating a basic log collecting module according to the information of the collected basic service logs and generating a special service log collecting module according to the information of the special service logs of the collecting platform; and the configuration module is used for configuring a corresponding special service log acquisition module according to the specific service of a preset platform when the user behavior log is acquired by a preset platform in the plurality of platforms, and generating a script for acquiring the user behavior log of the preset platform according to the basic log acquisition module and the configured special service log acquisition module.
Optionally, the information for acquiring the basic service log includes a minimum set of basic fields for acquiring the user behavior by the scripts, and further includes service logic and corresponding reporting fields shared by the scripts; the information of the service log specific to the acquisition platform comprises service logic specific to each script in the plurality of scripts and a corresponding reporting field.
Optionally, the script for collecting the user behavior log of the preset platform collects the log according to a log reporting mode specified by one of the scripts.
Optionally, the plurality of platforms includes a fixed client platform and a mobile client platform.
Optionally, the fixed client platform includes a PC end platform, and the mobile client platform includes a mobile phone M end platform.
Optionally, the configuration module configures a corresponding special service log acquisition module according to the specific service of the preset platform through a configuration file, where the configuration file further includes a specified execution sequence of the configured special service log acquisition modules, and information of function description and logic description of the configured basic log acquisition module and each special service log acquisition module.
According to yet another aspect of an embodiment of the present invention, an electronic device is provided.
An electronic device, comprising: one or more processors; a memory for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement a method for collecting a multi-platform user behavior log.
According to yet another aspect of embodiments of the present invention, a computer-readable medium is provided.
A computer-readable medium, on which a computer program is stored which, when executed by a processor, implements a method of collecting a multi-platform user behavior log.
One embodiment of the above invention has the following advantages or benefits: the method comprises the steps of extracting information for acquiring basic service logs and information for acquiring platform-specific service logs from scripts for acquiring user behavior logs of a plurality of platforms, generating a basic log acquisition module according to the information for acquiring the basic service logs, generating a special service log acquisition module according to the information for acquiring the platform-specific service logs, configuring a corresponding special service log acquisition module according to specific services of a preset platform when a user behavior log is acquired for a preset platform of the plurality of platforms, and generating a script for acquiring the user behavior log of the preset platform according to the basic log acquisition module and the configured special service log acquisition module. Therefore, the maintenance cost of a JS (JavaScript) script can be reduced, the whole framework is clear and has strong maintainability and readability is improved by modularizing each functional area, continuous expandability is realized by processing the special service independent modules, the service modules can be added according to different application scenes, and quick and accurate function expansion can be realized by adjusting the configuration files in real time.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram illustrating main steps of a method for collecting a multi-platform user behavior log according to an embodiment of the present invention.
As shown in fig. 1, the method for collecting a multi-platform user behavior log according to the embodiment of the present invention mainly includes the following steps S11 to S13.
Step S11: the method comprises the steps of obtaining scripts of a plurality of platforms for collecting user behavior logs, and extracting information for collecting basic service logs and information for collecting platform-specific service logs from the scripts.
The plurality of platforms may include a fixed client platform, which may include a PC-side platform, and a mobile client platform, which may include a mobile phone M-side (mobile client) platform. The embodiment of the invention assumes that different JS scripts exist in platforms such as a PC end platform, an M end platform (such as an h5 page (html5 page)), and the like, but JS scripts of other platforms except the PC end platform are derived from the JS scripts of the PC end platform.
The information for acquiring the basic service log can be the minimum common factor of the JS scripts of each platform, and mainly comprises a minimum set of basic fields for acquiring the user behaviors by the scripts, service logic shared by the scripts and corresponding reporting fields. The minimum set of basic fields of a plurality of scripts for acquiring user behaviors is mainly some basic content fields, for example, the minimum set may include access time, access address, visitor identification, some basic information of an access page, such as page title, browser model and version, screen resolution, and the like, and complete and detailed basic content fields may be formulated according to specific needs. Basic information of a user accessing a platform, such as user related information, accessed page basic information and the like, can be collected by configuring the basic content fields. The service logic shared by the scripts is mainly the service logic corresponding to the log of the service shared by all the platforms, for example, if the statistical reporting user identifier is the service logic shared by the fixed client platform and the mobile client platform, the service logic of the statistical reporting user identifier and the corresponding field of the reporting user identifier are extracted and used as a part of the information for collecting the basic service log.
The information of the service log specific to the acquisition platform comprises service logic specific to each script in the plurality of scripts and a corresponding reporting field. For example, assuming that the level of the reported user access page is the service logic specific to the mobile client platform, the service logic of the level of the reported user access page and the corresponding field of the reported page level are extracted as a part of the information for collecting the service log specific to the platform.
Step S12: and generating a basic log acquisition module according to the information of the acquired basic service log, and generating a special service log acquisition module according to the information of the service log specific to the acquisition platform.
The basic log collection module is generated according to the processing logic related to information compiling of the collected basic service logs, and the special service log collection module is formed according to the processing logic related to information compiling of the special service logs of the collection platform, so that the collected log contents can be flexibly configured according to service requirements through the modularized assembly. The generated basic log collection module and the special service log collection module are stored in a code module pool, and the code module pool can be a function library packaged in the form of a jar packet.
FIG. 2 is a schematic diagram of a pool of code modules according to an embodiment of the present invention. Each special service log collection module in the code module pool shown in fig. 2 may also be stored according to the platform identifier and the service name of the module, for example, the special service log collection module of the M-end platform is stored as M + aa, and aa represents aa service specific to the M-end platform.
Step S13: when a user behavior log is acquired for a preset platform in a plurality of platforms, a corresponding special service log acquisition module is configured according to the special service of the preset platform, and a script for acquiring the user behavior log of the preset platform is generated according to the basic log acquisition module and the configured special service log acquisition module.
The corresponding special service log acquisition module can be configured according to the special service of the preset platform through the configuration file. The configuration file can be used as a container for executing the log collection module, and it must contain the basic log collection module, and if the configuration file only contains the basic log collection module, the basic information accessed by the user, such as the user-related information, the accessed page basic information, etc., can be collected. If the configuration file includes the special service log collection module, the reporting content information is added in the basic reporting mode, such as the result information of the searched commodities in the website, the inherent attribute (price, goods existence state, commodity specification size, etc.) information on the commodity display page, and the like. The special service log acquisition module is optional, different platforms can use the special service log acquisition module corresponding to respective special service, and the configured special service log acquisition module can be added or adjusted in the configuration file.
The configuration file also comprises the execution sequence of the specified configured special service log acquisition modules, and the information of the function description and the logic description of the configured basic log acquisition modules and each special service log acquisition module.
The information of the function description and the logic description provides enough information for facilitating the special service log acquisition module of the configuration file and the sequential selection, and the function description and the logic description information can be referred to and supplemented even when the special service log acquisition module is newly added, so that the code maintenance cost can be reduced, and the work efficiency of a research and development engineer is improved.
Configuring a corresponding special service log acquisition module according to the special service of a preset platform, generating a script for acquiring a user behavior log of the preset platform according to a basic log acquisition module and the configured special service log acquisition module, calling the configuration file by the script when log acquisition is executed, and executing the basic log acquisition module and the configured special service log acquisition module according to a specified execution sequence, wherein the configured special service log acquisition module can be executed according to the sequence of the modules configured in the configuration file. According to the requirement, the script for collecting the user behavior log of the preset platform can also be added with an abnormal condition processing mechanism, a library for introducing standard input and output and the like.
In addition, the script for collecting the user behavior log of the preset platform can collect the log according to a log reporting mode specified by one of the scripts. The log reporting mode of each script may include, for example, reporting a log request one by one, reporting a plurality of logs together by packaging, reporting by using an independent interface function called separately or directly calling a reporting interface function in the JS script, and different reporting modes may also be used for different log types.
The whole code framework is adopted for maintaining the configuration file, the code maintenance cost is reduced, the log acquisition modules of the basic service and the special service are independent and do not influence each other, the modules are managed through the configuration file, the framework is clear and reasonable, the integration is easy, the readability is improved, the independent special service log acquisition modules can be compiled aiming at different application scenes, the corresponding special service log acquisition modules are added in the configuration file, and the expandability is high.
Fig. 3 is a schematic diagram of main modules of an apparatus for acquiring a multi-platform user behavior log according to an embodiment of the present invention.
As shown in fig. 3, the apparatus 30 for acquiring a multi-platform user behavior log according to an embodiment of the present invention mainly includes: an extraction module 301, a generation module 302 and a configuration module 303. The plurality of platforms may include a fixed client platform and a mobile client platform, the fixed client platform may include a PC end platform, and the mobile client platform may include a mobile phone M end platform.
The extraction module 301 is configured to obtain scripts of a plurality of platforms, which are used for collecting user behavior logs, and extract information of collecting basic service logs and information of collecting platform-specific service logs from the scripts.
The information for acquiring the basic service log comprises a minimum set of basic fields for acquiring the user behaviors by the scripts and service logic shared by the scripts and corresponding reporting fields; the information of the service log specific to the acquisition platform comprises service logic specific to each script in the plurality of scripts and a corresponding reporting field.
The generating module 302 is configured to generate a basic log collecting module according to information of collecting basic service logs, and generate a special service log collecting module according to information of collecting platform-specific service logs.
The configuration module 303 is configured to configure a corresponding special service log acquisition module according to a specific service of a preset platform when acquiring a user behavior log for a preset platform of the multiple platforms, and generate a script for acquiring the user behavior log of the preset platform according to the basic log acquisition module and the configured special service log acquisition module.
Specifically, the configuration module 303 may configure the corresponding special service log acquisition module according to the specific service of the preset platform through the configuration file, where the configuration file further includes a specified execution sequence of the configured special service log acquisition module, and information of the function description and the logic description of the configured basic log acquisition module and each special service log acquisition module.
The script for collecting the user behavior log of the preset platform can collect the log according to a log reporting mode specified by one script in the plurality of scripts.
Referring now to FIG. 4, shown is a block diagram of a computer system 400 suitable for use in implementing the electronic device of an embodiment of the present application. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 4, the computer system 400 includes a Central Processing Unit (CPU)401 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the system 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406 including a keyboard, a mouse, and the like; an output section 407 including a display device such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. A driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 410 as necessary, so that a computer program read out therefrom is mounted into the storage section 408 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above in the main step schematic of the collection method of the multi-platform user behavior log may be implemented as computer software programs. For example, the disclosed embodiments of the invention include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the main step diagram. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 409, and/or installed from the removable medium 411. The above-described functions defined in the system of the present application are executed when the computer program is executed by a Central Processing Unit (CPU) 401.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The principal step diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the main step diagram may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the main step diagram, and combinations of blocks in the main step diagram, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes an extraction module 301, a generation module 302, a configuration module 303. The names of these modules do not constitute a limitation to the module itself in some cases, for example, the extraction module 301 may also be described as "a module for acquiring a script for collecting user behavior logs of a plurality of platforms and extracting information for collecting basic service logs and information for collecting platform-specific service logs from the plurality of scripts".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: acquiring scripts of a plurality of platforms for acquiring user behavior logs, and extracting information for acquiring basic service logs and information for acquiring platform-specific service logs from the scripts; generating a basic log acquisition module according to the information of the acquired basic service log, and generating a special service log acquisition module according to the information of the service log specific to the acquisition platform; when a user behavior log is acquired for a preset platform in a plurality of platforms, a corresponding special service log acquisition module is configured according to the special service of the preset platform, and a script for acquiring the user behavior log of the preset platform is generated according to the basic log acquisition module and the configured special service log acquisition module.
According to the technical scheme of the embodiment of the invention, the information for acquiring the basic service logs and the information for acquiring the special service logs of the platform are extracted from the scripts for acquiring the user behavior logs of the platforms, the basic log acquisition module is generated according to the information for acquiring the basic service logs, the special service log acquisition module is generated according to the information for acquiring the special service logs of the platform, when the user behavior logs of one preset platform of the platforms are acquired, the corresponding special service log acquisition module is configured according to the special service of the preset platform, and the scripts for acquiring the user behavior logs of the preset platform are generated according to the basic log acquisition module and the configured special service log acquisition module. Therefore, the maintenance cost of a JS (JavaScript) script can be reduced, the whole framework is clear and has strong maintainability and readability is improved by modularizing each functional area, continuous expandability is realized by processing the special service independent modules, the service modules can be added according to different application scenes, and quick and accurate function expansion can be realized by adjusting the configuration files in real time.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.