From 1204ee0ce7b3f38bdeff35c93180081efe7fd6da Mon Sep 17 00:00:00 2001 From: Antonin Hildebrand Date: Thu, 8 Mar 2012 15:15:37 +0100 Subject: [PATCH] catch potential exceptions in leechgate_track_ga --- index.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/index.php b/index.php index 5495dc9..7d119fc 100644 --- a/index.php +++ b/index.php @@ -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) {