Addressed review comments.

This commit is contained in:
Mark Beamer Jr 2018-12-27 15:08:24 -05:00
parent 258762da47
commit 37b51b8fd1
No known key found for this signature in database
GPG key ID: 1C314FB89AD76973
3 changed files with 15 additions and 6 deletions

View file

@ -12,7 +12,8 @@ class Session
const NAMESPACE_DEFAULT = 'default',
NAMESPACE_FLASH = 'flash',
NAMESPACE_FLASH_REMOVE = 'flash_remove',
USER_ID = 'user_id';
USER_ID = 'user_id',
SITE_ID = 'lbry.io';
public static function init()
{
@ -33,8 +34,15 @@ class Session
static::setNamespace(static::NAMESPACE_DEFAULT, $oldSession);
}
$response = LBRY::logWebVisitor('lbry.io', $_SESSION[static::USER_ID], $_SERVER['REMOTE_ADDR']);
$site_visitor_id = key_exists(static::USER_ID,$_SESSION) ? $_SESSION[static::USER_ID] : '';
$response = LBRY::logWebVisitor(static::SITE_ID, $site_visitor_id, $_SERVER['REMOTE_ADDR']);
if (key_exists('data',$response) && key_exists('visitor_id',$response['data']))
{
$_SESSION[static::USER_ID] = $response['data']['visitor_id'];
}else{
$_SESSION[static::USER_ID] = '';
}
static::initFlashes();
}

View file

@ -77,7 +77,10 @@ class LBRY
}
public static function logWebVisitor($site, $visitorID, $IPAddress)
{
if (IS_PRODUCTION)
{
return Curl::post(static::getApiUrl("/visitor/new"), ['site' => $site, 'visitor_id' => $visitorID, 'ip_address' => $IPAddress], ['json_response' => true]);
}
}
}

View file

@ -16,8 +16,6 @@
fbq('init', '1618717031725766',{uid: '<?php echo $_SESSION[Session::USER_ID] ?>'}));
fbq('track', '<?php echo Response::getFacebookPixelAnalyticsType() ?>');
<?php LBRY::logWebVisitor('lbry.io', $_SESSION[Session::USER_ID], $_SERVER['REMOTE_ADDR'])?>
</script>
<?php else: ?>
<script>