1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Merge pull request #1154 from mikeller/analytics_improvements

Improvements to analytics collection.
This commit is contained in:
Michael Keller 2018-08-13 08:14:32 +12:00 committed by GitHub
commit dc67b06c8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 122 additions and 10 deletions

View file

@ -1,6 +1,6 @@
'use strict';
var Analytics = function (trackingId, userId, appName, appVersion, buildType, optOut, debugMode) {
var Analytics = function (trackingId, userId, appName, appVersion, changesetId, buildType, checkForDebugVersions, optOut, debugMode) {
this._trackingId = trackingId;
this.setOptOut(optOut);
@ -58,6 +58,8 @@ var Analytics = function (trackingId, userId, appName, appVersion, buildType, op
FIRMWARE_CHANNEL: 10,
LOGGING_STATUS: 11,
MCU_ID: 12,
CONFIGURATOR_CHANGESET_ID: 13,
CONFIGURATOR_USE_DEBUG_VERSIONS: 14,
};
this.METRICS = {
@ -66,6 +68,8 @@ var Analytics = function (trackingId, userId, appName, appVersion, buildType, op
};
this.setDimension(this.DIMENSIONS.CONFIGURATOR_BUILD_TYPE, buildType);
this.setDimension(this.DIMENSIONS.CONFIGURATOR_CHANGESET_ID, changesetId);
this.setDimension(this.DIMENSIONS.CONFIGURATOR_USE_DEBUG_VERSIONS, checkForDebugVersions);
this.resetFlightControllerData();
this.resetFirmwareData();

View file

@ -15,12 +15,16 @@ $(document).ready(function () {
function checkSetupAnalytics(callback) {
if (!analytics) {
setTimeout(function () {
chrome.storage.local.get(['userId', 'analyticsOptOut'], function (result) {
if (!analytics) {
setupAnalytics(result);
}
chrome.storage.local.get(['userId', 'analyticsOptOut', 'checkForConfiguratorUnstableVersions', ], function (result) {
$.getJSON('version.json', function(data) {
var gitChangesetId = data.gitChangesetId;
callback(analytics);
if (!analytics) {
setupAnalytics(result, gitChangesetId);
}
callback(analytics);
});
});
});
} else if (callback) {
@ -28,7 +32,7 @@ function checkSetupAnalytics(callback) {
}
};
function setupAnalytics(result) {
function setupAnalytics(result, gitChangesetId) {
var userId;
if (result.userId) {
userId = result.userId;
@ -40,10 +44,11 @@ function setupAnalytics(result) {
}
var optOut = !!result.analyticsOptOut;
var checkForDebugVersions = !!result.checkForConfiguratorUnstableVersions;
var debugMode = process.versions['nw-flavor'] === 'sdk';
analytics = new Analytics('UA-123002063-1', userId, 'Betaflight Configurator', getManifestVersion(), GUI.operating_system, optOut, debugMode);
analytics = new Analytics('UA-123002063-1', userId, 'Betaflight Configurator', getManifestVersion(), gitChangesetId, GUI.operating_system, checkForDebugVersions, optOut, debugMode);
function logException(exception) {
analytics.sendException(exception.stack);
@ -69,6 +74,8 @@ function setupAnalytics(result) {
// Looks like we're in Chrome - but the event does not actually get fired
chrome.runtime.onSuspend.addListener(sendCloseEvent);
}
$('.connect_b a.connect').removeClass('disabled');
}
//Process to execute to real start the app