1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 20:35:19 +03:00

analytics overhaul

This commit is contained in:
cTn 2014-07-16 12:59:12 +02:00
parent fb7cbe0c8f
commit 1885fba5a0
17 changed files with 38 additions and 48 deletions

View file

@ -23,7 +23,7 @@ var serial = {
self.onReceiveError.addListener(function watch_for_on_receive_errors(info) { self.onReceiveError.addListener(function watch_for_on_receive_errors(info) {
console.error(info); console.error(info);
ga_tracker.sendEvent('Error', 'Serial', info.error); googleAnalytics.sendEvent('Error', 'Serial', info.error);
switch (info.error) { switch (info.error) {
case 'system_error': // we might be able to recover from this one case 'system_error': // we might be able to recover from this one
@ -36,11 +36,11 @@ var serial = {
function crunch_status(info) { function crunch_status(info) {
if (!info.paused) { if (!info.paused) {
console.log('SERIAL: Connection recovered from last onReceiveError'); console.log('SERIAL: Connection recovered from last onReceiveError');
ga_tracker.sendEvent('Error', 'Serial', 'recovered'); googleAnalytics.sendEvent('Error', 'Serial', 'recovered');
} else { } else {
console.log('SERIAL: Connection did not recover from last onReceiveError, disconnecting'); console.log('SERIAL: Connection did not recover from last onReceiveError, disconnecting');
GUI.log('Unrecoverable <span style="color: red">failure</span> of serial connection, disconnecting...'); GUI.log('Unrecoverable <span style="color: red">failure</span> of serial connection, disconnecting...');
ga_tracker.sendEvent('Error', 'Serial', 'unrecoverable'); googleAnalytics.sendEvent('Error', 'Serial', 'unrecoverable');
if (GUI.connected_to || GUI.connecting_to) { if (GUI.connected_to || GUI.connecting_to) {
$('a.connect').click(); $('a.connect').click();
@ -67,7 +67,7 @@ var serial = {
if (callback) callback(connectionInfo); if (callback) callback(connectionInfo);
} else { } else {
console.log('SERIAL: Failed to open serial port'); console.log('SERIAL: Failed to open serial port');
ga_tracker.sendEvent('Error', 'Serial', 'FailedToOpen'); googleAnalytics.sendEvent('Error', 'Serial', 'FailedToOpen');
if (callback) callback(false); if (callback) callback(false);
} }
}); });
@ -91,7 +91,7 @@ var serial = {
console.log('SERIAL: Connection with ID: ' + self.connectionId + ' closed'); console.log('SERIAL: Connection with ID: ' + self.connectionId + ' closed');
} else { } else {
console.log('SERIAL: Failed to close connection with ID: ' + self.connectionId + ' closed'); console.log('SERIAL: Failed to close connection with ID: ' + self.connectionId + ' closed');
ga_tracker.sendEvent('Error', 'Serial', 'FailedToClose'); googleAnalytics.sendEvent('Error', 'Serial', 'FailedToClose');
} }
console.log('SERIAL: Statistics - Sent: ' + self.bytes_sent + ' bytes, Received: ' + self.bytes_received + ' bytes'); console.log('SERIAL: Statistics - Sent: ' + self.bytes_sent + ' bytes, Received: ' + self.bytes_received + ' bytes');

View file

@ -143,7 +143,7 @@ STM32_protocol.prototype.initialize = function() {
} else { } else {
console.log('STM32 - timed out, programming failed ...'); console.log('STM32 - timed out, programming failed ...');
GUI.log('STM32 - timed out, programming: <strong style="color: red">FAILED</strong>'); GUI.log('STM32 - timed out, programming: <strong style="color: red">FAILED</strong>');
ga_tracker.sendEvent('Flashing', 'Programming', 'timeout'); googleAnalytics.sendEvent('Flashing', 'Programming', 'timeout');
// protocol got stuck, clear timer and disconnect // protocol got stuck, clear timer and disconnect
GUI.interval_remove('STM32_timeout'); GUI.interval_remove('STM32_timeout');
@ -589,7 +589,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
if (verify) { if (verify) {
console.log('Programming: SUCCESSFUL'); console.log('Programming: SUCCESSFUL');
GUI.log('Programming: <strong style="color: green">SUCCESSFUL</strong>'); GUI.log('Programming: <strong style="color: green">SUCCESSFUL</strong>');
ga_tracker.sendEvent('Flashing', 'Programming', 'success'); googleAnalytics.sendEvent('Flashing', 'Programming', 'success');
// update progress bar // update progress bar
self.progress_bar_e.addClass('valid'); self.progress_bar_e.addClass('valid');
@ -599,7 +599,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
} else { } else {
console.log('Programming: FAILED'); console.log('Programming: FAILED');
GUI.log('Programming: <strong style="color: red">FAILED</strong>'); GUI.log('Programming: <strong style="color: red">FAILED</strong>');
ga_tracker.sendEvent('Flashing', 'Programming', 'fail'); googleAnalytics.sendEvent('Flashing', 'Programming', 'fail');
// update progress bar // update progress bar
self.progress_bar_e.addClass('invalid'); self.progress_bar_e.addClass('invalid');

View file

@ -421,7 +421,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
if (verify) { if (verify) {
console.log('Programming: SUCCESSFUL'); console.log('Programming: SUCCESSFUL');
GUI.log('Programming: <strong style="color: green">SUCCESSFUL</strong>'); GUI.log('Programming: <strong style="color: green">SUCCESSFUL</strong>');
ga_tracker.sendEvent('Flashing', 'Programming', 'success'); googleAnalytics.sendEvent('Flashing', 'Programming', 'success');
// update progress bar // update progress bar
self.progress_bar_e.addClass('valid'); self.progress_bar_e.addClass('valid');
@ -431,7 +431,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
} else { } else {
console.log('Programming: FAILED'); console.log('Programming: FAILED');
GUI.log('Programming: <strong style="color: red">FAILED</strong>'); GUI.log('Programming: <strong style="color: red">FAILED</strong>');
ga_tracker.sendEvent('Flashing', 'Programming', 'fail'); googleAnalytics.sendEvent('Flashing', 'Programming', 'fail');
// update progress bar // update progress bar
self.progress_bar_e.addClass('invalid'); self.progress_bar_e.addClass('invalid');

36
main.js
View file

@ -1,28 +1,21 @@
// Get access to the background window object // Get access to the background window object
// This object is used to pass current connectionId to the backround page // This object is used to pass variables between active page and background page
// so the onClosed event can close the port for us if it was left opened, without this
// users can experience weird behavior if they would like to access the serial bus afterwards.
chrome.runtime.getBackgroundPage(function(result) { chrome.runtime.getBackgroundPage(function(result) {
backgroundPage = result; backgroundPage = result;
backgroundPage.app_window = window; backgroundPage.app_window = window;
}); });
// Google Analytics BEGIN // Google Analytics
var ga_config; // google analytics config reference var googleAnalyticsService = analytics.getService('ice_cream_app');
var ga_tracking; // global result of isTrackingPermitted var googleAnalytics = googleAnalyticsService.getTracker('UA-32728876-6');
var googleAnalyticsConfig = false;
var service = analytics.getService('ice_cream_app'); googleAnalyticsService.getConfig().addCallback(function(config) {
service.getConfig().addCallback(function(config) { googleAnalyticsConfig = config;
ga_config = config;
ga_tracking = config.isTrackingPermitted();
}); });
var ga_tracker = service.getTracker('UA-32728876-6');
ga_tracker.sendAppView('Application Started');
// Google Analytics END
$(document).ready(function() { $(document).ready(function() {
googleAnalytics.sendAppView('Application Started');
// translate to user-selected language // translate to user-selected language
localize(); localize();
@ -126,7 +119,7 @@ $(document).ready(function() {
el.addClass('active'); el.addClass('active');
el.after('<div id="options-window"></div>'); el.after('<div id="options-window"></div>');
$('div#options-window').load('./tabs/options.html', function() { $('div#options-window').load('./tabs/options.html', function() {
ga_tracker.sendAppView('Options'); googleAnalytics.sendAppView('Options');
// translate to user-selected language // translate to user-selected language
localize(); localize();
@ -145,16 +138,13 @@ $(document).ready(function() {
}); });
// if tracking is enabled, check the statistics checkbox // if tracking is enabled, check the statistics checkbox
if (ga_tracking == true) { if (googleAnalyticsConfig.isTrackingPermitted()) {
$('div.statistics input').prop('checked', true); $('div.statistics input').prop('checked', true);
} }
$('div.statistics input').change(function() { $('div.statistics input').change(function() {
var check = $(this).is(':checked'); var result = $(this).is(':checked');
googleAnalyticsConfig.setTrackingPermitted(result);
ga_tracking = check;
ga_config.setTrackingPermitted(check);
}); });
$(this).slideDown(); $(this).slideDown();

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"minimum_chrome_version": "33", "minimum_chrome_version": "33",
"version": "0.46", "version": "0.47",
"author": "cTn", "author": "cTn",
"name": "Baseflight - Configurator", "name": "Baseflight - Configurator",

View file

@ -3,7 +3,7 @@ tabs.auxiliary_configuration = {};
tabs.auxiliary_configuration.initialize = function(callback) { tabs.auxiliary_configuration.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'auxiliary_configuration'; GUI.active_tab = 'auxiliary_configuration';
ga_tracker.sendAppView('Auxiliary Configuration'); googleAnalytics.sendAppView('Auxiliary Configuration');
MSP.send_message(MSP_codes.MSP_BOXNAMES, false, false, get_box_data); MSP.send_message(MSP_codes.MSP_BOXNAMES, false, false, get_box_data);

View file

@ -6,7 +6,7 @@ tabs.cli.initialize = function(callback) {
var self = this; var self = this;
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'cli'; GUI.active_tab = 'cli';
ga_tracker.sendAppView('CLI Page'); googleAnalytics.sendAppView('CLI Page');
$('#content').load("./tabs/cli.html", function() { $('#content').load("./tabs/cli.html", function() {
// translate to user-selected language // translate to user-selected language

View file

@ -18,7 +18,7 @@ tabs.default.initialize = function(callback) {
}); });
$('div.welcome a').click(function() { $('div.welcome a').click(function() {
ga_tracker.sendEvent('ExternalUrls', 'Click', $(this).prop('href')); googleAnalytics.sendEvent('ExternalUrls', 'Click', $(this).prop('href'));
}); });
if (callback) callback(); if (callback) callback();

View file

@ -2,7 +2,7 @@ tabs.firmware_flasher = {};
tabs.firmware_flasher.initialize = function(callback) { tabs.firmware_flasher.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'firmware_flasher'; GUI.active_tab = 'firmware_flasher';
ga_tracker.sendAppView('Firmware Flasher'); googleAnalytics.sendAppView('Firmware Flasher');
var intel_hex = false; // standard intel hex in string format var intel_hex = false; // standard intel hex in string format
var parsed_hex = false; // parsed raw hex in array format var parsed_hex = false; // parsed raw hex in array format
@ -49,7 +49,7 @@ tabs.firmware_flasher.initialize = function(callback) {
if (parsed_hex) { if (parsed_hex) {
GUI.log(chrome.i18n.getMessage('firmwareFlasherLocalFirmwareLoaded')); GUI.log(chrome.i18n.getMessage('firmwareFlasherLocalFirmwareLoaded'));
ga_tracker.sendEvent('Flashing', 'Firmware', 'local'); googleAnalytics.sendEvent('Flashing', 'Firmware', 'local');
$('a.flash_firmware').removeClass('locked'); $('a.flash_firmware').removeClass('locked');
$('span.size').html(parsed_hex.bytes_total + ' bytes'); $('span.size').html(parsed_hex.bytes_total + ' bytes');
@ -75,7 +75,7 @@ tabs.firmware_flasher.initialize = function(callback) {
if (parsed_hex) { if (parsed_hex) {
GUI.log(chrome.i18n.getMessage('firmwareFlasherRemoteFirmwareLoaded')); GUI.log(chrome.i18n.getMessage('firmwareFlasherRemoteFirmwareLoaded'));
ga_tracker.sendEvent('Flashing', 'Firmware', 'online'); googleAnalytics.sendEvent('Flashing', 'Firmware', 'online');
$('a.flash_firmware').removeClass('locked'); $('a.flash_firmware').removeClass('locked');
$('span.path').text('Using remote Firmware'); $('span.path').text('Using remote Firmware');

View file

@ -2,7 +2,7 @@ tabs.gps = {};
tabs.gps.initialize = function(callback) { tabs.gps.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'gps'; GUI.active_tab = 'gps';
ga_tracker.sendAppView('GPS Page'); googleAnalytics.sendAppView('GPS Page');
MSP.send_message(MSP_codes.MSP_RAW_GPS, false, false, load_html); MSP.send_message(MSP_codes.MSP_RAW_GPS, false, false, load_html);

View file

@ -5,7 +5,7 @@ tabs.initial_setup.initialize = function(callback) {
var self = this; var self = this;
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'initial_setup'; GUI.active_tab = 'initial_setup';
ga_tracker.sendAppView('Initial Setup'); googleAnalytics.sendAppView('Initial Setup');
MSP.send_message(MSP_codes.MSP_ACC_TRIM, false, false, load_ident); MSP.send_message(MSP_codes.MSP_ACC_TRIM, false, false, load_ident);

View file

@ -4,7 +4,7 @@ tabs.logging = {};
tabs.logging.initialize = function(callback) { tabs.logging.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'logging'; GUI.active_tab = 'logging';
ga_tracker.sendAppView('Logging'); googleAnalytics.sendAppView('Logging');
var requested_properties = []; var requested_properties = [];

View file

@ -2,7 +2,7 @@ tabs.motor_outputs = {};
tabs.motor_outputs.initialize = function(callback) { tabs.motor_outputs.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'motor_outputs'; GUI.active_tab = 'motor_outputs';
ga_tracker.sendAppView('Motor Outputs Page'); googleAnalytics.sendAppView('Motor Outputs Page');
function initSensorData() { function initSensorData() {
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {

View file

@ -2,7 +2,7 @@ tabs.pid_tuning = {};
tabs.pid_tuning.initialize = function(callback) { tabs.pid_tuning.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'pid_tuning'; GUI.active_tab = 'pid_tuning';
ga_tracker.sendAppView('PID Tuning'); googleAnalytics.sendAppView('PID Tuning');
// requesting MSP_STATUS manually because it contains CONFIG.profile // requesting MSP_STATUS manually because it contains CONFIG.profile
MSP.send_message(MSP_codes.MSP_STATUS, false, false, get_pid_names); MSP.send_message(MSP_codes.MSP_STATUS, false, false, get_pid_names);

View file

@ -2,7 +2,7 @@ tabs.receiver = {};
tabs.receiver.initialize = function(callback) { tabs.receiver.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'receiver'; GUI.active_tab = 'receiver';
ga_tracker.sendAppView('Receiver Page'); googleAnalytics.sendAppView('Receiver Page');
MSP.send_message(MSP_codes.MSP_RC_TUNING, false, false, get_rc_data); MSP.send_message(MSP_codes.MSP_RC_TUNING, false, false, get_rc_data);

View file

@ -2,7 +2,7 @@ tabs.sensors = {};
tabs.sensors.initialize = function(callback) { tabs.sensors.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'sensors'; GUI.active_tab = 'sensors';
ga_tracker.sendAppView('Sensor Page'); googleAnalytics.sendAppView('Sensor Page');
function initSensorData(){ function initSensorData(){
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {

View file

@ -9,7 +9,7 @@ tabs.servos = {};
tabs.servos.initialize = function(callback) { tabs.servos.initialize = function(callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'servos'; GUI.active_tab = 'servos';
ga_tracker.sendAppView('Servos'); googleAnalytics.sendAppView('Servos');
MSP.send_message(MSP_codes.MSP_IDENT, false, false, get_servo_conf_data); MSP.send_message(MSP_codes.MSP_IDENT, false, false, get_servo_conf_data);