Modified Analytics events

This commit is contained in:
benweet 2013-06-12 01:00:12 +01:00
parent 31db4fa59e
commit f1d606ef40
2 changed files with 73 additions and 151 deletions

View File

@ -1,89 +0,0 @@
Developer guide
===============
Architecture
------------
![Architecture diagram][1]
StackEdit uses [RequireJS][2] for asynchronous module definition ([AMD][3]).
### core
The `core` module is responsible for:
- creating the layout (using [UI Layout][4])
- creating the editor (using [PageDown][5])
- Loading/saving the settings
- detecting the offline status
### fileMgr
The `fileMgr` module is responsible for:
- creating/deleting local files
- switching from one file to another
- setting/removing file's sync/publish location
### synchronizer
The `synchronizer` module is responsible for:
- creating a new local file from a sync location (import)
- creating a new sync location from a local file (export)
- running 2 ways synchronization (upload and download) for all sync locations
### publisher
The `publisher` module is responsible for:
- creating new publish locations
- updating existing publish locations
#### publisher's providers
A `provider` module can be associated with the `publisher` module if it implements the following functions:
- `newPublishAttributes()`: returns a new [`publishAttributes`][6] object in order to create a new publish location
- `publish()`: performs publishing of one publish location
#### publishAttributes
A `publishAttributes` object is an object that describes a publish location. Attributes list differs from one provider to another except for the following attributes:
- `publishIndex`: the unique index of the publish location
- `provider`: the `provider` module that handles the publish location
- `format`: the publishing format for the publish location. It can be:
- `markdown` for Markdown format
- `html` for HTML format
- `template` for template format
> Written with [StackEdit](http://benweet.github.io/stackedit/).
[1]: http://benweet.github.io/stackedit/doc/img/architecture.png "Architecture diagram"
[2]: http://requirejs.org/ "RequireJS"
[3]: http://en.wikipedia.org/wiki/Asynchronous_module_definition "Asynchronous module definition"
[4]: http://layout.jquery-dev.net/ "UI Layout"
[5]: https://code.google.com/p/pagedown/ "PageDown"
[6]: #publishattributes

View File

@ -18,6 +18,21 @@ define([
var init = function() { var init = function() {
if(isLoaded === false && isOffline === false) { if(isLoaded === false && isOffline === false) {
var gaUrl = "/ga.js";
if(location.search.match(/(\?|&)console/)) {
gaUrl = "/u/ga_debug.js";
}
$.ajax({
url: "http://www.google-analytics.com" + gaUrl,
dataType: "script"
}).done(function() {
isLoaded = true;
});
}
};
var currentAction = "Unknown";
googleAnalytics.onReady = function() {
// First configure GA // First configure GA
_gaq.push([ _gaq.push([
@ -52,20 +67,20 @@ define([
'_trackEvent', '_trackEvent',
"Settings", "Settings",
'defaultContent backlink', 'defaultContent backlink',
"" + settings.defaultContent.indexOf(MAIN_URL) >= 0 "" + (settings.defaultContent.indexOf(MAIN_URL) !== -1)
]); ]);
_gaq.push([ _gaq.push([
'_trackEvent', '_trackEvent',
"Settings", "Settings",
'commitMsg backlink', 'commitMsg backlink',
"" + settings.commitMsg.indexOf(MAIN_URL) >= 0 "" + (settings.commitMsg.indexOf(MAIN_URL) !== -1)
]); ]);
// Check if user has changed sshProxy // Check if user has changed sshProxy
_gaq.push([ _gaq.push([
'_trackEvent', '_trackEvent',
"Settings", "Settings",
'sshProxy changed', 'sshProxy unchanged',
"" + settings.sshProxy != SSH_PROXY_URL "" + (settings.sshProxy == SSH_PROXY_URL)
]); ]);
// Check if extensions have been disabled // Check if extensions have been disabled
_.each(settings.extensionSettings, function(config, extensionId) { _.each(settings.extensionSettings, function(config, extensionId) {
@ -73,31 +88,27 @@ define([
'_trackEvent', '_trackEvent',
"Extensions", "Extensions",
extensionId + " enabled", extensionId + " enabled",
"" + config.enabled "" + (config.enabled === true)
]); ]);
}); });
// Now load GA script using jQuery // Catch window JavaScript errors
var gaUrl = "/ga.js"; window.onerror = function(message, url, line) {
if(location.search.match(/(\?|&)console/)) { _gaq.push([
gaUrl = "/u/ga_debug.js"; "_trackEvent",
} currentAction,
$.ajax({ 'JS error',
url: "http://www.google-analytics.com" + gaUrl, message + "(" + url + ": " + line + ")"
dataType: "script" ]);
}).done(function() {
isLoaded = true;
});
}
}; };
googleAnalytics.onReady = init; init();
};
googleAnalytics.onOfflineChanged = function(isOfflineParam) { googleAnalytics.onOfflineChanged = function(isOfflineParam) {
isOffline = isOfflineParam; isOffline = isOfflineParam;
init(); init();
}; };
var currentAction = "Unknown";
var startTime = 0; var startTime = 0;
googleAnalytics.onSyncRunning = function(isRunning) { googleAnalytics.onSyncRunning = function(isRunning) {
if(isRunning === true) { if(isRunning === true) {