Added Google Analytics
This commit is contained in:
parent
8942314860
commit
9b61c5062f
@ -553,7 +553,8 @@ div.dropdown-menu i {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#modal-settings .accordion-inner .form-inline .label-text {
|
||||
#modal-settings .accordion-inner .form-inline .label-text,
|
||||
#modal-settings .accordion-inner .control-label {
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ define([
|
||||
|
||||
// Used for periodic tasks
|
||||
var intervalId = undefined;
|
||||
var periodicCallbacks = [];
|
||||
var periodicCallbacks = [extensionMgr.onPeriodicRun];
|
||||
core.addPeriodicCallback = function(callback) {
|
||||
periodicCallbacks.push(callback);
|
||||
};
|
||||
|
@ -40,10 +40,12 @@ define([
|
||||
}
|
||||
|
||||
// Return a function that calls every callbacks from extensions
|
||||
function createHook(hookName) {
|
||||
function createHook(hookName, noLog) {
|
||||
var callbackList = getExtensionCallbackList(hookName);
|
||||
return function() {
|
||||
logger.log(hookName, arguments);
|
||||
if(!noLog) {
|
||||
logger.log(hookName, arguments);
|
||||
}
|
||||
var callbackArguments = arguments;
|
||||
_.each(callbackList, function(callback) {
|
||||
callback.apply(null, callbackArguments);
|
||||
@ -52,8 +54,8 @@ define([
|
||||
}
|
||||
|
||||
// Add a Hook to the extensionMgr
|
||||
function addHook(hookName) {
|
||||
extensionMgr[hookName] = createHook(hookName);
|
||||
function addHook(hookName, noLog) {
|
||||
extensionMgr[hookName] = createHook(hookName, noLog);
|
||||
}
|
||||
|
||||
// Set extension config
|
||||
@ -87,7 +89,8 @@ define([
|
||||
addHook("onMessage");
|
||||
addHook("onError");
|
||||
addHook("onOfflineChanged");
|
||||
addHook("onAsyncRunning");
|
||||
addHook("onAsyncRunning", true);
|
||||
addHook("onPeriodicRun", true);
|
||||
|
||||
// To access modules that are loaded after extensions
|
||||
addHook("onFileMgrCreated");
|
||||
|
@ -1,13 +1,26 @@
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"utils",
|
||||
"text!html/buttonSync.html",
|
||||
], function($, _, buttonSyncHTML) {
|
||||
"text!html/buttonSyncSettingsBloc.html",
|
||||
], function($, _, utils, buttonSyncHTML, buttonSyncSettingsBlocHTML) {
|
||||
|
||||
var buttonSync = {
|
||||
extensionId: "buttonSync",
|
||||
extensionName: 'Button "Synchronize"',
|
||||
settingsBloc: '<p>Adds a "Synchronize documents" button in the navigation bar.</p>'
|
||||
defaultConfig: {
|
||||
syncPeriod: 180000
|
||||
},
|
||||
settingsBloc: buttonSyncSettingsBlocHTML
|
||||
};
|
||||
|
||||
buttonSync.onLoadSettings = function() {
|
||||
utils.setInputValue("#input-sync-period", buttonSync.config.syncPeriod);
|
||||
};
|
||||
|
||||
buttonSync.onSaveSettings = function(newConfig, event) {
|
||||
newConfig.syncPeriod = utils.getInputIntValue("#input-sync-period", undefined, 0);
|
||||
};
|
||||
|
||||
var button = undefined;
|
||||
@ -32,10 +45,21 @@ define([
|
||||
synchronizer = synchronizerParameter;
|
||||
};
|
||||
|
||||
// Run sync periodically
|
||||
var lastSync = 0;
|
||||
buttonSync.onPeriodicRun = function() {
|
||||
if(viewerMode === true || !buttonSync.config.syncPeriod || lastSync + buttonSync.config.syncPeriod > utils.currentTime) {
|
||||
return;
|
||||
}
|
||||
if(synchronizer.sync() === true) {
|
||||
lastSync = utils.currentTime;
|
||||
}
|
||||
};
|
||||
|
||||
buttonSync.onCreateButton = function() {
|
||||
button = $(buttonSyncHTML).click(function() {
|
||||
if(!$(this).hasClass("disabled")) {
|
||||
synchronizer.forceSync();
|
||||
synchronizer.sync();
|
||||
}
|
||||
});
|
||||
return button;
|
||||
|
@ -31,48 +31,48 @@ define([
|
||||
// Collect informations about user settings
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
"settings",
|
||||
"Settings",
|
||||
'layoutOrientation',
|
||||
"" + settings.layoutOrientation
|
||||
]);
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
"settings",
|
||||
"Settings",
|
||||
'lazyRendering',
|
||||
"" + settings.lazyRendering
|
||||
]);
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
"settings",
|
||||
"Settings",
|
||||
'editorFontSize',
|
||||
"" + settings.editorFontSize
|
||||
]);
|
||||
// Check if user has removed back links
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
"settings",
|
||||
'defaultContentBacklink',
|
||||
"Settings",
|
||||
'defaultContent backlink',
|
||||
"" + settings.defaultContent.indexOf(MAIN_URL) >= 0
|
||||
]);
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
"settings",
|
||||
'commitMsgBacklink',
|
||||
"Settings",
|
||||
'commitMsg backlink',
|
||||
"" + settings.commitMsg.indexOf(MAIN_URL) >= 0
|
||||
]);
|
||||
// Check if user has changed sshProxy
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
"settings",
|
||||
'sshProxyChanged',
|
||||
"Settings",
|
||||
'sshProxy changed',
|
||||
"" + settings.sshProxy != SSH_PROXY_URL
|
||||
]);
|
||||
// Check if extensions have been disabled
|
||||
_.each(settings.extensionSettings, function(config, extensionId) {
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
"extensions",
|
||||
extensionId + "Enabled",
|
||||
"Extensions",
|
||||
extensionId + " enabled",
|
||||
"" + config.enabled
|
||||
]);
|
||||
});
|
||||
@ -97,25 +97,34 @@ define([
|
||||
init();
|
||||
};
|
||||
|
||||
var currentAction = "No action";
|
||||
googleAnalytics.onSyncRunning = function() {
|
||||
currentAction = "Sync";
|
||||
var currentAction = "Unknown";
|
||||
var startTime = 0;
|
||||
googleAnalytics.onSyncRunning = function(isRunning) {
|
||||
if(isRunning === true) {
|
||||
currentAction = "Sync";
|
||||
startTime = new Date().getTime();
|
||||
}
|
||||
};
|
||||
googleAnalytics.onPublishRunning = function() {
|
||||
currentAction = "Publish";
|
||||
googleAnalytics.onPublishRunning = function(isRunning) {
|
||||
if(isRunning === true) {
|
||||
currentAction = "Publish";
|
||||
startTime = new Date().getTime();
|
||||
}
|
||||
};
|
||||
googleAnalytics.onAsyncRunning = function(isRunning) {
|
||||
if(isRunning === false) {
|
||||
currentAction = "No action";
|
||||
currentAction = "Unknown";
|
||||
}
|
||||
};
|
||||
|
||||
// Log sync frequency
|
||||
// Log sync time
|
||||
googleAnalytics.onSyncSuccess = function() {
|
||||
var endTime = new Date().getTime();
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
'_trackTiming',
|
||||
'Sync',
|
||||
'SyncSuccess'
|
||||
'SyncTime',
|
||||
endTime - startTime
|
||||
]);
|
||||
};
|
||||
// Log import frequency and provider
|
||||
@ -128,7 +137,7 @@ define([
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
'Sync',
|
||||
'SyncImportProvider',
|
||||
'SyncImport provider',
|
||||
provider.providerId
|
||||
]);
|
||||
};
|
||||
@ -142,22 +151,24 @@ define([
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
'Sync',
|
||||
'SyncExportProvider',
|
||||
'SyncExport provider',
|
||||
syncAttributes.provider.providerId
|
||||
]);
|
||||
};
|
||||
// Log publish frequency and provider
|
||||
// Log publish time and provider
|
||||
googleAnalytics.onPublishSuccess = function(fileDesc) {
|
||||
var endTime = new Date().getTime();
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
'_trackTiming',
|
||||
'Publish',
|
||||
'PublishSuccess'
|
||||
'PublishSuccess',
|
||||
endTime - startTime
|
||||
]);
|
||||
_.each(fileDesc.publishLocations, function(publishAttributes) {
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
'Publish',
|
||||
'PublishSuccessProvider',
|
||||
'PublishSuccess provider',
|
||||
publishAttributes.provider.providerId
|
||||
]);
|
||||
});
|
||||
@ -167,7 +178,7 @@ define([
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
'Publish',
|
||||
'NewPublishProvider',
|
||||
'NewPublish provider',
|
||||
publishAttributes.provider.providerId
|
||||
]);
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
|
||||
var toc = {
|
||||
extensionId: "toc",
|
||||
extensionName: "Table of content",
|
||||
extensionName: "Table of Content",
|
||||
optional: true,
|
||||
defaultConfig: {
|
||||
marker: "\\[(TOC|toc)\\]"
|
||||
|
@ -5,7 +5,7 @@ define([
|
||||
|
||||
var workingIndicator = {
|
||||
extensionId: "workingIndicator",
|
||||
extensionName: "Working indicator",
|
||||
extensionName: "Working Indicator",
|
||||
settingsBloc: '<p>Displays an animated image when a network operation is running.</p>'
|
||||
};
|
||||
|
||||
|
10
js/html/buttonSyncSettingsBloc.html
Normal file
10
js/html/buttonSyncSettingsBloc.html
Normal file
@ -0,0 +1,10 @@
|
||||
<p>Adds a "Synchronize documents" button in the navigation bar.</p>
|
||||
<div class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input-sync-period">Sync period (optional)</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="input-sync-period"
|
||||
class="input-mini"> <span class="help-inline">ms</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -41,12 +41,6 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
// Force the synchronization
|
||||
synchronizer.forceSync = function() {
|
||||
lastSync = 0;
|
||||
synchronizer.sync();
|
||||
};
|
||||
|
||||
// Recursive function to upload a single file on multiple locations
|
||||
var uploadSyncAttributesList = [];
|
||||
var uploadContent = undefined;
|
||||
@ -154,16 +148,14 @@ define([
|
||||
|
||||
// Main entry point for synchronization
|
||||
var syncRunning = false;
|
||||
var lastSync = 0;
|
||||
synchronizer.sync = function() {
|
||||
// If sync is already running or timeout is not reached or offline
|
||||
if(syncRunning || lastSync + SYNC_PERIOD > utils.currentTime || core.isOffline) {
|
||||
return;
|
||||
// If sync is already running or offline
|
||||
if(syncRunning || core.isOffline) {
|
||||
return false;
|
||||
}
|
||||
syncRunning = true;
|
||||
extensionMgr.onSyncRunning(true);
|
||||
uploadCycle = true;
|
||||
lastSync = utils.currentTime;
|
||||
|
||||
function isError(error) {
|
||||
if(error !== undefined) {
|
||||
@ -187,11 +179,8 @@ define([
|
||||
extensionMgr.onSyncSuccess();
|
||||
});
|
||||
});
|
||||
return true;
|
||||
};
|
||||
// Run sync function periodically
|
||||
if(viewerMode === false) {
|
||||
core.addPeriodicCallback(synchronizer.sync);
|
||||
}
|
||||
|
||||
// Initialize the export dialog
|
||||
function initExportDialog(provider) {
|
||||
|
Loading…
Reference in New Issue
Block a user