analytics overhaul
parent
fb7cbe0c8f
commit
1885fba5a0
10
js/serial.js
10
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 <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) {
|
||||
$('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');
|
||||
|
|
|
@ -143,7 +143,7 @@ STM32_protocol.prototype.initialize = function() {
|
|||
} else {
|
||||
console.log('STM32 - timed out, programming failed ...');
|
||||
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
|
||||
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: <strong style="color: green">SUCCESSFUL</strong>');
|
||||
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: <strong style="color: red">FAILED</strong>');
|
||||
ga_tracker.sendEvent('Flashing', 'Programming', 'fail');
|
||||
googleAnalytics.sendEvent('Flashing', 'Programming', 'fail');
|
||||
|
||||
// update progress bar
|
||||
self.progress_bar_e.addClass('invalid');
|
||||
|
|
|
@ -421,7 +421,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
|
|||
if (verify) {
|
||||
console.log('Programming: SUCCESSFUL');
|
||||
GUI.log('Programming: <strong style="color: green">SUCCESSFUL</strong>');
|
||||
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: <strong style="color: red">FAILED</strong>');
|
||||
ga_tracker.sendEvent('Flashing', 'Programming', 'fail');
|
||||
googleAnalytics.sendEvent('Flashing', 'Programming', 'fail');
|
||||
|
||||
// update progress bar
|
||||
self.progress_bar_e.addClass('invalid');
|
||||
|
|
36
main.js
36
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 id="options-window"></div>');
|
||||
$('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();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"minimum_chrome_version": "33",
|
||||
"version": "0.46",
|
||||
"version": "0.47",
|
||||
|
||||
"author": "cTn",
|
||||
"name": "Baseflight - Configurator",
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 = [];
|
||||
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue