From ab5c205a7f5b228270cd5c8a8fea63fbe279da89 Mon Sep 17 00:00:00 2001 From: Awais Ansari Date: Tue, 15 Aug 2023 19:00:29 +0500 Subject: [PATCH] fix: moved feedback widget behind env variable --- .env | 1 + .env.development | 2 +- .env.test | 1 + src/hooks.js | 3 ++- src/index.jsx | 1 + src/notification-preferences/NotificationCourses.jsx | 2 ++ src/notification-preferences/NotificationPreferences.jsx | 2 -- 7 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 90fa5d9..e9fd025 100644 --- a/.env +++ b/.env @@ -31,3 +31,4 @@ MARKETING_EMAILS_OPT_IN='' APP_ID= MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='' +LEARNER_FEEDBACK_URL='' diff --git a/.env.development b/.env.development index b2cb20c..27d7a25 100644 --- a/.env.development +++ b/.env.development @@ -32,4 +32,4 @@ MARKETING_EMAILS_OPT_IN='' APP_ID= MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='mailto:support@example.com' - +LEARNER_FEEDBACK_URL='' diff --git a/.env.test b/.env.test index 7b20d23..7329bd4 100644 --- a/.env.test +++ b/.env.test @@ -30,3 +30,4 @@ ENABLE_DOB_UPDATE='' MARKETING_EMAILS_OPT_IN='' APP_ID= MFE_CONFIG_API_URL= +LEARNER_FEEDBACK_URL='' diff --git a/src/hooks.js b/src/hooks.js index 5731997..6d3feca 100644 --- a/src/hooks.js +++ b/src/hooks.js @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { getConfig } from '@edx/frontend-platform'; import { logError } from '@edx/frontend-platform/logging'; import { @@ -59,7 +60,7 @@ export function useFeedbackWrapper() { useEffect(() => { try { // eslint-disable-next-line no-undef - window.usabilla_live = lightningjs?.require('usabilla_live', '//w.usabilla.com/2655de034958.js'); + window.usabilla_live = lightningjs?.require('usabilla_live', getConfig().LEARNER_FEEDBACK_URL); } catch (error) { logError('Error loading usabilla_live', error); } diff --git a/src/index.jsx b/src/index.jsx index daf9e10..2a5a173 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -69,6 +69,7 @@ initialize({ ENABLE_DOB_UPDATE: (process.env.ENABLE_DOB_UPDATE || false), MARKETING_EMAILS_OPT_IN: (process.env.MARKETING_EMAILS_OPT_IN || false), PASSWORD_RESET_SUPPORT_LINK: process.env.PASSWORD_RESET_SUPPORT_LINK, + LEARNER_FEEDBACK_URL: process.env.LEARNER_FEEDBACK_URL, }, 'App loadConfig override handler'); }, }, diff --git a/src/notification-preferences/NotificationCourses.jsx b/src/notification-preferences/NotificationCourses.jsx index 6ab3018..ab60818 100644 --- a/src/notification-preferences/NotificationCourses.jsx +++ b/src/notification-preferences/NotificationCourses.jsx @@ -15,8 +15,10 @@ import { } from '../constants'; import { messages } from './messages'; import { NotFoundPage } from '../account-settings'; +import { useFeedbackWrapper } from '../hooks'; const NotificationCourses = ({ intl }) => { + useFeedbackWrapper(); const dispatch = useDispatch(); const coursesList = useSelector(selectCourseList()); const courseListStatus = useSelector(selectCourseListStatus()); diff --git a/src/notification-preferences/NotificationPreferences.jsx b/src/notification-preferences/NotificationPreferences.jsx index 990c50b..9eff7f2 100644 --- a/src/notification-preferences/NotificationPreferences.jsx +++ b/src/notification-preferences/NotificationPreferences.jsx @@ -22,10 +22,8 @@ import { SUCCESS_STATUS, } from '../constants'; import { NotFoundPage } from '../account-settings'; -import { useFeedbackWrapper } from '../hooks'; const NotificationPreferences = () => { - useFeedbackWrapper(); const { courseId } = useParams(); const dispatch = useDispatch(); const intl = useIntl();