Skip to content

Commit

Permalink
more tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
shatting committed Jun 28, 2011
1 parent eead4ab commit d270db4
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 65 deletions.
1 change: 0 additions & 1 deletion background.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<meta http-equiv='Content-type' content='text/html; charset=utf-8' />
<script type="text/javascript" src="javascripts/lib/jquery-1.6.1.min.js"></script>
<!-- <script type="text/javascript" src="javascripts/lib/jquery.store.js"></script>-->
<script type="text/javascript" src="javascripts/lib/quicksilver.js"></script>
<script type="text/javascript" src="javascripts/lib/webtoolkit.base64.js"></script>
<script type="text/javascript" src="javascripts/common.js"></script>
Expand Down
14 changes: 3 additions & 11 deletions javascripts/background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22573090-2']);
_gaq.push(['_trackPageview']);

var SM = new SimplenoteSM();

var SimplenoteBG = {
Expand All @@ -11,7 +7,7 @@ var SimplenoteBG = {
tab : undefined,

log : function(s) {
if (debugFlags.BG)
if (extData.debugFlags.BG)
logGeneral(s,"background.js");
},

Expand Down Expand Up @@ -252,14 +248,10 @@ $(document).ready(function() {

SimplenoteBG.log("(ready) setting up ga");
// some info about settings
_gaq.push(['_trackEvent', 'settings', 'editorfont', localStorage.option_editorfont]);
_gaq.push(['_trackEvent', 'settings', 'editorfontsize', localStorage.option_editorfontsize]);
_gaq.push(['_trackEvent', 'settings', 'sortby', localStorage.option_sortby]);
_gaq.push(['_trackEvent', 'settings', 'alwaystab', localStorage.option_alwaystab]);


setTimeout(function() {
var ga = document.createElement('script');ga.type = 'text/javascript';ga.async = true;
if (debugFlags.GA)
if (extData.debugFlags.GA)
ga.src = 'https://ssl.google-analytics.com/u/ga_debug.js';
else
ga.src = 'https://ssl.google-analytics.com/ga.js';
Expand Down
101 changes: 72 additions & 29 deletions javascripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@
// Simplenote common functions.
// ------------------------------------------------------------------------------------------------

var syncpadManifest;
var webnoteregstr = "^SYNCPADWEBNOTE\\[(.*),(\\d+px),(\\d+px),(\\d+px)?,(\\d+px)?\\]$";
var webnotereg = new RegExp(webnoteregstr,"m");


// debug switches
var debugFlags = {
general : false,
popup : true,
popup2BG : true,
BG : true,
DB : true,
LS : true,
API : true,
CM : true,
Timestamp : true,
GA : false
var extData = {
syncpadManifest : undefined,

webnoteregstr : "^SYNCPADWENOTE\\[(.*),(\\d+px),(\\d+px),(\\d+px)?,(\\d+px)?\\]$",

debugFlags : {
general : false,
popup : true,
popup2BG : true,
BG : true,
DB : true,
LS : true,
API : true,
CM : true,
Timestamp : true,
GA : true
},

chromeVersion : undefined
}

extData.webnotereg = new RegExp(extData.webnoteregstr,"m")

function logGeneral(s,prefix,target) {
if (!debugFlags.general)
if (!extData.debugFlags.general)
return;

if (debugFlags.Timestamp) {
if (extData.debugFlags.Timestamp) {
var t = new Date();
prefix = t.toTimeString().substr(0,t.toTimeString().indexOf(" "))+ "." + pad(t.getMilliseconds(),3) + " - " + prefix;
}
Expand Down Expand Up @@ -402,14 +406,10 @@ function setCBval(sel, bool) {
$(sel).removeAttr("checked");
}

get_manifest(function(mf) {
syncpadManifest = mf;
});

function exceptionCaught(e,src,line) {
if (!syncpadManifest)
if (!extData.syncpadManifest)
get_manifest(function(mf) {
syncpadManifest = mf;
extData.syncpadManifest = mf;
});

var funname = filename = message = filepos = "";
Expand All @@ -427,15 +427,58 @@ function exceptionCaught(e,src,line) {
message = line + ":" + funname + ":" + e.message;
}

var beacon = ['_trackEvent', 'exception_' + syncpadManifest.version, filepos, message];
var beacon = ['_trackEvent', 'exception_' + extData.syncpadManifest.version, filepos, message];

logGeneral(beacon.join(","),"EXC");
console.log(beacon.join(","));
if (e.stack)
logGeneral(e.stack,"EXC");
console.log(e.stack);

_gaq.push(beacon);
}

window.onerror = function(msg,src,line) {
exceptionCaught(msg, src, line);
};
};

function getChromeVersion() {
var v = "unknown";
if (navigator && navigator.appVersion) {
var m = navigator.appVersion.match(/chrome\/([\d+|\.]+)/i);
if (m && m.length >= 2)
v = m[1];

}
return v;
}

extData.chromeVersion = getChromeVersion();

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22573090-2']);
_gaq.push(['_setCustomVar',
1, // This custom var is set to slot #1. Required parameter.
'Chrome Version', // The name acts as a kind of category for the user activity. Required parameter.
extData.chromeVersion, // This value of the custom variable. Required parameter.
2 // Sets the scope to session-level. Optional parameter.
]);


get_manifest(function(mf) {
extData.syncpadManifest = mf;
_gaq.push(['_setCustomVar',
2, // This custom var is set to slot #1. Required parameter.
'Syncpad Version', // The name acts as a kind of category for the user activity. Required parameter.
mf.version, // This value of the custom variable. Required parameter.
2 // Sets the scope to session-level. Optional parameter.
]);
});


_gaq.push(['_setCustomVar',
3, // This custom var is set to slot #1. Required parameter.
'Option Always Tab', // The name acts as a kind of category for the user activity. Required parameter.
localStorage.option_alwaystab, // This value of the custom variable. Required parameter.
2 // Sets the scope to session-level. Optional parameter.
]);

_gaq.push(['_trackPageview']);
6 changes: 1 addition & 5 deletions javascripts/options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22573090-2']);
_gaq.push(['_trackPageview']);

var SM = new SimplenoteSM();

$(document).ready(function() {
Expand Down Expand Up @@ -92,7 +88,7 @@ $(document).ready(function() {

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
if (debugFlags.GA)
if (extData.debugFlags.GA)
ga.src = 'https://ssl.google-analytics.com/u/ga_debug.js';
else
ga.src = 'https://ssl.google-analytics.com/ga.js';
Expand Down
22 changes: 10 additions & 12 deletions javascripts/popup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var extData = {
var extData = extData || {};

$.extend(extData,{
background: undefined,

popup : this,
Expand Down Expand Up @@ -51,22 +53,18 @@ var extData = {
"Yanone Kaffeesatz" : '<link href="http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:300" rel="stylesheet" type="text/css" >',
"Vollkorn" : '<link href="http://fonts.googleapis.com/css?family=Vollkorn:regular" rel="stylesheet" type="text/css" >'
}
}
});

// ---------------------------------------

var snEditor;
var snSM = new SimplenoteSM();

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22573090-2']);
_gaq.push(['_trackPageview']);

// ---------------------------------------
function log(s) {
if (debugFlags.popup)
if (extData.debugFlags.popup)
logGeneral(s,"popup.js",console);
if (debugFlags.popup2BG)
if (extData.debugFlags.popup2BG)
logGeneral(s,"popup.js",extData.background.console);
}

Expand Down Expand Up @@ -616,7 +614,7 @@ function readyListener() {

setTimeout(function() {
var ga = document.createElement('script');ga.type = 'text/javascript';ga.async = true;
if (debugFlags.GA)
if (extData.debugFlags.GA)
ga.src = 'https://ssl.google-analytics.com/u/ga_debug.js';
else
ga.src = 'https://ssl.google-analytics.com/ga.js';
Expand Down Expand Up @@ -735,7 +733,7 @@ function fillIndex() {
req = mergeobj(req, {contentquery : $('#q').val()});
req = mergeobj(req, {sort:localStorage.option_sortby, sortdirection:localStorage.option_sortbydirection});
if ((localStorage.option_hidewebnotes == undefined || localStorage.option_hidewebnotes == "true") && (req.tag == "" || req.tag == "#all#"))
req = mergeobj(req, {notregex: webnoteregstr});
req = mergeobj(req, {notregex: extData.webnoteregstr});

log("fillIndex: " + JSON.stringify(req));

Expand Down Expand Up @@ -1071,7 +1069,7 @@ function indexFillNoteReqComplete(note) {
var $noteabstract = $('#' + note.key + "abstract");

var lines = note.content.split("\n").filter(function(line) {
return ( line.trim().length > 0 && !line.match(webnotereg))
return ( line.trim().length > 0 && !line.match(extData.webnotereg))
});

// heading
Expand Down Expand Up @@ -1122,7 +1120,7 @@ function indexFillNoteReqComplete(note) {
}

// webnote icon
var wnm = note.content.match(webnotereg);
var wnm = note.content.match(extData.webnotereg);
if (wnm && $("#" + note.key + "webnoteicon").length == 0) {
var url = wnm[1];
$("<div id='" + note.key + "webnoteicon' class='webnoteicon statusicon-clickable'>&nbsp;</div>").insertBefore($noteheading);
Expand Down
2 changes: 1 addition & 1 deletion javascripts/simplenoteAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $.ajaxSetup({
var SimplenoteAPI2 = {

log : function(s) {
if (debugFlags.API)
if (extData.debugFlags.API)
logGeneral(s,"SimplenoteAPI2");
},

Expand Down
2 changes: 1 addition & 1 deletion javascripts/simplenoteCM.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ var SimplenoteCM = {
cascading: true,

log : function(s) {
if (debugFlags.CM)
if (extData.debugFlags.CM)
logGeneral(s,"SimplenoteCM");
},

Expand Down
2 changes: 1 addition & 1 deletion javascripts/simplenoteDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var SimplenoteDB = {
//cypherReg : /^\-\-SYNCPADAES\-\-\n(.*)\n\-\-SYNCPADAES\-\-$/m,

log : function(s) {
if (debugFlags.DB)
if (extData.debugFlags.DB)
logGeneral(s,"SimplenoteDB");
},

Expand Down
6 changes: 3 additions & 3 deletions javascripts/simplenoteLS.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var SimplenoteLS = {
indexTimeKey : "_indexTime",

log : function(s) {
if (debugFlags.LS)
if (extData.debugFlags.LS)
logGeneral(s,"SimplenoteLS");
},

Expand Down Expand Up @@ -213,7 +213,7 @@ var SimplenoteLS = {
add &= note.systemtags.indexOf("shared") >= 0;
break;
case "#webnote#":
add &= note.content != undefined && note.content.match(webnotereg) != undefined;
add &= note.content != undefined && note.content.match(extData.webnotereg) != undefined;
break;
default:
add &= note.tags != undefined && note.tags.indexOf(options.tag)>=0;
Expand Down Expand Up @@ -394,7 +394,7 @@ var SimplenoteLS = {
predeftags[4].count++;
if (thissystemtags != undefined && thissystemtags.indexOf("published") >= 0)
predeftags[3].count++;
if (thisnote.content != undefined && thisnote.content.match(webnotereg)) {
if (thisnote.content != undefined && thisnote.content.match(extData.webnotereg)) {
predeftags[5].count++;
predeftags[0].count--;
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Syncpad for Simplenote",
"version": "1.8.5.1",
"version": "1.8.5.2",
"minimum_chrome_version": "5.0.316.0",
"description": "__MSG_description__",
"default_locale": "en",
Expand Down

0 comments on commit d270db4

Please sign in to comment.