feat(analytics): ✨ add request status field
This commit is contained in:
parent
6ae06b4765
commit
73414fa639
4 changed files with 11 additions and 3 deletions
|
@ -8,7 +8,7 @@ interface AnalyticsInterface {
|
|||
public function log_path_access(
|
||||
$path,
|
||||
$agent,
|
||||
$referrer, $runtime);
|
||||
$referrer, $runtime, $status = 200);
|
||||
|
||||
public function log_path_errcode(
|
||||
$path,
|
||||
|
|
|
@ -72,7 +72,7 @@ class MySQLAnalyticsHandler
|
|||
$path,
|
||||
$agent,
|
||||
$referrer,
|
||||
$time) {
|
||||
$time, $status = 200) {
|
||||
|
||||
if(strlen($path) == 0) {
|
||||
$path = '/';
|
||||
|
@ -83,6 +83,7 @@ class MySQLAnalyticsHandler
|
|||
'path' => $path,
|
||||
'agent' => $agent,
|
||||
'referrer' => $referrer,
|
||||
'status' => $status
|
||||
], 'access_sum');
|
||||
|
||||
$this->increment_counter([
|
||||
|
|
|
@ -107,6 +107,8 @@ if($REQUEST_PATH == '/search/') {
|
|||
$post = $adapter->get_post($REQUEST_PATH);
|
||||
|
||||
if(!isset($post)) {
|
||||
$analytics_return_status = 404;
|
||||
|
||||
$error_page = $SITE_CONFIG['site_defaults'];
|
||||
$error_page['path'] = '/404';
|
||||
$error_page['title'] = '404 oh no';
|
||||
|
|
|
@ -5,6 +5,9 @@ $data_time_start = microtime(true);
|
|||
$analytics_enable_tail = false;
|
||||
$analytics_post = null;
|
||||
|
||||
$analytics_return_status = 200;
|
||||
|
||||
|
||||
function deduce_user_agent() {
|
||||
$real_agent=$_SERVER['HTTP_USER_AGENT'];
|
||||
|
||||
|
@ -34,6 +37,8 @@ register_shutdown_function(function() {
|
|||
|
||||
global $analytics_enable_tail;
|
||||
|
||||
global $analytics_return_status;
|
||||
|
||||
$data_time_end = microtime(true);
|
||||
|
||||
$http_referer = 'magic';
|
||||
|
@ -48,7 +53,7 @@ register_shutdown_function(function() {
|
|||
$analytics_adapter->log_path_access($REQUEST_PATH,
|
||||
deduce_user_agent(),
|
||||
$referrer,
|
||||
$compute_time);
|
||||
$compute_time, $analytics_return_status);
|
||||
|
||||
if($analytics_enable_tail) {
|
||||
echo "<!-- Total page time was: " . $compute_time . " -->";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue