Skip to content

Commit 328faa1

Browse files
committed
Updating to Matomo analytics tracking.
1 parent 95f8709 commit 328faa1

29 files changed

+193
-161
lines changed

resources/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--
44
about.html
5-
BarcodeAPI.org, 2017-2024
5+
BarcodeAPI.org, 2017-2025
66
-->
77

88
<head>

resources/admin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--
44
admin.html
5-
BarcodeAPI.org, 2017-2024
5+
BarcodeAPI.org, 2017-2025
66
-->
77

88
<head>

resources/api.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--
44
api.html
5-
BarcodeAPI.org, 2017-2024
5+
BarcodeAPI.org, 2017-2025
66
-->
77

88
<head>

resources/bulk.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--
44
bulk.html
5-
BarcodeAPI.org, 2017-2024
5+
BarcodeAPI.org, 2017-2025
66
-->
77

88
<head>
@@ -93,7 +93,7 @@ <h2>Bulk Barcode Generator</h2>
9393
</div>
9494

9595
<div class="col-xs-8">
96-
<form method="post" action="bulk/" enctype="multipart/form-data">
96+
<form method="post" onsubmit="onUpload(event);" action="bulk/" enctype="multipart/form-data">
9797
<div class="row center-xs middle-xs">
9898
<div class="col-xs-6">
9999
<input type="file" id="csvFile" name="csvFile" class="file-input">

resources/contracts.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--
44
contracts.html
5-
BarcodeAPI.org, 2017-2024
5+
BarcodeAPI.org, 2017-2025
66
-->
77

88
<head>
@@ -23,7 +23,7 @@
2323
<script src="/ext/js/ui.js"></script>
2424
</head>
2525

26-
<body onload="displayTokenCount();">
26+
<body>
2727
<div class="wrapper container-fluid">
2828

2929
<div class="header row between-sm start-sm center-xs">

resources/decode.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--
44
bulk.html
5-
BarcodeAPI.org, 2017-2024
5+
BarcodeAPI.org, 2017-2025
66
-->
77

88
<head>

resources/ext/js/admin.js

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
11
//
2-
// BarcodeAPI.org, 2023
2+
// BarcodeAPI.org, 2017-2025
33
// admin.js // admin.html
44
//
55

6-
function fetch(path, callback) {
7-
8-
var xobj = new XMLHttpRequest();
9-
xobj.overrideMimeType("application/json");
10-
11-
xobj.open('GET', path, true);
12-
xobj.onreadystatechange = function() {
13-
if (xobj.readyState === 4 && xobj.status === 200) {
14-
callback(JSON.parse(xobj.responseText));
15-
}
16-
};
17-
18-
xobj.send(null);
19-
}
20-
216
function zero(x) {
227
return ((x < 10) ? ("0" + x) : x);
238
}
249

2510
function loadInfo() {
26-
fetch("/info/", function(info) {
11+
fetch("/info/").then(response => {
12+
return response.json();
13+
}).then(onLoadInfo);
14+
}
15+
16+
function onLoadInfo(info) {
17+
18+
// display hostname and version
19+
document.getElementById("appHost").innerHTML = info.hostname;
20+
document.getElementById("appVersion").innerHTML = info.version;
2721

28-
// display hostname and version
29-
document.getElementById("appHost").innerHTML = info.hostname;
30-
document.getElementById("appVersion").innerHTML = info.version;
22+
// calculate uptime in HH:MM
23+
var sinceH = Math.floor((info.uptime / 1000 / 60 / 60)).toFixed(0);
24+
var sinceM = Math.floor((info.uptime / 1000 / 60 % 60)).toFixed(0);
3125

32-
// calculate uptime in HH:MM
33-
var sinceH = Math.floor((info.uptime / 1000 / 60 / 60)).toFixed(0);
34-
var sinceM = Math.floor((info.uptime / 1000 / 60 % 60)).toFixed(0);
26+
// display uptime
27+
var uptime = ("+" + zero(sinceH) + ":" + zero(sinceM));
28+
document.getElementById("appUptime").innerHTML = uptime;
3529

36-
// display uptime
37-
var uptime = ("+" + zero(sinceH) + ":" + zero(sinceM));
38-
document.getElementById("appUptime").innerHTML = uptime;
39-
});
30+
// Log tracking event
31+
var setupMillis = ((new Date()) - timeStart);
32+
trackingEvent("AppEvents", "AppLoad", "Admin", setupMillis);
4033
}

resources/ext/js/bulk.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// BarcodeAPI.org, 2017-2025
3+
// bulk.js // bulk.html
4+
//
15

26
var submitButton;
37

@@ -9,7 +13,8 @@ function init() {
913
document.getElementById("csvFile").addEventListener('change', checkIfFileSelected);
1014

1115
// Log tracking event
12-
trackingEvent("app_bulk_load");
16+
var setupMillis = ((new Date()) - timeStart);
17+
trackingEvent("AppEvents", "AppLoad", "Bulk", setupMillis);
1318
}
1419

1520
function actionDownloadCSV() {
@@ -29,7 +34,7 @@ function actionDownloadCSV() {
2934
document.body.removeChild(a);
3035

3136
// Log tracking event
32-
trackingEvent("app_bulk_example");
37+
trackingEvent("Bulk", "Download", "Example");
3338
}
3439

3540
function checkIfFileSelected(obj) {
@@ -52,6 +57,14 @@ function checkIfFileSelected(obj) {
5257
}
5358
}
5459

60+
function onUpload(e) {
61+
62+
// Log tracking event
63+
trackingEvent("Bulk", "Upload");
64+
65+
return false;
66+
}
67+
5568
var csvExample = [
5669
"Aztec Barcode,aztec",
5770
"1234567890,codabar",

resources/ext/js/decode.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
2-
// BarcodeAPI.org
3-
// decode.js
2+
// BarcodeAPI.org, 2017-2025
3+
// decode.js // decode.html
44
//
55

66
// 2MB max upload file size
@@ -20,7 +20,8 @@ function init() {
2020
clearButton.addEventListener("click", clearPreview);
2121

2222
// Log tracking event
23-
trackingEvent("app_decode_load");
23+
var setupMillis = ((new Date()) - timeStart);
24+
trackingEvent("AppEvents", "AppLoad", "Decode", setupMillis);
2425
}
2526

2627
function handleFileSelection() {
@@ -66,6 +67,9 @@ function previewImage(file) {
6667
img.style.display = 'block';
6768
};
6869
reader.readAsDataURL(file);
70+
71+
// Log tracking event
72+
trackingEvent("Decode", "Preview");
6973
}
7074

7175
function clearPreview() {
@@ -112,5 +116,5 @@ function submitForDecode(e) {
112116
});
113117

114118
// Log tracking event
115-
trackingEvent("app_decode_upload");
119+
trackingEvent("Decode", "Upload");
116120
}

resources/ext/js/index.js

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
2-
// BarcodeAPI.org
3-
// index.js
2+
// BarcodeAPI.org, 2017-2025
3+
// index.js // index.html
44
//
55

66
/**
@@ -86,7 +86,8 @@ async function init() {
8686
window.onbeforeunload = actionCloseKeyboard;
8787

8888
// Log tracking event
89-
trackingEvent("app_main_load");
89+
var setupMillis = ((new Date()) - timeStart);
90+
trackingEvent("AppEvents", "AppLoad", "Main", setupMillis);
9091
}
9192

9293
/**
@@ -209,8 +210,8 @@ function loadSelectedType() {
209210
text.focus();
210211

211212
// Log tracking event
212-
trackingEvent("app_main_type", //
213-
((codeType) ? { "type": codeType.name } : null));
213+
trackingEvent("AppMain", "TypeChange", //
214+
(codeType) ? codeType.name : "Auto");
214215
}
215216

216217
function renderOptions(type) {
@@ -371,31 +372,32 @@ function updateBarcodeImage(url) {
371372
}
372373

373374
// Request the image
374-
fetch(url, options).then(response => {
375-
376-
// Upate token count if not cached
377-
var tokens = response.headers.get('x-ratelimit-tokens');
378-
tokens = (tokens == -1) ? "Unlimited" : tokens;
379-
document.getElementById("barcode_tokens").innerHTML = tokens;
380-
381-
// Update learn more link
382-
var codeType = response.headers.get('x-barcode-type');
383-
var displayType = codeType.replace("_", " ");
384-
var linkType = codeType.replace("_", "");
385-
386-
// Update learn more link
387-
var link = document.getElementsByClassName("link-more")[0];
388-
link.innerHTML = "Learn more about " + displayType + " barcodes!";
389-
link.href = "/type.html#" + linkType;
390-
391-
// Update the image blob
392-
response.blob().then(blob => {
393-
document.getElementById('barcode_output').src = URL.createObjectURL(blob);
375+
fetch(url, options)
376+
.then(response => {
377+
378+
// Upate token count if not cached
379+
var tokens = response.headers.get('x-ratelimit-tokens');
380+
tokens = (tokens == -1) ? "Unlimited" : tokens;
381+
document.getElementById("barcode_tokens").innerHTML = tokens;
382+
383+
// Update learn more link
384+
var codeType = response.headers.get('x-barcode-type');
385+
var displayType = codeType.replace("_", " ");
386+
var linkType = codeType.replace("_", "");
387+
388+
// Update learn more link
389+
var link = document.getElementsByClassName("link-more")[0];
390+
link.innerHTML = "Learn more about " + displayType + " barcodes!";
391+
link.href = "/type.html#" + linkType;
392+
393+
// Update the image blob
394+
response.blob().then(blob => {
395+
document.getElementById('barcode_output').src = URL.createObjectURL(blob);
396+
});
394397
});
395-
});
396398

397399
// Log tracking event
398-
trackingEvent("app_main_generate");
400+
trackingEvent("AppMain", "Generate");
399401
}
400402

401403
/**
@@ -524,11 +526,17 @@ function showRenderMenu(show) {
524526
*/
525527
function toggleShowRenderOptions() {
526528

527-
// Toggle render options dropdown state
528-
showRenderMenu(!appState.optionsOpen);
529+
// Determine opposite state
530+
var stateNew = !appState.optionsOpen;
529531

530-
// Log tracking event
531-
trackingEvent("app_main_options");
532+
// Set new state
533+
showRenderMenu(stateNew);
534+
535+
if (stateNew) {
536+
537+
// Log tracking event
538+
trackingEvent("AppMain", "Options");
539+
}
532540
}
533541

534542
/**
@@ -555,7 +563,7 @@ function actionShowKeyboard() {
555563
}
556564

557565
// Log tracking event
558-
trackingEvent("app_main_keyboard");
566+
trackingEvent("AppMain", "Keyboard");
559567
}
560568

561569
/**
@@ -580,7 +588,7 @@ function actionPrintImage() {
580588
w.close();
581589

582590
// Log tracking event
583-
trackingEvent("app_main_print");
591+
trackingEvent("AppMain", "Print");
584592
}
585593

586594
/**
@@ -629,7 +637,7 @@ async function actionCopyImage() {
629637
}
630638

631639
// Log tracking event
632-
trackingEvent("app_main_copy");
640+
trackingEvent("AppMain", "Copy");
633641
}
634642

635643
/**
@@ -640,7 +648,7 @@ function actionDownloadImage() {
640648
window.open(appState.current, '_blank');
641649

642650
// Log tracking event
643-
trackingEvent("app_main_download")
651+
trackingEvent("AppMain", "Download");
644652
}
645653

646654
/**

resources/ext/js/keyboard.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
2-
// BarcodeAPI.org
3-
// keyboard.js
2+
// BarcodeAPI.org, 2017-2025
3+
// keyboard.js // keyboard.html
44
//
55

66
function init() {

resources/ext/js/limits.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//
2+
// BarcodeAPI.org, 2017-2025
3+
// limits.js // limits.html
4+
//
5+
16
window.addEventListener("load", function() {
27

38
fetch('/limiter/')
@@ -14,8 +19,9 @@ window.addEventListener("load", function() {
1419

1520
document.getElementById("token_limit").innerHTML = //
1621
((data.tokenLimit == -1) ? "Unlimited" : data.tokenLimit);
17-
});
1822

19-
// Log tracking event
20-
trackingEvent("app_limits_load");
23+
// Log tracking event
24+
var setupMillis = ((new Date()) - timeStart);
25+
trackingEvent("AppEvents", "AppLoad", "Limits", setupMillis);
26+
});
2127
});

0 commit comments

Comments
 (0)