From a5abde23f8d58767c9131b9cd8b552ca63c8075c Mon Sep 17 00:00:00 2001 From: Mattk70 Date: Mon, 12 Feb 2024 17:59:02 +0000 Subject: [PATCH] Do not track option Better event handling Full list of non-avian species --- index.html | 35 +++++---- js/BirdNet2.4.js | 4 +- js/listWorker.js | 188 +++++++++++++++++++++++++---------------------- js/ui.js | 76 +++++++++---------- js/worker.js | 1 + 5 files changed, 162 insertions(+), 142 deletions(-) diff --git a/index.html b/index.html index 9cf53fa6..3f050322 100644 --- a/index.html +++ b/index.html @@ -309,7 +309,7 @@
Saved Records
- +
@@ -510,9 +510,9 @@
Saved Records
- ? + ?
@@ -549,7 +549,7 @@
Saved Records
- +
Spectrogram Preferences @@ -598,7 +598,7 @@
Saved Records
science Advanced features ? + class="material-symbols-outlined align-middle">science Advanced features ?
@@ -615,7 +615,7 @@
Saved Records
- ?
-
-
-
- ? + +
+
+
- + ?
-
-
+
+
+
+ + ? +
+
+
+
+ diff --git a/js/BirdNet2.4.js b/js/BirdNet2.4.js index 79e49986..58b4bcfd 100644 --- a/js/BirdNet2.4.js +++ b/js/BirdNet2.4.js @@ -320,9 +320,9 @@ class Model { const finalPrediction = newPrediction || prediction; const { indices, values } = tf.topk(finalPrediction, 5, true); - const topIndices = await indices.array(); + const topIndices = indices.arraySync(); indices.dispose(); - const topValues = await values.array(); + const topValues = values.arraySync(); values.dispose(); // end new // const array_of_predictions = finalPrediction.arraySync() diff --git a/js/listWorker.js b/js/listWorker.js index a783e1af..4f578c3d 100644 --- a/js/listWorker.js +++ b/js/listWorker.js @@ -10,92 +10,108 @@ let NOT_BIRDS; const NOCTURNAL = new Set(["Pluvialis dominica_American Golden Plover", "Acanthis hornemanni_Arctic Redpoll", "Sterna paradisaea_Arctic Tern", "Recurvirostra avosetta_Avocet", "Porzana pusilla_Baillon's Crake", "Limosa lapponica_Bar-tailed Godwit", "Tyto alba_Barn Owl", "Branta leucopsis_Barnacle Goose", "Cygnus columbianus_Bewick's Swan", "Botaurus stellaris_Bittern (call)", "Chroicocephalus ridibundus_Black-headed Gull", "Podiceps nigricollis_Black-necked Grebe", "Limosa limosa_Black-tailed Godwit", "Turdus merula_Blackbird (flight call)", "Sylvia atricapilla_Blackcap (call)", "Fringilla montifringilla_Brambling", "Branta bernicla_Brent Goose", "Branta canadensis_Canada Goose", "Larus cachinnans_Caspian Gull", "Phylloscopus collybita_Chiffchaff (call)", "Loxia curvirostra_Common Crossbill", "Larus canus_Common Gull", "Acanthis flammea_Common Redpoll", "Actitis hypoleucos_Common Sandpiper", "Melanitta nigra_Common Scoter", "Sterna hirundo_Common Tern", "Fulica atra_Coot", "Emberize calandre_Corn Bunting (call)", "Crex crex_Corncrake", "Cuculus canorus_Cuckoo (call)", "Calidris ferruginea_Curlew Sandpiper", "Numenius arquata_Curlew", "Charadrius morinellus_Dotterel", "Calidris alpina_Dunlin", "Prunella modularis_Dunnock (call)", "Alopochen aegyptiaca_Egyptian Goose", "Turdus pilaris_Fieldfare (call)", "Mareca strepera_Gadwall", "Sylvia borin_Garden Warbler (call)", "Spatula querquedula_Garganey", "Regulus regulus_Goldcrest (call)", "Regulus ignicapilla_Firecrest (call)", "Pluvialis apricaria_Golden Plover", "Bucephala clangula_Goldeneye", "Mergus merganser_Goosander", "Locustella naevia_Grasshopper Warbler (call)", "Larus marinus_Great Black-backed Gull", "Podiceps cristatus_Great Crested Grebe", "Tringa ochropus_Green Sandpiper", "Tringa nebularia_Greenshank", "Ardea cinerea_Grey Heron", "Perdix perdix_Grey Partridge", "Phalaropus fulicarius_Grey", "Pluvialis squatarola_Grey Plover", "Motacilla cinerea_Grey Wagtail ", "Anser anser_Greylag Goose", "Delichon urbicum_House Martin", "Coccothraustes coccothraustes_Hawfinch (call)", "Larus argentatus_Herring Gull", "Lymnocryptes minimus_Jack Snipe", "Alcedo atthis_Kingfisher", "Calidris canutus_Knot", "Calcarius lapponicus_Lapland Bunting (call)", "Larus fuscus_Lesser Black-backed Gull", "Acanthis cabaret_Lesser Redpoll ", "Curraca curruca_Lesser Whitethroat (call)", "Linaria cannabina_Linnet", "Ixobrychus minutus_Little Bittern (call)", "Egretta garzetta_Little Egret", "Tachybaptus ruficollis_Little Grebe", "Hydrocoloeus minutus_Little Gull", "Athene noctua_Little Owl", "Charadrius dubius_Little Ringed Plover", "Calidris minuta_Little Stint ", "Sternula albifrons_Little Tern", "Asio otus_Long-eared Owl", "Clangula hyemalis_Long-tailed Duck", "Anas platyrhynchos_Mallard", "Aix galericulata_Mandarin Duck", "Anthus pratensis_Meadow Pipit (call)", "Ichthyaetus melanocephalus_Mediterranean Gull", "Turdus viscivorus_Mistle Thrush (call)", "Gallinula chloropus_Moorhen", "Nycticorax nycticorax_Night Heron", "Luscinia megarhynchos_Nightingale (call)", "Luscinia megarhynchos_Nightingale (song)", "Caprimulgus europaeus_Nightjar (call)", "Anthus hodgsoni_Olive-backed Pipit (call)", "Emberiza hortulana_Ortolan Bunting (call)", "Emberiza pusilla_Little Bunting (call)", "Haematopus ostralegus_Oystercatcher", "Ficedula hypoleuca_Pied Flycatcher (call)", "Motacilla alba_Pied Wagtail", "Anser brachyrhynchus_Pink-footed Goose", "Anas acuta_Pintail", "Aythya ferina_Pochard", "Calidris maritima_Purple Sandpiper", "Coturnix coturnix_Quail (call)", "Coturnix coturnix_Quail (song)", "Mergus serrator_Red-breasted Merganser", "Netta rufina_Red-crested Pochard", "Alectoris rufa_Red-legged Partridge", "Tringa totanus_Redshank", "Phoenicurus phoenicurus_Redstart (call)", "Turdus iliacus_Redwing (call)", "Emberiza schoeniclus_Reed Bunting (call)", "Acrocephalus scirpaceus_Reed Warbler (call)", "Anthus richardi_Richard's Pipit (call)", "Turdus torquatus_Ring Ouzel (call)", "Charadrius hiaticula_Ringed Plover", "Erithacus rubecula_Robin (flight call)", "Anthus petrosus_Rock Pipit", "Sterna dougallii_Roseate Tern", "Calidris pugnax_Ruff", "Riparia riparia_Sand Martin", "Calidris alba_Sanderling", "Thalasseus sandvicensis_Sandwich Tern", "Aythya marila_Scaup", "Loxia scotica_Scottish Crossbill", "Acrocephalus schoenobaenus_Sedge Warbler", "Tadorna tadorna_Shelduck", "Asio flammeus_Short-eared Owl", "Spatula clypeata_Shoveler", "Spinus spinus_Siskin", "Alauda arvensis_Skylark (call)", "Gallinago gallinago_Snipe", "Plectrophenax nivalis_Snow Bunting", "Turdus philomelos_Song Thrush (call)", "Porzana porzana_Spotted Crake", "Muscicapa striata_Spotted Flycatcher", "Tringa erythropus_Spotted Redshank (call)", "Burhinus oedicnemus_Stone-curlew", "Saxicola rubicola_Stonechat", "Hirundo rustica_Swallow", "Apus apus_Swift", "Anser fabalis_Taiga Bean Goose", "Strix aluco_Tawny Owl", "Anas crecca_Teal", "Anthus trivialis_Tree Pipit (call)", "Aythya fuligula_Tufted Duck", "Anser serrirostris_Tundra Bean Goose", "Arenaria interpres_Turnstone", "Anthus spinoletta_Water Pipit", "Rallus aquaticus_Water Rail", "Numenius phaeopus_Whimbrel", "Anser albifrons_White-fronted Goose", "Sylvia communis_Whitethroat (call)", "Cygnus cygnus_Whooper Swan", "Mareca penelope_Wigeon", "Phylloscopus trochilus_Willow Warbler (call)", "Tringa glareola_Wood Sandpiper", "Scolopax rusticola_Woodcock", "Lullula arborea_Woodlark (call)", "Larus michahellis_Yellow-legged Gull", "Motacilla flava_Yellow Wagtail", "Emberiza citrinella_Yellowhammer (call)"]); const CHIRPITY_NOT_BIRDS = ['Ambient Noise_Ambient Noise', 'Animal_Animal', 'Cat_Cat', 'Church Bells_Church Bells', 'Cough_Cough', 'Dog_Dog', 'Human_Human', 'Laugh_Laugh', 'No call_No call', 'Rain_Rain', 'Red Fox_Red Fox', 'Sneeze_Sneeze', 'Snoring_Snoring', 'Thunder_Thunder', 'Vehicle_Vehicle', 'Water Drops_Water Drops', 'Waves_Waves', 'Wind_Wind']; const BIRDNET_NOT_BIRDS = [ - 'Dog_Dog', - 'Environmental_Environmental', - 'Engine_Engine', - 'Fireworks_Fireworks', - 'Gun_Gun', - 'Human non-vocal_Human non-vocal', - 'Human vocal_Human vocal', - 'Human whistle_Human whistle', - 'Miogryllus saussurei_Miogryllus saussurei', - 'Noise_Noise', - 'Power tools_Power tools', - 'Siren_Siren', - "Canis latrans_Coyote", - "Canis lupus_Gray Wolf", - "Gastrophryne carolinensis_Eastern Narrow-mouthed Toad", - "Gastrophryne olivacea_Great Plains Narrow-mouthed Toad", - "Incilius valliceps_Gulf Coast Toad", - "Allonemobius allardi_Allard's Ground Cricket", - "Allonemobius tinnulus_Tinkling Ground Cricket", - "Allonemobius walkeri_Walker's Ground Cricket", - "Anaxyrus americanus_American Toad", - "Anaxyrus canorus_Yosemite Toad", - "Anaxyrus cognatus_Great Plains Toad", - "Anaxyrus fowleri_Fowler's Toad", - "Anaxyrus houstonensis_Houston Toad", - "Anaxyrus microscaphus_Arizona Toad", - "Anaxyrus quercicus_Oak Toad", - "Anaxyrus speciosus_Texas Toad", - "Anaxyrus terrestris_Southern Toad", - "Anaxyrus woodhousii_Woodhouse's Toad", - "Atlanticus testaceus_Protean Shieldback", - "Conocephalus brevipennis_Short-winged Meadow Katydid", - "Conocephalus fasciatus_Slender Meadow Katydid", - "Orchelimum agile_Agile Meadow Katydid", - "Orchelimum concinnum_Stripe-faced Meadow Katydid", - "Orchelimum pulchellum_Handsome Meadow Katydid", - "Pterophylla camellifolia_Common True Katydid", - "Scudderia curvicauda_Curve-tailed Bush Katydid", - "Scudderia furcata_Fork-tailed Bush Katydid", - "Scudderia texensis_Texas Bush Katydid", - "Microcentrum rhombifolium_Greater Angle-wing", - "Dryophytes andersonii_Pine Barrens Treefrog", - "Dryophytes arenicolor_Canyon Treefrog", - "Dryophytes avivoca_Bird-voiced Treefrog", - "Dryophytes chrysoscelis_Cope's Gray Treefrog", - "Dryophytes cinereus_Green Treefrog", - "Dryophytes femoralis_Pine Woods Treefrog", - "Dryophytes gratiosus_Barking Treefrog", - "Dryophytes squirellus_Squirrel Treefrog", - "Dryophytes versicolor_Gray Treefrog", - "Eleutherodactylus planirostris_Greenhouse Frog", - "Hyliola regilla_Pacific Chorus Frog", - "Lithobates catesbeianus_American Bullfrog", - "Lithobates clamitans_Green Frog", - "Lithobates palustris_Pickerel Frog", - "Lithobates sylvaticus_Wood Frog", - "Pseudacris brimleyi_Brimley's Chorus Frog", - "Pseudacris clarkii_Spotted Chorus Frog", - "Pseudacris crucifer_Spring Peeper", - "Pseudacris feriarum_Upland Chorus Frog", - "Pseudacris nigrita_Southern Chorus Frog", - "Pseudacris ocularis_Little Grass Frog", - "Pseudacris ornata_Ornate Chorus Frog", - "Pseudacris streckeri_Strecker's Chorus Frog", - "Pseudacris triseriata_Striped Chorus Frog", - "Acris crepitans_Northern Cricket Frog", - "Acris gryllus_Southern Cricket Frog", - "Eunemobius carolinus_Carolina Ground Cricket", - "Eunemobius confusus_Confused Ground Cricket", - "Gryllus assimilis_Gryllus assimilis", - "Gryllus fultoni_Southern Wood Cricket", - "Gryllus pennsylvanicus_Fall Field Cricket", - "Gryllus rubens_Southeastern Field Cricket", - "Neonemobius cubensis_Cuban Ground Cricket", - "Oecanthus celerinictus_Fast-calling Tree Cricket", - "Oecanthus exclamationis_Davis's Tree Cricket", - "Oecanthus fultoni_Snowy Tree Cricket", - "Oecanthus nigricornis_Blackhorned Tree Cricket", - "Oecanthus niveus_Narrow-winged Tree Cricket", - "Oecanthus pini_Pine Tree Cricket", - "Oecanthus quadripunctatus_Four-spotted Tree Cricket", - "Orocharis saltator_Jumping Bush Cricket", - "Alouatta pigra_Mexican Black Howler Monkey", - "Tamias striatus_Eastern Chipmunk", - "Sciurus carolinensis_Eastern Gray Squirrel", - "Tamiasciurus hudsonicus_Red Squirrel"]; +"Acris crepitans_Northern Cricket Frog", +"Acris gryllus_Southern Cricket Frog", +"Allonemobius allardi_Allard's Ground Cricket", +"Allonemobius tinnulus_Tinkling Ground Cricket", +"Allonemobius walkeri_Walker's Ground Cricket", +"Alouatta pigra_Mexican Black Howler Monkey", +"Amblycorypha alexanderi_Clicker Round-winged Katydid", +"Amblycorypha longinicta_Common Virtuoso Katydid", +"Amblycorypha oblongifolia_Oblong-winged Katydid", +"Amblycorypha rotundifolia_Rattler Round-winged Katydid", +"Anaxipha exigua_Say's Trig", +"Anaxyrus americanus_American Toad", +"Anaxyrus canorus_Yosemite Toad", +"Anaxyrus cognatus_Great Plains Toad", +"Anaxyrus fowleri_Fowler's Toad", +"Anaxyrus houstonensis_Houston Toad", +"Anaxyrus microscaphus_Arizona Toad", +"Anaxyrus quercicus_Oak Toad", +"Anaxyrus speciosus_Texas Toad", +"Anaxyrus terrestris_Southern Toad", +"Anaxyrus woodhousii_Woodhouse's Toad", +"Apis mellifera_Honey Bee", +"Atlanticus testaceus_Protean Shieldback", +"Canis latrans_Coyote", +"Canis lupus_Gray Wolf", +"Conocephalus brevipennis_Short-winged Meadow Katydid", +"Conocephalus fasciatus_Slender Meadow Katydid", +"Cyrtoxipha columbiana_Columbian Trig", +"Dryophytes andersonii_Pine Barrens Treefrog", +"Dryophytes arenicolor_Canyon Treefrog", +"Dryophytes avivoca_Bird-voiced Treefrog", +"Dryophytes chrysoscelis_Cope's Gray Treefrog", +"Dryophytes cinereus_Green Treefrog", +"Dryophytes femoralis_Pine Woods Treefrog", +"Dryophytes gratiosus_Barking Treefrog", +"Dryophytes squirellus_Squirrel Treefrog", +"Dryophytes versicolor_Gray Treefrog", +"Eleutherodactylus planirostris_Greenhouse Frog", +"Eunemobius carolinus_Carolina Ground Cricket", +"Eunemobius confusus_Confused Ground Cricket", +"Gastrophryne carolinensis_Eastern Narrow-mouthed Toad", +"Gastrophryne olivacea_Great Plains Narrow-mouthed Toad", +"Gryllus assimilis_Gryllus assimilis", +"Gryllus fultoni_Southern Wood Cricket", +"Gryllus pennsylvanicus_Fall Field Cricket", +"Gryllus rubens_Southeastern Field Cricket", +"Hyliola regilla_Pacific Chorus Frog", +"Incilius valliceps_Gulf Coast Toad", +"Lithobates catesbeianus_American Bullfrog", +"Lithobates clamitans_Green Frog", +"Lithobates palustris_Pickerel Frog", +"Lithobates sylvaticus_Wood Frog", +"Microcentrum rhombifolium_Greater Angle-wing", +"Miogryllus saussurei_Miogryllus saussurei", +"Neoconocephalus bivocatus_False Robust Conehead", +"Neoconocephalus ensiger_Sword-bearing Conehead", +"Neoconocephalus retusus_Round-tipped Conehead", +"Neoconocephalus robustus_Robust Conehead", +"Neonemobius cubensis_Cuban Ground Cricket", +"Odocoileus virginianus_White-tailed Deer", +"Oecanthus celerinictus_Fast-calling Tree Cricket", +"Oecanthus exclamationis_Davis's Tree Cricket", +"Oecanthus fultoni_Snowy Tree Cricket", +"Oecanthus nigricornis_Blackhorned Tree Cricket", +"Oecanthus niveus_Narrow-winged Tree Cricket", +"Oecanthus pini_Pine Tree Cricket", +"Oecanthus quadripunctatus_Four-spotted Tree Cricket", +"Orchelimum agile_Agile Meadow Katydid", +"Orchelimum concinnum_Stripe-faced Meadow Katydid", +"Orchelimum pulchellum_Handsome Meadow Katydid", +"Orocharis saltator_Jumping Bush Cricket", +"Phyllopalpus pulchellus_Handsome Trig", +"Pseudacris brimleyi_Brimley's Chorus Frog", +"Pseudacris clarkii_Spotted Chorus Frog", +"Pseudacris crucifer_Spring Peeper", +"Pseudacris feriarum_Upland Chorus Frog", +"Pseudacris nigrita_Southern Chorus Frog", +"Pseudacris ocularis_Little Grass Frog", +"Pseudacris ornata_Ornate Chorus Frog", +"Pseudacris streckeri_Strecker's Chorus Frog", +"Pseudacris triseriata_Striped Chorus Frog", +"Pterophylla camellifolia_Common True Katydid", +"Scaphiopus couchii_Couch's Spadefoot", +"Sciurus carolinensis_Eastern Gray Squirrel", +"Scudderia curvicauda_Curve-tailed Bush Katydid", +"Scudderia furcata_Fork-tailed Bush Katydid", +"Scudderia texensis_Texas Bush Katydid", +"Spea bombifrons_Plains Spadefoot", +"Tamias striatus_Eastern Chipmunk", +"Tamiasciurus hudsonicus_Red Squirrel", +"Human vocal_Human vocal", +"Human non-vocal_Human non-vocal", +"Human whistle_Human whistle", +"Dog_Dog", +"Power tools_Power tools", +"Siren_Siren", +"Engine_Engine", +"Gun_Gun", +"Fireworks_Fireworks", +"Environmental_Environmental", +"Noise_Noise" +]; const MYSTERIES = ['Unknown Sp._Unknown Sp.']; diff --git a/js/ui.js b/js/ui.js index 77824ed6..83f1620a 100644 --- a/js/ui.js +++ b/js/ui.js @@ -1389,6 +1389,7 @@ window.onload = async () => { webgl: { threads: 2, batchSize: 32 }, audio: { gain: 0, format: 'mp3', bitrate: 192, quality: 5, downmix: false, padding: false, fade: false }, limit: 500, + track: true, debug: false }; // Load preferences and override defaults @@ -2192,26 +2193,7 @@ function onChartData(args) { updateElementCache(); } - - // const locale = document.getElementById('locale') - // locale.addEventListener('change', async ()=> { - // config[config.model].locale = locale.value; - // updatePrefs(); - // const chirpity = config[config.model].locale === 'en_uk' && config.model !== 'birdnet' ? 'chirpity' : ''; - // const labelFile = `labels/V2.4/BirdNET_GLOBAL_6K_V2.4_${chirpity}Labels_${config[config.model].locale}.txt`; - // fetch(labelFile).then(response => { - // if (! response.ok) throw new Error('Network response was not ok'); - // return response.text(); - // }).then(filecontents => { - // LABELS = filecontents.trim().split(/\r?\n/); - // // Add unknown species - // LABELS.push('Unknown Sp._Unknown Sp.'); - // worker.postMessage({action: 'update-locale', locale: config[config.model].locale, labels: LABELS}) - // }).catch(error =>{ - // console.error('There was a problem fetching the label file:', error); - // }) - // }) - + // list mode icons const listIcon = document.getElementById('list-icon') const speciesThresholdEl = document.getElementById('species-threshold-el'); @@ -2267,10 +2249,11 @@ function onChartData(args) { backend: config.backend, clearCache: clearCache }); + } - const handleBackendChange = (e) => { - config.backend = e.target.value; + const handleBackendChange = (backend) => { + config.backend = backend instanceof Event ? backend.target.value : backend; if (config.backend === 'webgl') { //powerSave(true) SNRSlider.disabled = true; @@ -2849,7 +2832,11 @@ function onChartData(args) { t1_analysis = Date.now(); const analysisTime = ((t1_analysis - t0_analysis) / 1000).toFixed(2); DIAGNOSTICS['Analysis Duration'] = analysisTime + ' seconds'; - DIAGNOSTICS['Analysis Rate'] = (DIAGNOSTICS['Audio Duration'] / analysisTime).toFixed(0) + 'x faster than real time performance.'; + const rate = (DIAGNOSTICS['Audio Duration'] / analysisTime); + DIAGNOSTICS['Analysis Rate'] = rate.toFixed(0) + 'x faster than real time performance.'; + track(`${config.model}-${config.backend}`, 'Audio Duration', config.backend, Math.round(DIAGNOSTICS['Audio Duration'])); + track(`${config.model}-${config.backend}`, 'Analysis Duration', config.backend, parseInt(analysisTime)); + track(`${config.model}-${config.backend}`, 'Analysis Rate', config.backend, parseInt(rate)); } /* @@ -3614,6 +3601,7 @@ function onChartData(args) { filelist.push(f.path); } if (filelist.length) filterValidFiles({ filePaths: filelist }) + track('UI', 'Drop', 'Open Folder(s)', filelist.length); }); @@ -4066,14 +4054,8 @@ DOM.gain.addEventListener('input', () => { const target = e.target.closest('[id]').id; contextMenu.classList.add("d-none"); hideConfidenceSlider(); - console.log('clicked', target); - - fetch(`https://analytics.mattkirkland.co.uk/matomo.php?action_name=Settings%20Change&idsite=2&rand=${Date.now()}&rec=1&uid=${config.UUID}&apiv=1 - &e_c=Click&e_a=${target}`) - .then(response => { - if (! response.ok) throw new Error('Network response was not ok', response); - }) - .catch(error => console.log('Error posting click tracking:', error)) + config.debug && console.log('clicked', target); + track('UI', 'Click', target); }) @@ -4118,6 +4100,10 @@ DOM.gain.addEventListener('input', () => { handleAttenuationchange(e); break; } + case 'do-not-track': { + config.track = !element.checked; + break; + } case 'lowShelfFrequency': { handleLowShelfchange(e); break; @@ -4190,15 +4176,18 @@ DOM.gain.addEventListener('input', () => { config.detect.contextAware = false; SNRSlider.disabled = true; config.filters.SNR = 0; + } else { // show chirpity-only features chirpityOnly.forEach(element => element.classList.remove('d-none')); - document.getElementById('use-location-container').classList.add('d-none') + document.getElementById('use-location-container').classList.add('d-none'); DOM.contextAware.disabed = false; SNRSlider.disabled = false; } document.getElementById('locale').value = config[config.model].locale; - loadModel(); + config.backend = 'tensorflow'; + document.getElementById('tensorflow').checked = true; + handleBackendChange(config.backend); break; } case 'thread-slider': { @@ -4274,17 +4263,22 @@ DOM.gain.addEventListener('input', () => { }; } updatePrefs(); - - fetch(`https://analytics.mattkirkland.co.uk/matomo.php?action_name=Settings%20Change&idsite=2&rand=${Date.now()}&rec=1&uid=${config.UUID}&apiv=1 - &e_c=Change&e_a=${target}&e_n=${element.value}`) - .then(response => { - if (! response.ok) throw new Error('Network response was not ok', response); - }) - .catch(error => console.log('Error posting tracking:', error)) + track('Settings Change', target, element.value); } }) - +function track(event, action, name, value){ + name = name ? `&e_n=${name}` : ''; + value = value ? `&e_v=${value}` : ''; + if (config.track){ + fetch(`https://analytics.mattkirkland.co.uk/matomo.php?action_name=Settings%20Change&idsite=2&rand=${Date.now()}&rec=1&uid=${config.UUID}&apiv=1 + &e_c=${event}&e_a=${action}${name}${value}`) + .then(response => { + if (! response.ok) throw new Error('Network response was not ok', response); + }) + .catch(error => console.log('Error posting tracking:', error)) + } +} async function createContextMenu(e) { const target = e.target; diff --git a/js/worker.js b/js/worker.js index 908dafaf..baa7911d 100644 --- a/js/worker.js +++ b/js/worker.js @@ -2077,6 +2077,7 @@ const prepSummaryStatement = (included) => { if ( !aborted) { predictWorkers[response.worker].isAvailable = true; let worker = await parsePredictions(response); + DEBUG && console.log('predictions left for', response.file, predictionsReceived[response.file] - predictionsRequested[response.file]) if (predictionsReceived[response.file] === predictionsRequested[response.file]) { const limit = 10; clearCache(CACHE_LOCATION, limit);