We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cip
It seems like tracker-proxy does not include token_auth and cip in bulk request . The X-Forwarded-For does not work with bulk requests on Matomo 5.
token_auth
X-Forwarded-For
For all bulk requests, the server IP is used on Matomo instead of the real forwarded IP address.
I took some liberty to add a few more methods to the file, it works but I did not test it for PHP < 7.4.
What works:
What seems to be broken:
Here's the code:
function isUsingBulkRequest($rawData) { if (!empty($rawData)) { return strpos($rawData, '"requests"') || strpos($rawData, "'requests'"); } return false; } function processBulkQuery($query, $extraParam = []) { $cleanedQuery = $query; if (substr($query, 0, 1)) { $cleanedQuery = substr($query, 1); } $parsedQuery = array(); $parsedUrl = parse_str($cleanedQuery, $parsedQuery); return '?' . http_build_query(array_merge($parsedQuery, $extraParam)); } function buildAuthBulkRequest($rawData, $auth_token, $cip) { $jsonData = json_decode($rawData, $assoc = true); if (!isset($jsonData['requests'])) { return $rawData; } $jsonData['token_auth'] = $auth_token; $extraQueryParams = [ "cip" => $cip, ]; $jsonData['requests'] = array_map( function($query) use ($extraQueryParams) { return processBulkQuery($query, $extraQueryParams); }, $jsonData['requests'] ); return json_encode($jsonData); }
Add the following code in the POST handler will add cip to the individual query and token_auth on the post body:
global $TOKEN_AUTH; $postBody = file_get_contents("php://input"); $isBulk = isUsingBulkRequest($postBody); ... if($isBulk) { $stream_options['http']['content'] = buildAuthBulkRequest($postBody, $TOKEN_AUTH, $visitIp); } $stream_options['http']['header'][] = "Content-Length: " . strlen($postBody);
original requests :
{ "requests": [ "?action=Page", ], "send_image": 0 }
expected result:
{ "requests": [ "?action=Page&cip=0.0.0.0", ], "send_image": 0, "token_auth": "TOKEN_AUTH" }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It seems like tracker-proxy does not include
token_auth
andcip
in bulk request .The
X-Forwarded-For
does not work with bulk requests on Matomo 5.For all bulk requests, the server IP is used on Matomo instead of the real forwarded IP address.
I took some liberty to add a few more methods to the file, it works but I did not test it for PHP < 7.4.
What works:
What seems to be broken:
cip
passed in the bulk request?)Here's the code:
Add the following code in the POST handler will add
cip
to the individual query andtoken_auth
on the post body:original requests :
expected result:
The text was updated successfully, but these errors were encountered: