django-hoptoad/config/index.html @ c63538ce40e1

hg-prompt: Update documentation.
author Steve Losh <steve@stevelosh.com>
date Sun, 10 Jan 2010 18:18:04 -0500
parents 825cda6146fa
children 64399c0fed7a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
      xmlns:foaf="http://xmlns.com/foaf/0.1/">
  
  <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    
    <title>
      django-hoptoad » Configuration
    </title>
    
    <link rel="stylesheet" type="text/css" href="../media/css/reset.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="../media/css/layout.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="../media/css/typography.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="../media/css/pygments.css" media="screen, projection" />
  </head>
  
  <body>
    <div id="content">

      
        <div id="breadcrumbs">
          <p>
              
                
                  <a href="../">index</a> &#187;
                
              
                
                  config
                
              
          </p>
        </div> <!-- div#breadcrumbs -->
      
      
      
  <h1 id="configuration">Configuration</h1>
<p>There are a few extra things you can configure if you'd like to tweak the notification process a bit.</p>
<div class="toc">
<ul>
<li><a href="#configuration">Configuration</a><ul>
<li><a href="#notify-hoptoad-while-in-debug-mode">Notify Hoptoad While in DEBUG Mode</a></li>
<li><a href="#specify-a-default-timeout">Specify a Default Timeout</a></li>
<li><a href="#track-404-errors">Track 404 Errors</a></li>
<li><a href="#track-403-errors">Track 403 Errors</a></li>
<li><a href="#ignore-specific-user-agents">Ignore Specific User Agents</a></li>
<li><a href="#problems">Problems?</a></li>
</ul>
</li>
</ul>
</div>
<h2 id="notify-hoptoad-while-in-debug-mode">Notify Hoptoad While in DEBUG Mode</h2>
<p>By default the Middleware will <strong>not</strong> report errors to Hoptoad when your project is in <code>DEBUG</code> mode.  The idea behind this is that if you can already see the error information right in the browser you probably don't need to see it in Hoptoad too.  If you want to always notify Hoptoad of errors, even while in <code>DEBUG</code> mode, add the following setting:</p>
<div class="codehilite"><pre><span class="n">HOPTOAD_NOTIFY_WHILE_DEBUG</span> <span class="o">=</span> <span class="n">True</span>
</pre></div>


<h2 id="specify-a-default-timeout">Specify a Default Timeout</h2>
<p>By default, the amount of time the notifier will wait before giving up on contacting Hoptoad is Python's "global default timeout setting".  I have no idea what that is because the <a href="http://docs.python.org/library/urllib2.html">documentation</a> does not see fit to explain that to me.</p>
<p>If you'd like to change that amount you can use the <code>HOPTOAD_TIMEOUT</code> setting.  You <strong>must</strong> be running Python 2.6+ to use this.</p>
<div class="codehilite"><pre><span class="n">HOPTOAD_TIMEOUT</span> <span class="o">=</span> <span class="mi">5</span>
</pre></div>


<p>The number is the number of seconds the notifier will wait before timing out.  Yes, you can use a float like <code>0.5</code> to specify fractions of a second.</p>
<h2 id="track-404-errors">Track 404 Errors</h2>
<p>By default Hoptoad will <strong>not</strong> be notified of 404 (page not found) errors.  If you'd like to change this you'll need to add the following setting:</p>
<div class="codehilite"><pre><span class="n">HOPTOAD_NOTIFY_404</span> <span class="o">=</span> <span class="n">True</span>
</pre></div>


<p><strong>IMPORTANT</strong>: If you are using Django's <code>flatpages</code> app and want to track 404 errors, you need to make sure the <code>FlatpageFallbackMiddleware</code> comes <em>after</em> the <code>HoptoadNotifierMiddleware</code>.  If you don't do this Hoptoad will be notified of 404 errors even if the user actually sees a Flatpage.</p>
<p>To track 404s while using the <code>flatpages</code> app your <code>MIDDLEWARE_CLASSES</code> setting should look like this:</p>
<div class="codehilite"><pre><span class="n">MIDDLEWARE_CLASSES</span> <span class="o">=</span> <span class="p">(</span>
    <span class="c1"># ... other middleware classes ...</span>
    <span class="s">&#39;hoptoad.middleware.HoptoadNotifierMiddleware&#39;</span><span class="p">,</span>
    <span class="s">&#39;django.contrib.flatpages.middleware.FlatpageFallbackMiddleware&#39;</span><span class="p">,</span>
<span class="p">)</span>
</pre></div>


<p>A couple of things to note:</p>
<ul>
<li>If your website doesn't have a favicon specified most browsers will request it each time.  This will result in one (or possibly two, if it tries to append a slash) 404 errors for every page view.</li>
<li>At the moment all 404 errors are grouped together as "similar" errors in Hoptoad.  I am trying to figure out what causes this.</li>
</ul>
<h2 id="track-403-errors">Track 403 Errors</h2>
<p>By default Hoptoad will <strong>not</strong> be notified of 403 (forbidden) errors.  If you'd like to change this you'll need to add the following setting:</p>
<div class="codehilite"><pre><span class="n">HOPTOAD_NOTIFY_403</span> <span class="o">=</span> <span class="n">True</span>
</pre></div>


<p>Note:</p>
<ul>
<li>At the moment all 403 errors are grouped together as "similar" errors in Hoptoad.  I am trying to figure out what causes this.</li>
</ul>
<h2 id="ignore-specific-user-agents">Ignore Specific User Agents</h2>
<p>If you'd like to ignore all errors from certain User Agents you can use the following setting:</p>
<div class="codehilite"><pre><span class="n">HOPTOAD_IGNORE_AGENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;MSIE 6.0&#39;</span><span class="p">,</span> <span class="s">&#39;Trident&#39;</span><span class="p">]</span>
</pre></div>


<p>If any of the strings in the list appear <em>anywhere</em> in the User Agent string, Hoptoad will not be notified of the error.</p>
<p>The strings are actually regular expressions, so you can be more specific if you like:</p>
<div class="codehilite"><pre><span class="n">HOPTOAD_IGNORE_AGENTS</span> <span class="o">=</span> <span class="p">[</span><span class="n">r</span><span class="s">&#39;^Mozilla.*compatible; MSIE \d+\.\d+.*$&#39;</span><span class="p">]</span>
</pre></div>


<p>One thing this is useful for (aside from hating on IE) is ignoring errors from web crawlers.  Often bots will mangle URLs and if you're tracking 404 errors you'll see a <em>lot</em> of errors that you probably don't care about.</p>
<p>This would probably be a good starting point for ignoring crawlers:</p>
<div class="codehilite"><pre><span class="n">HOPTOAD_IGNORE_AGENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Googlebot&#39;</span><span class="p">,</span> <span class="s">&#39;Yahoo! Slurp&#39;</span><span class="p">,</span> <span class="s">&#39;YahooSeeker&#39;</span><span class="p">]</span>
</pre></div>


<h2 id="problems">Problems?</h2>
<p>If you're having trouble you might want to take a look at the <a href="../troubleshooting/">Troubleshooting Guide</a>.</p>

    
      <p id="footer">
        
          django-hoptoad —
        
        Powered by <a href="http://bitbucket.org/zacharyvoase/markdoc">Markdoc</a>.
      </p>
    
    </div> <!-- div#content -->
  </body>
</html>