diff --git a/js/serial.js b/js/serial.js index 155b0734..3cd846f6 100644 --- a/js/serial.js +++ b/js/serial.js @@ -23,7 +23,7 @@ var serial = { self.onReceiveError.addListener(function watch_for_on_receive_errors(info) { console.error(info); - ga_tracker.sendEvent('Error', 'Serial', info.error); + googleAnalytics.sendEvent('Error', 'Serial', info.error); switch (info.error) { case 'system_error': // we might be able to recover from this one @@ -36,11 +36,11 @@ var serial = { function crunch_status(info) { if (!info.paused) { console.log('SERIAL: Connection recovered from last onReceiveError'); - ga_tracker.sendEvent('Error', 'Serial', 'recovered'); + googleAnalytics.sendEvent('Error', 'Serial', 'recovered'); } else { console.log('SERIAL: Connection did not recover from last onReceiveError, disconnecting'); GUI.log('Unrecoverable failure of serial connection, disconnecting...'); - ga_tracker.sendEvent('Error', 'Serial', 'unrecoverable'); + googleAnalytics.sendEvent('Error', 'Serial', 'unrecoverable'); if (GUI.connected_to || GUI.connecting_to) { $('a.connect').click(); @@ -67,7 +67,7 @@ var serial = { if (callback) callback(connectionInfo); } else { console.log('SERIAL: Failed to open serial port'); - ga_tracker.sendEvent('Error', 'Serial', 'FailedToOpen'); + googleAnalytics.sendEvent('Error', 'Serial', 'FailedToOpen'); if (callback) callback(false); } }); @@ -91,7 +91,7 @@ var serial = { console.log('SERIAL: Connection with ID: ' + self.connectionId + ' closed'); } else { 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'); diff --git a/js/stm32.js b/js/stm32.js index ca95a376..95633489 100644 --- a/js/stm32.js +++ b/js/stm32.js @@ -143,7 +143,7 @@ STM32_protocol.prototype.initialize = function() { } else { console.log('STM32 - timed out, programming failed ...'); GUI.log('STM32 - timed out, programming: FAILED'); - ga_tracker.sendEvent('Flashing', 'Programming', 'timeout'); + googleAnalytics.sendEvent('Flashing', 'Programming', 'timeout'); // protocol got stuck, clear timer and disconnect GUI.interval_remove('STM32_timeout'); @@ -589,7 +589,7 @@ STM32_protocol.prototype.upload_procedure = function(step) { if (verify) { console.log('Programming: SUCCESSFUL'); GUI.log('Programming: SUCCESSFUL'); - ga_tracker.sendEvent('Flashing', 'Programming', 'success'); + googleAnalytics.sendEvent('Flashing', 'Programming', 'success'); // update progress bar self.progress_bar_e.addClass('valid'); @@ -599,7 +599,7 @@ STM32_protocol.prototype.upload_procedure = function(step) { } else { console.log('Programming: FAILED'); GUI.log('Programming: FAILED'); - ga_tracker.sendEvent('Flashing', 'Programming', 'fail'); + googleAnalytics.sendEvent('Flashing', 'Programming', 'fail'); // update progress bar self.progress_bar_e.addClass('invalid'); diff --git a/js/stm32dfu.js b/js/stm32dfu.js index b66f552a..5cc6fe6d 100644 --- a/js/stm32dfu.js +++ b/js/stm32dfu.js @@ -421,7 +421,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) { if (verify) { console.log('Programming: SUCCESSFUL'); GUI.log('Programming: SUCCESSFUL'); - ga_tracker.sendEvent('Flashing', 'Programming', 'success'); + googleAnalytics.sendEvent('Flashing', 'Programming', 'success'); // update progress bar self.progress_bar_e.addClass('valid'); @@ -431,7 +431,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) { } else { console.log('Programming: FAILED'); GUI.log('Programming: FAILED'); - ga_tracker.sendEvent('Flashing', 'Programming', 'fail'); + googleAnalytics.sendEvent('Flashing', 'Programming', 'fail'); // update progress bar self.progress_bar_e.addClass('invalid'); diff --git a/main.js b/main.js index fca91e19..0423bb3f 100644 --- a/main.js +++ b/main.js @@ -1,28 +1,21 @@ // Get access to the background window object -// This object is used to pass current connectionId to the backround 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. +// This object is used to pass variables between active page and background page chrome.runtime.getBackgroundPage(function(result) { backgroundPage = result; backgroundPage.app_window = window; }); -// Google Analytics BEGIN -var ga_config; // google analytics config reference -var ga_tracking; // global result of isTrackingPermitted - -var service = analytics.getService('ice_cream_app'); -service.getConfig().addCallback(function(config) { - ga_config = config; - ga_tracking = config.isTrackingPermitted(); +// Google Analytics +var googleAnalyticsService = analytics.getService('ice_cream_app'); +var googleAnalytics = googleAnalyticsService.getTracker('UA-32728876-6'); +var googleAnalyticsConfig = false; +googleAnalyticsService.getConfig().addCallback(function(config) { + googleAnalyticsConfig = config; }); -var ga_tracker = service.getTracker('UA-32728876-6'); - -ga_tracker.sendAppView('Application Started'); -// Google Analytics END - $(document).ready(function() { + googleAnalytics.sendAppView('Application Started'); + // translate to user-selected language localize(); @@ -126,7 +119,7 @@ $(document).ready(function() { el.addClass('active'); el.after('
'); $('div#options-window').load('./tabs/options.html', function() { - ga_tracker.sendAppView('Options'); + googleAnalytics.sendAppView('Options'); // translate to user-selected language localize(); @@ -145,16 +138,13 @@ $(document).ready(function() { }); // if tracking is enabled, check the statistics checkbox - if (ga_tracking == true) { + if (googleAnalyticsConfig.isTrackingPermitted()) { $('div.statistics input').prop('checked', true); } $('div.statistics input').change(function() { - var check = $(this).is(':checked'); - - ga_tracking = check; - - ga_config.setTrackingPermitted(check); + var result = $(this).is(':checked'); + googleAnalyticsConfig.setTrackingPermitted(result); }); $(this).slideDown(); diff --git a/manifest.json b/manifest.json index 453df15d..aef46435 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "minimum_chrome_version": "33", - "version": "0.46", + "version": "0.47", "author": "cTn", "name": "Baseflight - Configurator", diff --git a/tabs/auxiliary_configuration.js b/tabs/auxiliary_configuration.js index eded1bb7..94ef608f 100644 --- a/tabs/auxiliary_configuration.js +++ b/tabs/auxiliary_configuration.js @@ -3,7 +3,7 @@ tabs.auxiliary_configuration = {}; tabs.auxiliary_configuration.initialize = function(callback) { GUI.active_tab_ref = this; 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); diff --git a/tabs/cli.js b/tabs/cli.js index 44fce450..73d9b680 100644 --- a/tabs/cli.js +++ b/tabs/cli.js @@ -6,7 +6,7 @@ tabs.cli.initialize = function(callback) { var self = this; GUI.active_tab_ref = this; GUI.active_tab = 'cli'; - ga_tracker.sendAppView('CLI Page'); + googleAnalytics.sendAppView('CLI Page'); $('#content').load("./tabs/cli.html", function() { // translate to user-selected language diff --git a/tabs/default.js b/tabs/default.js index df6253f9..05be4aea 100644 --- a/tabs/default.js +++ b/tabs/default.js @@ -18,7 +18,7 @@ tabs.default.initialize = function(callback) { }); $('div.welcome a').click(function() { - ga_tracker.sendEvent('ExternalUrls', 'Click', $(this).prop('href')); + googleAnalytics.sendEvent('ExternalUrls', 'Click', $(this).prop('href')); }); if (callback) callback(); diff --git a/tabs/firmware_flasher.js b/tabs/firmware_flasher.js index f9a73fe5..ab3c8438 100644 --- a/tabs/firmware_flasher.js +++ b/tabs/firmware_flasher.js @@ -2,7 +2,7 @@ tabs.firmware_flasher = {}; tabs.firmware_flasher.initialize = function(callback) { GUI.active_tab_ref = this; 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 parsed_hex = false; // parsed raw hex in array format @@ -49,7 +49,7 @@ tabs.firmware_flasher.initialize = function(callback) { if (parsed_hex) { GUI.log(chrome.i18n.getMessage('firmwareFlasherLocalFirmwareLoaded')); - ga_tracker.sendEvent('Flashing', 'Firmware', 'local'); + googleAnalytics.sendEvent('Flashing', 'Firmware', 'local'); $('a.flash_firmware').removeClass('locked'); $('span.size').html(parsed_hex.bytes_total + ' bytes'); @@ -75,7 +75,7 @@ tabs.firmware_flasher.initialize = function(callback) { if (parsed_hex) { GUI.log(chrome.i18n.getMessage('firmwareFlasherRemoteFirmwareLoaded')); - ga_tracker.sendEvent('Flashing', 'Firmware', 'online'); + googleAnalytics.sendEvent('Flashing', 'Firmware', 'online'); $('a.flash_firmware').removeClass('locked'); $('span.path').text('Using remote Firmware'); diff --git a/tabs/gps.js b/tabs/gps.js index 6d4da543..c4ec546c 100644 --- a/tabs/gps.js +++ b/tabs/gps.js @@ -2,7 +2,7 @@ tabs.gps = {}; tabs.gps.initialize = function(callback) { GUI.active_tab_ref = this; 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); diff --git a/tabs/initial_setup.js b/tabs/initial_setup.js index 1778c7ff..59296674 100644 --- a/tabs/initial_setup.js +++ b/tabs/initial_setup.js @@ -5,7 +5,7 @@ tabs.initial_setup.initialize = function(callback) { var self = this; GUI.active_tab_ref = this; 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); diff --git a/tabs/logging.js b/tabs/logging.js index 060c91c9..4c00e4cf 100644 --- a/tabs/logging.js +++ b/tabs/logging.js @@ -4,7 +4,7 @@ tabs.logging = {}; tabs.logging.initialize = function(callback) { GUI.active_tab_ref = this; GUI.active_tab = 'logging'; - ga_tracker.sendAppView('Logging'); + googleAnalytics.sendAppView('Logging'); var requested_properties = []; diff --git a/tabs/motor_outputs.js b/tabs/motor_outputs.js index 18d09af1..8438df31 100644 --- a/tabs/motor_outputs.js +++ b/tabs/motor_outputs.js @@ -2,7 +2,7 @@ tabs.motor_outputs = {}; tabs.motor_outputs.initialize = function(callback) { GUI.active_tab_ref = this; GUI.active_tab = 'motor_outputs'; - ga_tracker.sendAppView('Motor Outputs Page'); + googleAnalytics.sendAppView('Motor Outputs Page'); function initSensorData() { for (var i = 0; i < 3; i++) { diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 27fb33c7..f839f729 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -2,7 +2,7 @@ tabs.pid_tuning = {}; tabs.pid_tuning.initialize = function(callback) { GUI.active_tab_ref = this; GUI.active_tab = 'pid_tuning'; - ga_tracker.sendAppView('PID Tuning'); + googleAnalytics.sendAppView('PID Tuning'); // requesting MSP_STATUS manually because it contains CONFIG.profile MSP.send_message(MSP_codes.MSP_STATUS, false, false, get_pid_names); diff --git a/tabs/receiver.js b/tabs/receiver.js index 7b924f2c..125f81d1 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -2,7 +2,7 @@ tabs.receiver = {}; tabs.receiver.initialize = function(callback) { GUI.active_tab_ref = this; 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); diff --git a/tabs/sensors.js b/tabs/sensors.js index bdcce565..47ebe7b4 100644 --- a/tabs/sensors.js +++ b/tabs/sensors.js @@ -2,7 +2,7 @@ tabs.sensors = {}; tabs.sensors.initialize = function(callback) { GUI.active_tab_ref = this; GUI.active_tab = 'sensors'; - ga_tracker.sendAppView('Sensor Page'); + googleAnalytics.sendAppView('Sensor Page'); function initSensorData(){ for (var i = 0; i < 3; i++) { diff --git a/tabs/servos.js b/tabs/servos.js index b16b1572..09c21377 100644 --- a/tabs/servos.js +++ b/tabs/servos.js @@ -9,7 +9,7 @@ tabs.servos = {}; tabs.servos.initialize = function(callback) { GUI.active_tab_ref = this; GUI.active_tab = 'servos'; - ga_tracker.sendAppView('Servos'); + googleAnalytics.sendAppView('Servos'); MSP.send_message(MSP_codes.MSP_IDENT, false, false, get_servo_conf_data);