Monday, October 29, 2012

Google Analytics and development/staging/production servers

It's common (best practice, actually) to have multiple copies of a site for development, staging, production, etc. Ideally you want to use the same code on all the sites. This can lead to an analytics problem -- having data from the dev and staging sites pollute the production data. One approach to dealing with this is to add a filter to the analytics profile to remove any data coming from the staging or dev servers.

I've starting modifying my analytics code as follows:
if (!/staging|localhost/.test(window.location.hostname))
 _gaq.push(['_setAccount', 'UA-XXXXX-X']);

In brief, if we're on our staging server, don't set the web property ID . This results in the tracker using a default ID -- something like "UA-99999-9".

Advantages:
  • The analytics code functions normally, but any data is sent to the default web property ID. This is nice because it's possible to verify that the analytics code is working.
Disadvantages:
  • More Javascript (the hostname comparison) that runs on every page.
Note: I used to put the conditional on the _trackPageview call -- The problem with this is that other analytics code (like _trackEvent, etc) will still be sending data.


Saturday, October 27, 2012

Building a Raspberry Pi Cross Compiler: could not retrieve eglibc-2_16

tl;dr svn is required to fetch eglibc-2_16 when building a Raspberry Pi cross compiler with crosstool-NG

The Raspberry Pi is a great little device. While it's possible to do compiles on the platform, because of limited memory/CPU, for bigger binaries it's faster to work on my regular desktop box.

I'm using crosstool-NG to build a toolchain for cross compiling binaries for the Raspberry Pi.
Following along Chris Boot's steps from How to build a cross compiler for your Raspberry Pi, the final build failed during the "Retrieving needed toolchain components' tarballs" step with the error

ct-ng could not retrieve eglibc-2_16

Looks like the the eglibc folk don't provide tarball releases, so svn is required to fetch eglibc.
Installed Subversion, and had a successful build.

Just for the records, the final list of packages needed for building the cross compiler were:
sudo apt-get -y install libssl-dev openssh-server git-core pkg-config build-essential curl gcc g++
sudo apt-get -y install bison flex gperf libtool texinfo gawk automake libncurses5-dev
sudo apt-get -y install subversion

Update: If you're planning on cross compiling Node.js (build time: 10 minutes instead of 2 hours!), make sure to enable C++ from within ct-ng menuconfig (under C-compiler > Additional supported languages)