Skip to content

Commit

Permalink
catch potential exceptions in leechgate_track_ga
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Mar 8, 2012
1 parent 4b3fb3d commit 1204ee0
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions index.php
Expand Up @@ -90,19 +90,23 @@ function leechgate_expand_config(&$config) {
}

function leechgate_track_ga($config) {
// prepare GA structures
$tracker = new GoogleAnalytics\Tracker($config['gaid'], $config['normalized_host']);
$visitor = new GoogleAnalytics\Visitor();
$visitor->fromServerVar($_SERVER);
if ($config['utma_cookie']) {
$visitor->fromUtma($config['utma_cookie']);
}
$session = new GoogleAnalytics\Session();
$event = new GoogleAnalytics\Event($config['normalized_host'], $config['product'], $config['product_version']);
$event->setNoninteraction(true);
try {
// prepare GA structures
$tracker = new GoogleAnalytics\Tracker($config['gaid'], $config['normalized_host']);
$visitor = new GoogleAnalytics\Visitor();
$visitor->fromServerVar($_SERVER);
if ($config['utma_cookie']) {
$visitor->fromUtma($config['utma_cookie']);
}
$session = new GoogleAnalytics\Session();
$event = new GoogleAnalytics\Event($config['normalized_host'], $config['product'], $config['product_version']);
$event->setNoninteraction(true);

// track it!
$tracker->trackEvent($event, $session, $visitor);
// track it!
$tracker->trackEvent($event, $session, $visitor);
} catch (Exception $e) {
fwrite(STDERR, "Caught exception in leechgate_track_ga: ".$e->getMessage()."\n");
}
}

function leechgate_redirect($config) {
Expand Down

0 comments on commit 1204ee0

Please sign in to comment.