We recommend using a cron job which will send logfile requests to the Mapp tracking server every few minutes, and empty your file to keep it at a manageable size. There are two options:  Custom and Predefined. 

Custom Cron Job File

This option requires you to write your own cron job file and use our MappIntelligenceCronjob class.

Methods

constructor

For a complete configuration of the Mapp Intelligence Cronjob please check Configuration.

/**
 * @param config Mapp Intelligence config
 * @throws MappIntelligenceException Mapp Intelligence configuration exception
 */
const cronjob = new MappIntelligenceCronjob(config: MappIntelligenceConfig);
JS
run

Send the logfile requests to the Mapp tracking server and delete your logfiles to keep it at a manageable size. Returns the following results:

  • 0: All data was sent successfully.
  • 1: An error has occurred.
/**
 * @return Promise<number>
 */
cronjob.run();
JS

Example

import {MappIntelligenceConfig, MappIntelligenceCronjob} from '@mapp-intelligence/node';

(async function() {
	let status = 1;
    try {
		const mappIntelligenceConfig = new MappIntelligenceConfig();
		mappIntelligenceConfig.setTrackId("111111111111111");
		mappIntelligenceConfig.setTrackDomain("analytics01.wt-eu02.net");
		mappIntelligenceConfig.setFilePath("/path/to/your/log/file/");
		mappIntelligenceConfig.setFilePrefix("MappIntelligenceData");
			
        const cronjob = new MappIntelligenceCronjob(mappIntelligenceConfig);
        status = await cronjob.run();
	} catch (Exception e) {
    	// do nothing
    }

    process.exit(status);
})();
JS

Predefined Cron Job Script

This option allows you to use our predefined mapp-intelligence-java-cronjob.jar file, which is included in our repository

Short notationLong notationDescription
-i--trackIdEnter your Mapp Intelligence track ID provided by Mapp.
-d--trackDomainEnter your Mapp Intelligence tracking URL.
-f--filePathEnter the path to your request logging file.
-p--filePrefixEnter the prefix for your request logging files.

-c--configEnter the path to your configuration file (*.json or *.js).


--debugActivates the debug mode. The debug mode sends messages to the command line.

--deactivateDeactivate the tracking functionality.

--helpDisplay the help (this text) and exit.

--versionDisplay version and exit.

Example

$ mapp-intelligence-node -i 111111111111111 -d analytics01.wt-eu02.net -f /tmp/ -p MappIntelligenceData
 
$ mapp-intelligence-node -i 111111111111111 -d analytics01.wt-eu02.net -f /tmp/ -p MappIntelligenceData --debug
 
 
$ mapp-intelligence-node -c /path/to/your/configuration/file/config.json
 
$ mapp-intelligence-node -c /path/to/your/configuration/file/config.json --debug
BASH

Define a Cron Job

To create your crontab file, type the following command at the shell prompt crontab -e and add the following lines:

# sends every five minutes the tracking data to the Mapp tracking serve
*/5 * * * * mapp-intelligence-node -c /path/to/your/configuration/file/config.json
BASH