From 5b735aaf103673ea6e1f6ec7e05ddbece7ac4973 Mon Sep 17 00:00:00 2001 From: thomasrosen Date: Fri, 17 Sep 2021 19:03:44 +0200 Subject: [PATCH] BUGFIX wrapped usage of window.umami in a check --- src/App.js | 10 ++++++---- src/index.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/App.js b/src/App.js index 4ed5a91..6a82da0 100644 --- a/src/App.js +++ b/src/App.js @@ -71,7 +71,7 @@ function trigger_download(name, data){ function UmamiLink({ href, name, target, children, ...props }) { const handleClick = useCallback(event => { - if (name) { + if (window.umami && name) { window.umami.trackEvent('A: ' + name) // Log Anker / Link } @@ -291,9 +291,11 @@ function App({ getString, locales, currentLocale, onLanguageChange }) { const frameName = frame.name || 'No-Frame' const hashtagName = hashtag.name || 'No-Hashtag' - window.umami.trackEvent('F: ' + frameName) // Log Frame - window.umami.trackEvent('H: ' + hashtagName) // Log Hashtag - window.umami.trackEvent('C: ' + [frameName, hashtagName].join(' | ')) // Log Combined + if (window.umami) { + window.umami.trackEvent('F: ' + frameName) // Log Frame + window.umami.trackEvent('H: ' + hashtagName) // Log Hashtag + window.umami.trackEvent('C: ' + [frameName, hashtagName].join(' | ')) // Log Combined + } }) } diff --git a/src/index.js b/src/index.js index fa4c933..5823f01 100644 --- a/src/index.js +++ b/src/index.js @@ -12,7 +12,7 @@ function AppLanguageWrapper() { useEffect(() => { let systemLocales = navigator.languages - if (!!systemLocales || Array.isArray(systemLocales)) { + if (window.umami && (!!systemLocales || Array.isArray(systemLocales))) { for (const locale of systemLocales) { window.umami.trackEvent('L: ' + locale) // Log Locale / Languages }