Load Tracking payload directly via PHP?


Currently looking into how one would load tracking data via PHP, and would be grateful for some pointers on how to do this with PHP.

QueuedTracking plugin (https://github.com/matomo-org/plugin-QueuedTracking) does what I want but is using Mysql/Redis as a backend, I want to use regular files that is already generated by our internal tools and source for input for Matomo to process.

Example of JSON data, this is the same data that would be in Redis when tracking users via the QueuedTracking-plugin:

“tokenAuth”: false,
“time”: 1560838899,
“requests”: [
“_idts”: “1550496955”,
“_refts”: “1559545193”,
“idsite”: “8”,
“_id”: “24d69bbaddd5dd18”,
“rec”: “1”,
“fla”: “0”,
“_idn”: “0”,
“s”: “56”,
“wma”: “0”,
“r”: “772356”,
“gears”: “0”,
“gt_ms”: “13”,
“res”: “2560x1440”,
“cookie”: “1”,
“m”: “59”,
“ag”: “0”,
“_viewts”: “1559545193”,
“pv_id”: “Q4EzEA”,
“action_name”: “X”,
“java”: “0”,
“pdf”: “1”,
“realp”: “0”,
“url”: “X”,
“_idvc”: “60”,
“dir”: “0”,
“send_image”: “1”,
“h”: “8”,
“_ref”: “X”,
“qt”: “0”
“env”: {
“cookies”: {},
“server”: {
“MM_REGION”: “12”,
“HTTP_USER_AGENT”: “curl/7.64.0”,
“MM_CITY_GEONAMEID”: “3161732”,
“MM_ADDR”: “X”,
“REQUEST_TIME”: 1560838899,
“MM_POSTAL_CODE”: “5803”,
“HTTP_HOST”: “localhost”,
“MM_LONGITUDE”: “5.30590”,
“MM_ORG”: “BKK Digitek AS”,
“MM_CITY_NAME”: “Bergen”,
“SCRIPT_FILENAME”: “/var/www/matomo-tracker”,
“MM_REGION_NAME”: “Hordaland”,
“MM_ISP”: “BKK Digitek AS”,
“REQUEST_TIME_FLOAT”: “1560838899.023”,

How would I got about using Matomo, via PHP, to load this file and insert a Request ? AFAIK, I cannot post this data directly to matomo.php. As an example, QueuedTracking will load the above JSON string from the Redis queue and process it, but I’m not sure what code snippet (https://github.com/matomo-org/plugin-QueuedTracking/blob/master/Commands/Process.php) in QueuedTracking that is actually processing the request, and where error handling is done.

I’ve tried to look at the log-import tool as well for help (https://github.com/matomo-org/matomo-log-analytics), but that calls matomo.php via the webserver which in our case would create a lot of overhead.