Improvements to analytics collection.

10.4.x-maintenance
mikeller 2018-08-12 20:19:02 +12:00
parent 5a3bda615d
commit 6b7ac3e542
7 changed files with 122 additions and 10 deletions

View File

@ -22,6 +22,7 @@ const concat = require('gulp-concat');
const install = require("gulp-install"); const install = require("gulp-install");
const rename = require('gulp-rename'); const rename = require('gulp-rename');
const os = require('os'); const os = require('os');
const git = require('gulp-git');
const DIST_DIR = './dist/'; const DIST_DIR = './dist/';
const APPS_DIR = './apps/'; const APPS_DIR = './apps/';
@ -60,7 +61,9 @@ gulp.task('clean-release', clean_release);
gulp.task('clean-cache', clean_cache); gulp.task('clean-cache', clean_cache);
var distBuild = gulp.series(dist_src, dist_locale, dist_libraries, dist_resources); gulp.task('get-changeset-id', getChangesetId);
var distBuild = gulp.series(dist_src, dist_locale, dist_libraries, dist_resources, getChangesetId);
var distRebuild = gulp.series(clean_dist, distBuild); var distRebuild = gulp.series(clean_dist, distBuild);
gulp.task('dist', distRebuild); gulp.task('dist', distRebuild);
@ -433,6 +436,20 @@ function buildNWApps(platforms, flavor, dir, done) {
} }
} }
function getChangesetId(done) {
git.exec({args : 'log -1 --format="%h"'}, function (err, stdout) {
if (err) {
throw err;
}
var versionData = { gitChangesetId: stdout.trim() }
var destFile = path.join(DIST_DIR, 'version.json');
fs.writeFile(destFile, JSON.stringify(versionData) , function () {
done();
});
});
}
function start_debug(done) { function start_debug(done) {

77
package-lock.json generated
View File

@ -201,6 +201,12 @@
"integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=",
"dev": true "dev": true
}, },
"any-shell-escape": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/any-shell-escape/-/any-shell-escape-0.1.1.tgz",
"integrity": "sha1-1Vq5ciRMcaml4asIefML8RCAaVk=",
"dev": true
},
"anymatch": { "anymatch": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz",
@ -2374,6 +2380,15 @@
"parse-filepath": "^1.0.1" "parse-filepath": "^1.0.1"
} }
}, },
"first-chunk-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz",
"integrity": "sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA=",
"dev": true,
"requires": {
"readable-stream": "^2.0.2"
}
},
"flagged-respawn": { "flagged-respawn": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.0.tgz", "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.0.tgz",
@ -3465,6 +3480,43 @@
} }
} }
}, },
"gulp-git": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/gulp-git/-/gulp-git-2.8.0.tgz",
"integrity": "sha512-45pahZGIcsb6eCJS9EGCdXqYBbxE1dtSbS03iXIF3dHHor1r37KMqwoQQJv1SXJjpLKc6ei+rdvIl7Ar6tB+ow==",
"dev": true,
"requires": {
"any-shell-escape": "^0.1.1",
"fancy-log": "^1.3.2",
"lodash.template": "^4.4.0",
"plugin-error": "^0.1.2",
"require-dir": "^1.0.0",
"strip-bom-stream": "^3.0.0",
"through2": "^2.0.3",
"vinyl": "^2.0.1"
},
"dependencies": {
"lodash.template": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz",
"integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=",
"dev": true,
"requires": {
"lodash._reinterpolate": "~3.0.0",
"lodash.templatesettings": "^4.0.0"
}
},
"lodash.templatesettings": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz",
"integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=",
"dev": true,
"requires": {
"lodash._reinterpolate": "~3.0.0"
}
}
}
},
"gulp-install": { "gulp-install": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/gulp-install/-/gulp-install-1.1.0.tgz", "resolved": "https://registry.npmjs.org/gulp-install/-/gulp-install-1.1.0.tgz",
@ -6920,6 +6972,12 @@
"when": "^3.7.7" "when": "^3.7.7"
} }
}, },
"require-dir": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/require-dir/-/require-dir-1.0.0.tgz",
"integrity": "sha512-PUJcQVTP4n6F8Un1GEEWhqnmBMfukVsL5gqwBxt7RF+nP+9hSOLJ/vSs5iUoXw1UWDgzqg9B/IIb15kfQKWsAQ==",
"dev": true
},
"require-directory": { "require-directory": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@ -7764,6 +7822,25 @@
"is-utf8": "^0.2.0" "is-utf8": "^0.2.0"
} }
}, },
"strip-bom-buf": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz",
"integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=",
"dev": true,
"requires": {
"is-utf8": "^0.2.1"
}
},
"strip-bom-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-stream/-/strip-bom-stream-3.0.0.tgz",
"integrity": "sha1-lWvMXYRDD2klapDtgjdlzYWOFZw=",
"dev": true,
"requires": {
"first-chunk-stream": "^2.0.0",
"strip-bom-buf": "^1.0.0"
}
},
"strip-eof": { "strip-eof": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",

View File

@ -52,6 +52,7 @@
"gulp": "~4.0.0", "gulp": "~4.0.0",
"gulp-concat": "~2.6.1", "gulp-concat": "~2.6.1",
"gulp-debian": "~0.1.8", "gulp-debian": "~0.1.8",
"gulp-git": "^2.8.0",
"gulp-install": "^1.1.0", "gulp-install": "^1.1.0",
"gulp-rename": "~1.2.2", "gulp-rename": "~1.2.2",
"gulp-zip": "^4.1.0", "gulp-zip": "^4.1.0",

View File

@ -1473,6 +1473,12 @@ dialog {
transition: none; transition: none;
} }
.connect_b a.connect.disabled {
background-color: #808080;
pointer-events: none;
cursor: default;
}
.connect_b a.connect { .connect_b a.connect {
background-color: #ffbb00; background-color: #ffbb00;
border: 1px solid #dba718; border: 1px solid #dba718;

View File

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

View File

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

View File

@ -125,7 +125,7 @@
<div id="port-picker"> <div id="port-picker">
<div class="connect_controls" id="connectbutton"> <div class="connect_controls" id="connectbutton">
<div class="connect_b"> <div class="connect_b">
<a class="connect" href="#"></a> <a class="connect disabled" href="#"></a>
</div> </div>
<a class="connect_state" i18n="connect"></a> <a class="connect_state" i18n="connect"></a>
</div> </div>