Skip to content

Instantly share code, notes, and snippets.

@vtsatskin
Created March 4, 2014 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vtsatskin/9337436 to your computer and use it in GitHub Desktop.
Save vtsatskin/9337436 to your computer and use it in GitHub Desktop.
Firefox Network Error Message Rate of Occurances

Firefox Network Error Message Rate of Occurances

A quick and dirty analysis of the rate of the occurances of different network errors. The data source used was from testpilot.

Results

output.english.only.json contains each error message with their rate of occurances.

Notes

Any errors in locales other than en-US was discarded manually in the results. See comments in parse.js for more information.

{
"The connection was reset": 19656,
"Server not found": 75285,
"This Connection is Untrusted": 1317,
"Document Expired": 4700,
"Unable to connect": 7049,
"The connection has timed out": 12024,
"File not found": 807,
"Well, this is embarrassing.": 459,
"Private Browsing": 733,
"Content Encoding Error": 169,
"The page isn't redirecting properly": 272,
"The proxy server is refusing connections": 656,
"The connection was interrupted": 292,
"The address isn't valid": 112,
"Offline mode": 30,
"Secure Connection Failed": 192,
"Unable to find the proxy server": 108,
"Corrupted Content Error": 29,
"Connection Interrupted": 1,
"Address Not Found": 2,
"Welcome Humans!": 4,
"Oops.": 2,
"This address is restricted": 25,
}
// This file will parse testPilot's heatmap data and extract the occurances
// of the different types of error messages.
// For example: "Server not found", "Connection reset", "Untrusted connection", etc
// The results will be outputted to the file specified in OUTPUT_FILE.
// NOTE: This will not aggregate error messages in different locales.
// For example, "Server not found" and "Servidor no encontrado" will be two different errors.
const FILE = "testpilot_heatmap17_10.json";
const NETERROR_EVENT_NAME = "404 page";
const OUTPUT_FILE = "output.json";
var fs = require('fs'),
readline = require('readline');
var rd = readline.createInterface({
input: fs.createReadStream(FILE),
output: process.stdout,
terminal: false
});
var netErrors = {};
var readOnce = false;
rd.on('line', function(line) {
var userData = convertDataLineToObject(line);
userData && userData.events.forEach(function(event){
// Example of representation of an event:
// [1, "404 page", "The connection was reset", "pageload", 1355916017671]
if(event[1] == NETERROR_EVENT_NAME) {
netErrors[event[2]] = netErrors[event[2]] ? netErrors[event[2]] + 1 : 1;
}
});
});
rd.on('close', function(){
var jsonString = JSON.stringify(netErrors, null, "\t");
fs.writeFile(OUTPUT_FILE, jsonString, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved to " + OUTPUT_FILE);
}
});
});
var convertDataLineToObject = function(line) {
// Each line of our data file consists of a GUID and a JSON string represting the user's data.
// These are delimetered by a tab.
// For example: <guid> <json>
// We will need to remove the GUID in order to convert the JSON string into an object.
var firstCurly = line.indexOf("{");
if(firstCurly < 0) {
return null;
}
var jsonString = line.slice(firstCurly);
var obj = JSON.parse(jsonString);
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment