Skip to content

Commit 005868b

Browse files
committed
Added analytics for new configurator elements.
1 parent 93e4cf8 commit 005868b

File tree

11 files changed

+239
-117
lines changed

11 files changed

+239
-117
lines changed

locales/en/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,7 @@
24612461
"message": "Load from file"
24622462
},
24632463
"cliConfirmSnippetDialogTitle": {
2464-
"message": "Review loaded commands"
2464+
"message": "Loaded file <strong>{{fileName}}</strong>. Review the loaded commands"
24652465
},
24662466
"cliConfirmSnippetNote": {
24672467
"message": "<strong>Note</strong>: You can review and edit commands before execution."

src/js/Analytics.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ var Analytics = function (trackingId, userId, appName, appVersion, changesetId,
3535
FIRMWARE_TYPE: 'firmwareType',
3636
FIRMWARE_VERSION: 'firmwareVersion',
3737
FIRMWARE_NAME: 'firmwareName',
38-
FIRMWARE_CHECKSUM: 'firmwareChecksum',
3938
FIRMWARE_SOURCE: 'firmwareSource',
4039
FIRMWARE_CHANNEL: 'firmwareChannel',
4140
FIRMWARE_ERASE_ALL: 'firmwareEraseAll',
@@ -158,7 +157,6 @@ Analytics.prototype._rebuildFirmwareEvent = function () {
158157
this.setDimension(this.DIMENSIONS.FIRMWARE_ERASE_ALL, this._firmwareData[this.DATA.FIRMWARE_ERASE_ALL]);
159158
this.setDimension(this.DIMENSIONS.FIRMWARE_CHANNEL, this._firmwareData[this.DATA.FIRMWARE_CHANNEL]);
160159
this.setMetric(this.METRICS.FIRMWARE_SIZE, this._firmwareData[this.DATA.FIRMWARE_SIZE]);
161-
this._googleAnalytics.set('eventLabel', this._firmwareData[this.DATA.FIRMWARE_CHECKSUM]);
162160
}
163161

164162
Analytics.prototype.setFirmwareData = function (property, value) {

src/js/CliAutoComplete.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ CliAutoComplete.setEnabled = function(enable) {
5151
};
5252

5353
CliAutoComplete.initialize = function($textarea, sendLine, writeToOutput) {
54+
analytics.sendEvent(analytics.EVENT_CATEGORIES.APPLICATION, 'CliAutoComplete', this.configEnabled);
55+
5456
this.$textarea = $textarea;
5557
this.forceOpen = false,
5658
this.sendLine = sendLine;

src/js/localization.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const languagesAvailables = ['ca', 'de', 'en', 'es', 'fr', 'gl', 'hr', 'id', 'it
1212
* Functions that depend on the i18n framework
1313
*/
1414
i18n.init = function(cb) {
15-
16-
getStoredUserLocale(function(userLanguage){
15+
getStoredUserLocale(function(userLanguage) {
1716

1817
i18next
1918
.use(i18nextXHRBackend)

src/js/main.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ $(document).ready(function () {
2121
}
2222
i18n.init(function() {
2323
startProcess();
24+
25+
checkSetupAnalytics(function (analytics) {
26+
analytics.sendEvent(analytics.EVENT_CATEGORIES.APPLICATION, 'SelectedLanguage', i18n.selectedLanguage);
27+
});
28+
2429
initializeSerialBackend();
2530
});
2631
});
@@ -106,7 +111,7 @@ function startProcess() {
106111
i18n.localizePage();
107112

108113
// alternative - window.navigator.appVersion.match(/Chrome\/([0-9.]*)/)[1];
109-
GUI.log(i18n.getMessage('infoVersions',{operatingSystem: GUI.operating_system,
114+
GUI.log(i18n.getMessage('infoVersions', { operatingSystem: GUI.operating_system,
110115
chromeVersion: window.navigator.appVersion.replace(/.*Chrome\/([0-9.]*).*/, "$1"),
111116
configuratorVersion: CONFIGURATOR.version }));
112117

@@ -391,7 +396,7 @@ function startProcess() {
391396
var checked = $(this).is(':checked');
392397

393398
ConfigStorage.set({'darkTheme': checked});
394-
DarkTheme.setConfig(checked);
399+
setDarkTheme(checked);
395400
}).change();
396401

397402
function close_and_cleanup(e) {
@@ -543,10 +548,18 @@ function startProcess() {
543548
});
544549

545550
ConfigStorage.get('darkTheme', function (result) {
546-
DarkTheme.setConfig(result.darkTheme);
551+
setDarkTheme(result.darkTheme);
547552
});
548553
};
549554

555+
function setDarkTheme(enabled) {
556+
DarkTheme.setConfig(enabled);
557+
558+
checkSetupAnalytics(function (analytics) {
559+
analytics.sendEvent(analytics.EVENT_CATEGORIES.APPLICATION, 'DarkTheme', enabled);
560+
});
561+
}
562+
550563
function checkForConfiguratorUpdates() {
551564
var releaseChecker = new ReleaseChecker('configurator', 'https://api.github.com/repos/betaflight/betaflight-configurator/releases');
552565

src/js/tabs/cli.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function getCliCommand(command, cliBuffer) {
4646

4747
function copyToClipboard(text) {
4848
function onCopySuccessful() {
49+
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'CliCopyToClipboard', text.length);
4950
const button = $('.tab-cli .copy');
5051
const origText = button.text();
5152
const origWidth = button.css("width");
@@ -207,13 +208,16 @@ TABS.cli.initialize = function (callback) {
207208

208209
let previewArea = $("#snippetpreviewcontent textarea#preview");
209210

210-
function executeSnippet() {
211+
function executeSnippet(fileName) {
211212
const commands = previewArea.val();
213+
214+
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'CliExecuteFromFile', fileName);
215+
212216
executeCommands(commands);
213217
self.GUI.snippetPreviewWindow.close();
214218
}
215219

216-
function previewCommands(result) {
220+
function previewCommands(result, fileName) {
217221
if (!self.GUI.snippetPreviewWindow) {
218222
self.GUI.snippetPreviewWindow = new jBox("Modal", {
219223
id: "snippetPreviewWindow",
@@ -222,10 +226,10 @@ TABS.cli.initialize = function (callback) {
222226
closeButton: 'title',
223227
animation: false,
224228
isolateScroll: false,
225-
title: i18n.getMessage("cliConfirmSnippetDialogTitle"),
229+
title: i18n.getMessage("cliConfirmSnippetDialogTitle", { fileName: fileName }),
226230
content: $('#snippetpreviewcontent'),
227231
onCreated: () =>
228-
$("#snippetpreviewcontent a.confirm").click(() => executeSnippet())
232+
$("#snippetpreviewcontent a.confirm").click(() => executeSnippet(fileName))
229233
,
230234
});
231235
}
@@ -236,7 +240,7 @@ TABS.cli.initialize = function (callback) {
236240
entry.file((file) => {
237241
let reader = new FileReader();
238242
reader.onload =
239-
() => previewCommands(reader.result);
243+
() => previewCommands(reader.result, file.name);
240244
reader.onerror = () => console.error(reader.error);
241245
reader.readAsText(file);
242246
});

src/js/tabs/configuration.js

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,42 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
353353
orientation_acc_e.val(SENSOR_ALIGNMENT.align_acc);
354354
orientation_mag_e.val(SENSOR_ALIGNMENT.align_mag);
355355

356+
orientation_gyro_e.change(function () {
357+
let value = parseInt($(this).val());
358+
359+
let newValue = undefined;
360+
if (value !== SENSOR_ALIGNMENT.align_gyro) {
361+
newValue = $(this).find('option:selected').text();
362+
}
363+
self.analyticsChanges['GyroAlignment'] = newValue;
364+
365+
SENSOR_ALIGNMENT.align_gyro = value;
366+
});
367+
368+
orientation_acc_e.change(function () {
369+
let value = parseInt($(this).val());
370+
371+
let newValue = undefined;
372+
if (value !== SENSOR_ALIGNMENT.align_acc) {
373+
newValue = $(this).find('option:selected').text();
374+
}
375+
self.analyticsChanges['AccAlignment'] = newValue;
376+
377+
SENSOR_ALIGNMENT.align_acc = value;
378+
});
379+
380+
orientation_mag_e.change(function () {
381+
let value = parseInt($(this).val());
382+
383+
let newValue = undefined;
384+
if (value !== SENSOR_ALIGNMENT.align_mag) {
385+
newValue = $(this).find('option:selected').text();
386+
}
387+
self.analyticsChanges['MagAlignment'] = newValue;
388+
389+
SENSOR_ALIGNMENT.align_mag = value;
390+
});
391+
356392
// Multi gyro config
357393
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
358394

@@ -393,6 +429,30 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
393429
$('.gyro_alignment_inputs_second').toggle(detected_gyro_2);
394430
$('.gyro_alignment_inputs_selection').toggle(detected_gyro_1 || detected_gyro_2);
395431
$('.gyro_alignment_inputs_notfound').toggle(!detected_gyro_1 && !detected_gyro_2);
432+
433+
orientation_gyro_1_align_e.change(function () {
434+
let value = parseInt($(this).val());
435+
436+
let newValue = undefined;
437+
if (value !== SENSOR_ALIGNMENT.gyro_1_align) {
438+
newValue = $(this).find('option:selected').text();
439+
}
440+
self.analyticsChanges['Gyro1Alignment'] = newValue;
441+
442+
SENSOR_ALIGNMENT.gyro_1_align = value;
443+
});
444+
445+
orientation_gyro_2_align_e.change(function () {
446+
let value = parseInt($(this).val());
447+
448+
let newValue = undefined;
449+
if (value !== SENSOR_ALIGNMENT.gyro_2_align) {
450+
newValue = $(this).find('option:selected').text();
451+
}
452+
self.analyticsChanges['Gyro2Alignment'] = newValue;
453+
454+
SENSOR_ALIGNMENT.gyro_2_align = value;
455+
});
396456
}
397457
}
398458

@@ -437,8 +497,24 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
437497
$('input[id="unsyncedPWMSwitch"]').prop('checked', PID_ADVANCED_CONFIG.use_unsyncedPwm !== 0).change();
438498
$('input[name="unsyncedpwmfreq"]').val(PID_ADVANCED_CONFIG.motor_pwm_rate);
439499
$('input[name="digitalIdlePercent"]').val(PID_ADVANCED_CONFIG.digitalIdlePercent);
440-
$('input[id="dshotBidir"]').prop('checked', MOTOR_CONFIG.use_dshot_telemetry).change();
441-
$('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles);
500+
if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
501+
let dshotBidirectional_e = $('input[id="dshotBidir"]');
502+
dshotBidirectional_e.prop('checked', MOTOR_CONFIG.use_dshot_telemetry).change();
503+
504+
dshotBidirectional_e.change(function () {
505+
let value = $(this).prop('checked');
506+
507+
var newValue = undefined;
508+
if (value !== MOTOR_CONFIG.use_dshot_telemetry) {
509+
newValue = value ? 'On' : 'Off';
510+
}
511+
self.analyticsChanges['BidirectionalDshot'] = newValue;
512+
513+
MOTOR_CONFIG.use_dshot_telemetry = value;
514+
});
515+
516+
$('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles);
517+
}
442518

443519
esc_protocol_e.val(PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
444520
esc_protocol_e.change(function () {
@@ -1069,7 +1145,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
10691145
MOTOR_CONFIG.mincommand = parseInt($('input[name="mincommand"]').val());
10701146
if(semver.gte(CONFIG.apiVersion, "1.42.0")) {
10711147
MOTOR_CONFIG.motor_poles = parseInt($('input[name="motorPoles"]').val());
1072-
MOTOR_CONFIG.use_dshot_telemetry = $('input[id="dshotBidir"]').prop('checked');
10731148
}
10741149

10751150
if(self.SHOW_OLD_BATTERY_CONFIG) {
@@ -1089,13 +1164,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
10891164
MOTOR_3D_CONFIG.neutral = parseInt($('input[name="3dneutral"]').val());
10901165
}
10911166

1092-
SENSOR_ALIGNMENT.align_gyro = parseInt(orientation_gyro_e.val());
1093-
SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val());
1094-
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
10951167
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
10961168
SENSOR_ALIGNMENT.gyro_to_use = parseInt(orientation_gyro_to_use_e.val());
1097-
SENSOR_ALIGNMENT.gyro_1_align = parseInt(orientation_gyro_1_align_e.val());
1098-
SENSOR_ALIGNMENT.gyro_2_align = parseInt(orientation_gyro_2_align_e.val());
10991169
}
11001170

11011171
PID_ADVANCED_CONFIG.fast_pwm_protocol = parseInt(esc_protocol_e.val()-1);

0 commit comments

Comments
 (0)