From 3b9183138403e498c2dc59997cd85191fd25dd5a Mon Sep 17 00:00:00 2001 From: Nuzhy-Deriv Date: Tue, 24 Dec 2024 13:02:44 +0800 Subject: [PATCH 1/3] fix: localstorage trackjs issue --- src/js/footer/helper/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/footer/helper/index.js b/src/js/footer/helper/index.js index 457db5b..0cfe3e2 100644 --- a/src/js/footer/helper/index.js +++ b/src/js/footer/helper/index.js @@ -172,7 +172,7 @@ const getDomainAppID = () => { }; export const getServerUrl = () => { - if (!!window?.localStorage) { + if (typeof window.localStorage !== "undefined" && window.localStorage) { return localStorage.getItem("config.server_url") || DEFAULT_SERVER_URL; } else { return DEFAULT_SERVER_URL; From 992d1d2034deb11d788f136a9348706ae668caa6 Mon Sep 17 00:00:00 2001 From: Nuzhy-Deriv Date: Tue, 24 Dec 2024 15:45:20 +0800 Subject: [PATCH 2/3] fix: update to use try catch --- src/js/footer/helper/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/footer/helper/index.js b/src/js/footer/helper/index.js index 0cfe3e2..5677a43 100644 --- a/src/js/footer/helper/index.js +++ b/src/js/footer/helper/index.js @@ -172,9 +172,9 @@ const getDomainAppID = () => { }; export const getServerUrl = () => { - if (typeof window.localStorage !== "undefined" && window.localStorage) { + try { return localStorage.getItem("config.server_url") || DEFAULT_SERVER_URL; - } else { + } catch { return DEFAULT_SERVER_URL; } }; From 211beacc4448e0ee87518440803aecfcb4330356 Mon Sep 17 00:00:00 2001 From: Nuzhy-Deriv Date: Tue, 24 Dec 2024 15:50:10 +0800 Subject: [PATCH 3/3] fix: added console warn --- src/js/footer/helper/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/footer/helper/index.js b/src/js/footer/helper/index.js index 5677a43..6b059fb 100644 --- a/src/js/footer/helper/index.js +++ b/src/js/footer/helper/index.js @@ -174,7 +174,8 @@ const getDomainAppID = () => { export const getServerUrl = () => { try { return localStorage.getItem("config.server_url") || DEFAULT_SERVER_URL; - } catch { + } catch (error) { + console.warn("Warning: Error accessing localStorage:", error); return DEFAULT_SERVER_URL; } };