Permalink
Browse files

catch potential exceptions in leechgate_track_ga

  • Loading branch information...
1 parent 4b3fb3d commit 1204ee0ce7b3f38bdeff35c93180081efe7fd6da @darwin committed Mar 8, 2012
Showing with 16 additions and 12 deletions.
  1. +16 −12 index.php
View
@@ -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) {

0 comments on commit 1204ee0

Please sign in to comment.