plesk / matomo-tracking-cli

Matomo TrackingCLI Plugin. Import tracking data to Matomo via CLI and stdin.
Apache License 2.0
2 stars 1 forks source link

Feature request: import raw JSON data #1

Open toredash opened 5 years ago

toredash commented 5 years ago

Hi @ekaragodin ,

I noticed this plugin with the 3.10 release.

Would it be possible to add support for loading "raw" JSON tracking data ? That would make it easier to import tracking data when the number of tracking elements ( https://developer.matomo.org/api-reference/tracking-api ) varies for each request.

A sample tracking event that I would like to import looks like this:

{
“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”,
“MM_LOCATION_TIMEZONE”: “Europe/Oslo”,
“MM_CONTINENT_GEONAMEID”: “6255148”,
“MM_LATITUDE”: “X”,
“MM_REGISTERED_COUNTRY_ISO”: “NO”,
“HTTP_USER_AGENT”: “curl/7.64.0”,
“MMDB_ADDR”: “X”,
“MM_CITY_GEONAMEID”: “3161732”,
“MM_ADDR”: “X”,
“REQUEST_URI”: “/X”,
“REQUEST_TIME”: 1560838899,
“MM_CONTINENT_NAME”: “Europe”,
“HTTP_X_FORWARDED_FOR”: “X”,
“MM_POSTAL_CODE”: “5803”,
“QUERY_STRING”: “X”,
“HTTP_HOST”: “localhost”,
“REMOTE_ADDR”: “X”,
“MM_LONGITUDE”: “5.30590”,
“MM_REGISTERED_COUNTRY_NAME”: “Norway”,
“MM_REGISTERED_COUNTRY_GEONAMEID”: “3144096”,
“MM_ORG”: “BKK Digitek AS”,
“MM_REGION_GEONAMEID”: “3151864”,
“MM_CITY_NAME”: “Bergen”,
“MM_COUNTRY_GEONAMEID”: “3144096”,
“MM_LOCATION_ACCURACY_RADIUS”: “100”,
“SCRIPT_FILENAME”: “/var/www/matomo-tracker”,
“MM_COUNTRY_CODE”: “NO”,
“MM_CONTINENT_CODE”: “EU”,
“MM_REGION_NAME”: “Hordaland”,
“MM_ISP”: “BKK Digitek AS”,
“HTTP_ACCEPT”: “/”,
“REQUEST_TIME_FLOAT”: “1560838899.023”,
“MM_COUNTRY_NAME”: “Norway”
}
}
}

For a simple ping tracking event (https://developer.matomo.org/guides/tracking-javascript-guide#accurately-measure-the-time-spent-on-each-page) that amount of data in the request would look very differently.

The above sample payload is created by the QueuedTracking-plugin ( https://github.com/matomo-org/plugin-QueuedTracking/ ) and that would be stored in Redis for later processing.

I do not know PHP well enough to create a PR for this, pointers or suggestions welcome, thanks!

ekaragodin commented 5 years ago

summon @dshiryaev-plesk