From 1219f461b648ce2f1274caa88c564fa776fccb86 Mon Sep 17 00:00:00 2001 From: chrisj-er <“chrisj@earthranger.com”> Date: Wed, 26 Feb 2025 15:54:26 -0800 Subject: [PATCH 1/8] ERA-11250 Swap in new cookie manager by Osana feat: Osana cookie manager --- public/index.html | 16 +++++++--------- src/UserMenu/index.js | 2 +- src/index.js | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/public/index.html b/public/index.html index dcb2a4524..1244fe2e8 100644 --- a/public/index.html +++ b/public/index.html @@ -44,15 +44,13 @@ --> - <% if (process.env.NODE_ENV==='production' ) { %> - - - - - + <% if (process.env.NODE_ENV==='development' ) { %> + + + + <% } %> diff --git a/src/UserMenu/index.js b/src/UserMenu/index.js index a73678cdd..cf2d1e8e6 100644 --- a/src/UserMenu/index.js +++ b/src/UserMenu/index.js @@ -53,7 +53,7 @@ const UserMenu = ({ onLogOutClick, onProfileClick, selectedUserProfile, user, us } - cookieSettingsRef.current.click()}>{t('cookieSettingsItem')} + window.Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')}>{t('cookieSettingsItem')} {t('logoutItem')} diff --git a/src/index.js b/src/index.js index 3208f5dfe..f413f036f 100644 --- a/src/index.js +++ b/src/index.js @@ -62,9 +62,9 @@ const RootApp = () => { const { i18n } = useTranslation(); useEffect(() => { - if (window?.OneTrust) { + if (window?.Osana) { document.documentElement.lang = i18n.language; - window.OneTrust.changeLanguage(i18n.language); + window.Osana.setLanguage(i18n.language); } }, [i18n.language]); From d2880b2968389cad57483f5220852dcc3b53c16b Mon Sep 17 00:00:00 2001 From: chrisj-er <“chrisj@earthranger.com”> Date: Wed, 26 Feb 2025 16:09:38 -0800 Subject: [PATCH 2/8] enable in production --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 1244fe2e8..85c54dfd2 100644 --- a/public/index.html +++ b/public/index.html @@ -44,7 +44,7 @@ --> - <% if (process.env.NODE_ENV==='development' ) { %> + <% if (process.env.NODE_ENV==='production' ) { %> - + <% } %> diff --git a/src/index.js b/src/index.js index ae791c4a1..12beafe7a 100644 --- a/src/index.js +++ b/src/index.js @@ -62,9 +62,9 @@ const RootApp = () => { const { i18n } = useTranslation(); useEffect(() => { - if (typeof window !== 'undefined' && window.Osana) { + if (typeof window !== 'undefined' && window.Osano) { document.documentElement.lang = i18n.language; - window.Osana.setLanguage(i18n.language); + window.Osano.setLanguage(i18n.language); } }, [i18n.language]); From f0186759910e890009e35155a07a6ba38b82936f Mon Sep 17 00:00:00 2001 From: chrisj-er <“chrisj@earthranger.com”> Date: Thu, 27 Feb 2025 21:00:30 -0800 Subject: [PATCH 5/8] optionally hide cookie settings menu item if Osano not fully initialized. --- src/UserMenu/index.js | 6 +++++- src/index.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/UserMenu/index.js b/src/UserMenu/index.js index cf2d1e8e6..c6849dac9 100644 --- a/src/UserMenu/index.js +++ b/src/UserMenu/index.js @@ -53,7 +53,11 @@ const UserMenu = ({ onLogOutClick, onProfileClick, selectedUserProfile, user, us } - window.Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')}>{t('cookieSettingsItem')} + {window.Osano?.cm && ( + window.Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')}> + {t('cookieSettingsItem')} + + )} {t('logoutItem')} diff --git a/src/index.js b/src/index.js index 12beafe7a..c7b1b4895 100644 --- a/src/index.js +++ b/src/index.js @@ -64,7 +64,7 @@ const RootApp = () => { useEffect(() => { if (typeof window !== 'undefined' && window.Osano) { document.documentElement.lang = i18n.language; - window.Osano.setLanguage(i18n.language); + window.Osano('locale', i18n.language); } }, [i18n.language]); From c52d83546cda62427e413ca26cc86c634984d15b Mon Sep 17 00:00:00 2001 From: chrisj-er <“chrisj@earthranger.com”> Date: Fri, 28 Feb 2025 06:17:51 -0800 Subject: [PATCH 6/8] fix: handle osano throwing an error of Language unavailable --- src/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index c7b1b4895..383e7da85 100644 --- a/src/index.js +++ b/src/index.js @@ -64,7 +64,15 @@ const RootApp = () => { useEffect(() => { if (typeof window !== 'undefined' && window.Osano) { document.documentElement.lang = i18n.language; - window.Osano('locale', i18n.language); + try { + window.Osano('locale', i18n.language); + } catch (error) { + if (error.message === 'Language unavailable') { + window.Osano('locale', 'en'); + } else { + throw error; + } + } } }, [i18n.language]); From dbffc0930262d848057cd11ae86c041a7906c6f6 Mon Sep 17 00:00:00 2001 From: chrisj-er <“chrisj@earthranger.com”> Date: Fri, 28 Feb 2025 06:49:46 -0800 Subject: [PATCH 7/8] osano throwing promise rejection --- src/index.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index 383e7da85..ebf9b696d 100644 --- a/src/index.js +++ b/src/index.js @@ -62,18 +62,22 @@ const RootApp = () => { const { i18n } = useTranslation(); useEffect(() => { - if (typeof window !== 'undefined' && window.Osano) { - document.documentElement.lang = i18n.language; - try { - window.Osano('locale', i18n.language); - } catch (error) { - if (error.message === 'Language unavailable') { - window.Osano('locale', 'en'); - } else { - throw error; + const setLocale = async () => { + if (typeof window !== 'undefined' && window.Osano) { + document.documentElement.lang = i18n.language; + try { + await window.Osano('locale', i18n.language); + } catch (error) { + if (error.message === 'Language unavailable') { + await window.Osano('locale', 'en'); + } else { + console.error('Error setting Osano locale:', error); + } } } - } + }; + + setLocale(); }, [i18n.language]); return <> From 0ec8464b71b279ccb66b4537491715cd2f870baa Mon Sep 17 00:00:00 2001 From: chrisj-er <“chrisj@earthranger.com”> Date: Fri, 28 Feb 2025 15:01:12 -0800 Subject: [PATCH 8/8] one more fix for changing locale in Osano --- src/index.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/index.js b/src/index.js index ebf9b696d..cc5975590 100644 --- a/src/index.js +++ b/src/index.js @@ -62,22 +62,13 @@ const RootApp = () => { const { i18n } = useTranslation(); useEffect(() => { - const setLocale = async () => { - if (typeof window !== 'undefined' && window.Osano) { - document.documentElement.lang = i18n.language; - try { - await window.Osano('locale', i18n.language); - } catch (error) { - if (error.message === 'Language unavailable') { - await window.Osano('locale', 'en'); - } else { - console.error('Error setting Osano locale:', error); - } - } + if (typeof window !== 'undefined' && window.Osano) { + document.documentElement.lang = i18n.language; + window.Osano.cm.locale = i18n.language; + if (window.Osano.cm.locale !== i18n.language) { + window.Osano.cm.locale = 'en'; } - }; - - setLocale(); + } }, [i18n.language]); return <>