We recommend using a cron job to send logfile requests to the Mapp tracking server every few minutes and empty your file to keep it at a manageable size. You have two options:

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 array $config Mapp Intelligence config
 * @throws MappIntelligenceException Mapp Intelligence configuration exception
 */
$mappIntelligenceCronjob = new MappIntelligenceCronjob($config);
PHP

run

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

  • 0: All data was sent successfully.
  • 1: An error has occurred.
/**
 * @return int Status
 */
$mappIntelligenceCronjob->run();
PHP
Example
require_once __DIR__ . '/lib/MappIntelligenceCronjob.php'

$status = 1;
try {
	$mappIntelligenceConfig = new MappIntelligenceConfig();
	$mappIntelligenceConfig.setTrackId("111111111111111");
	$mappIntelligenceConfig.setTrackDomain("analytics01.wt-eu02.net");
	$mappIntelligenceConfig.setConsumerType(MappIntelligenceConsumerType::FILE_ROTATION);
	$mappIntelligenceConfig.setFilePath("/path/to/your/log/file/");
	$mappIntelligenceConfig.setFilePrefix("MappIntelligenceData");

    $cronjob = new MappIntelligenceCronjob($mappIntelligenceConfig);
 
    $status = $cronjob->run();
} catch (Exception $e) {}
 
exit($status)
PHP

Predefined Cron Job Script

This option allows you to use our predefined cronjob.php script, 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.
-t--consumerType

Enter your current file consumer type. Options: "FILE", "FILE_ROTATION". Defaults to "FILE".

-c--configEnter the path to your configuration file (*.ini).

-f--filename

Enter the path to your request logging file. Only relevant for file consumer type "FILE". Defaults to "/tmp/MappIntelligenceRequests.log".

-f--filePath

Enter the path to your request logging files. Only relevant for file consumer type "FILE_ROTATION". Defaults to "/tmp/".

-p--filePrefix

Enter the prefix for your request logging files. Only relevant for file consumer type "FILE_ROTATION". Defaults to "MappIntelligenceRequests".



--deactivateDeactivate the tracking functionality.

--debug

Activates the debug mode. The debug mode sends messages to the command line.


--helpDisplay the help and exit.

--versionDisplay version and exit.
Example
$ php cronjob.php -i 111111111111111 -d analytics01.wt-eu02.net -t FILE_ROTATION -f /tmp/ -p MappIntelligenceData
 
$ php cronjob.php -i 111111111111111 -d analytics01.wt-eu02.net -t FILE_ROTATION -f /tmp/ -p MappIntelligenceData --debug
 
 
$ php cronjob.php -c /path/to/your/configuration/file/config.ini
 
$ php cronjob.php -c /path/to/your/configuration/file/config.ini --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 * * * * php ./cronjob.php -c /path/to/your/configuration/file/config.ini
BASH