Cron Job
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
constructorFor 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);
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();
Example
import {MappIntelligenceConfig, MappIntelligenceCronjob} from '@mapp-intelligence/node';
(async function() {
const 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);
})();
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 notation | Long notation | Description |
---|---|---|
-i | --trackId | Enter your Mapp Intelligence track ID provided by Mapp. |
-d | --trackDomain | Enter your Mapp Intelligence tracking URL. |
-f | --filePath | Enter the path to your request logging file. |
-p | --filePrefix | Enter the prefix for your request logging files. |
-c | --config | Enter the path to your configuration file (*.json or *.js). |
--debug | Activates the debug mode. The debug mode sends messages to the command line. | |
--deactivate | Deactivate the tracking functionality. | |
--help | Display the help (this text) and exit. | |
--version | Display 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
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