From 7a7322ec081d68779c54bd10e2829193e05ed27e Mon Sep 17 00:00:00 2001 From: amir ali <129206554+amir-deriv@users.noreply.github.com> Date: Mon, 22 Jan 2024 11:03:59 +0500 Subject: [PATCH] chore: add growthbook toggle key (#13053) --- packages/core/build/constants.js | 1 + .../AccountSignupModal/account-signup-modal.jsx | 8 ++++---- packages/core/src/App/app.jsx | 12 ++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/core/build/constants.js b/packages/core/build/constants.js index 8be0e530c695..3fe363960efb 100644 --- a/packages/core/build/constants.js +++ b/packages/core/build/constants.js @@ -139,6 +139,7 @@ const plugins = ({ base, is_test_env }) => { 'process.env.RUDDERSTACK_KEY': JSON.stringify(process.env.RUDDERSTACK_KEY), 'process.env.GROWTHBOOK_CLIENT_KEY': JSON.stringify(process.env.GROWTHBOOK_CLIENT_KEY), 'process.env.GROWTHBOOK_DECRYPTION_KEY': JSON.stringify(process.env.GROWTHBOOK_DECRYPTION_KEY), + 'process.env.IS_GROWTHBOOK_ENABLED': JSON.stringify(process.env.IS_GROWTHBOOK_ENABLED), }), new CleanWebpackPlugin(), new CopyPlugin(copyConfig(base)), diff --git a/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx b/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx index ef84f9ae0bfd..cb809121dad2 100644 --- a/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx +++ b/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx @@ -65,18 +65,18 @@ const AccountSignup = ({ }); // need to modify data from ab testing platform to reach translation and tracking needs const fetchQuestionnarieData = () => { - let ab_value = Analytics.getFeatureValue('questionnaire-config', 'inactive'); + let ab_value = Analytics.getFeatureValue('questionnaire-config', 'inactive') || 'inactive'; const default_ab_value = ab_value; ab_value = ab_value?.[language] ?? ab_value?.EN ?? ab_value; if (ab_value?.show_answers_in_random_order) { ab_value = [ - { ...default_ab_value.default }, + { ...default_ab_value?.default }, { ...ab_value, - answers: shuffleArray(ab_value.answers), + answers: shuffleArray(ab_value?.answers), }, ]; - } else if (ab_value !== 'inactive') ab_value = [{ ...default_ab_value.default }, { ...ab_value }]; + } else if (ab_value !== 'inactive') ab_value = [{ ...default_ab_value?.default }, { ...ab_value }]; return ab_value; }; setABQuestionnaire(fetchQuestionnarieData()); diff --git a/packages/core/src/App/app.jsx b/packages/core/src/App/app.jsx index 5f2ab434fdf5..2b94b2a30336 100644 --- a/packages/core/src/App/app.jsx +++ b/packages/core/src/App/app.jsx @@ -49,11 +49,15 @@ const AppWithoutTranslation = ({ root_store }) => { initializeTranslations(); if (process.env.RUDDERSTACK_KEY) { - Analytics.initialise({ - growthbookKey: process.env.GROWTHBOOK_CLIENT_KEY, - growthbookDecryptionKey: process.env.GROWTHBOOK_DECRYPTION_KEY, + const config = { + growthbookKey: + process.env.IS_GROWTHBOOK_ENABLED === 'true' ? process.env.GROWTHBOOK_CLIENT_KEY : undefined, + growthbookDecryptionKey: + process.env.IS_GROWTHBOOK_ENABLED === 'true' ? process.env.GROWTHBOOK_DECRYPTION_KEY : undefined, rudderstackKey: process.env.RUDDERSTACK_KEY, - }); + }; + + Analytics.initialise(config); } // TODO: [translation-to-shared]: add translation implemnentation in shared