From 2ecd05b720ba2b3e7f093624647e1c071d31edaf Mon Sep 17 00:00:00 2001 From: frankknoll Date: Tue, 21 Mar 2023 11:20:03 +0100 Subject: [PATCH] refactoring --- docs/GoogleAnalytics.js | 20 ++++++++++++++++++++ docs/batchCodeTable.html | 1 + docs/batchCodeTable.js | 14 ++------------ 3 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 docs/GoogleAnalytics.js diff --git a/docs/GoogleAnalytics.js b/docs/GoogleAnalytics.js new file mode 100644 index 00000000000..f1ae6368add --- /dev/null +++ b/docs/GoogleAnalytics.js @@ -0,0 +1,20 @@ +class GoogleAnalytics { + + static click_batchcode(batchcode) { + gtag( + 'event', + 'click_batchcode', + { + 'batchcode': batchcode + }); + } + + static view_search_results(search_term) { + gtag( + 'event', + 'view_search_results', + { + 'search_term': search_term + }); + } +} diff --git a/docs/batchCodeTable.html b/docs/batchCodeTable.html index 4def163bfdf..1e5cb8aad10 100644 --- a/docs/batchCodeTable.html +++ b/docs/batchCodeTable.html @@ -31,6 +31,7 @@ + diff --git a/docs/batchCodeTable.js b/docs/batchCodeTable.js index 2525ddd9121..23b3882b395 100644 --- a/docs/batchCodeTable.js +++ b/docs/batchCodeTable.js @@ -155,12 +155,7 @@ class BatchCodeTableInitializer { tr.addClass('shown'); const batchcode = row.data()[thisClassInstance.#getColumnIndex('Batch')]; new HistogramView(uiContainer).displayHistogramView(thisClassInstance.#getCountry(), batchcode); - gtag( - 'event', - 'click_batchcode', - { - 'batchcode': batchcode - }); + GoogleAnalytics.click_batchcode(batchcode); } }); } @@ -171,12 +166,7 @@ class BatchCodeTableInitializer { .on( 'search.dt', function () { - gtag( - 'event', - 'view_search_results', - { - 'search_term': thisClassInstance.#batchCodeTable.search().toUpperCase() - }); + GoogleAnalytics.view_search_results(thisClassInstance.#batchCodeTable.search().toUpperCase()); }); } }