From 55a5a78db20243344b08683abf652ddefadad305 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 26 Sep 2023 15:20:35 +0530 Subject: [PATCH 1/2] Track Site Features on Step Change --- src/OnboardingSPA/components/App/index.js | 16 ++++++++++++++++ .../pages/Steps/SiteFeatures/index.js | 10 ---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/OnboardingSPA/components/App/index.js b/src/OnboardingSPA/components/App/index.js index ae8342b6f..7ee57f7c5 100644 --- a/src/OnboardingSPA/components/App/index.js +++ b/src/OnboardingSPA/components/App/index.js @@ -26,6 +26,7 @@ import { } from '../../utils/analytics/hiive'; import { injectInAllSteps } from '../../data/routes/allStepsHandler'; import { + ACTION_FEATURE_ADDED, ACTION_LOGO_ADDED, ACTION_ONBOARDING_CHAPTER_COMPLETE, ACTION_ONBOARDING_CHAPTER_STARTED, @@ -270,6 +271,21 @@ const App = () => { } } + if ( previousStepPath.includes( 'site-features' ) ) { + const siteFeatures = currentData.data.siteFeatures; + for ( const siteFeature in siteFeatures ) { + if ( false !== siteFeatures[ siteFeature ] ) + trackOnboardingEvent( + new OnboardingEvent( + ACTION_FEATURE_ADDED, + siteFeature, + {}, + previousStepURL + ) + ); + } + } + window.nfdOnboarding.previousStep = { path: location.pathname, url: window.location.href, diff --git a/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js b/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js index 6ccf579d2..f02ad5628 100644 --- a/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js +++ b/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js @@ -12,11 +12,6 @@ import HeadingWithSubHeading from '../../../components/HeadingWithSubHeading'; import CheckboxList from '../../../components/CheckboxTemplate/CheckboxList'; import { CheckboxListSkeleton } from '../../../components/CheckboxTemplate'; import getContents from './contents'; -import { - OnboardingEvent, - trackOnboardingEvent, -} from '../../../utils/analytics/hiive'; -import { ACTION_FEATURE_ADDED } from '../../../utils/analytics/hiive/constants'; const StepSiteFeatures = () => { const isLargeViewport = useViewportMatch( 'medium' ); @@ -53,11 +48,6 @@ const StepSiteFeatures = () => { currentData.data.siteFeatures = { ...selectedPluginsCopy }; setCurrentOnboardingData( currentData ); - if ( true === choice ) { - trackOnboardingEvent( - new OnboardingEvent( ACTION_FEATURE_ADDED, slug ) - ); - } } async function changeToStoreSchema( customPlugins, saveToStore = false ) { From e2cf8898ea638959d1a56dff11d19b0ca8f0009a Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 26 Sep 2023 15:25:51 +0530 Subject: [PATCH 2/2] Lint Fixes --- src/OnboardingSPA/components/App/index.js | 3 ++- src/OnboardingSPA/pages/Steps/SiteFeatures/index.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OnboardingSPA/components/App/index.js b/src/OnboardingSPA/components/App/index.js index 7ee57f7c5..cf7b9b400 100644 --- a/src/OnboardingSPA/components/App/index.js +++ b/src/OnboardingSPA/components/App/index.js @@ -274,7 +274,7 @@ const App = () => { if ( previousStepPath.includes( 'site-features' ) ) { const siteFeatures = currentData.data.siteFeatures; for ( const siteFeature in siteFeatures ) { - if ( false !== siteFeatures[ siteFeature ] ) + if ( false !== siteFeatures[ siteFeature ] ) { trackOnboardingEvent( new OnboardingEvent( ACTION_FEATURE_ADDED, @@ -283,6 +283,7 @@ const App = () => { previousStepURL ) ); + } } } diff --git a/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js b/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js index f02ad5628..86ad44e9e 100644 --- a/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js +++ b/src/OnboardingSPA/pages/Steps/SiteFeatures/index.js @@ -67,9 +67,11 @@ const StepSiteFeatures = () => { async function getCustomPlugins() { const customPlugins = await getSiteFeatures(); - if ( isEmpty( currentData?.data?.siteFeatures ) ) + if ( isEmpty( currentData?.data?.siteFeatures ) ) { changeToStoreSchema( customPlugins.body, true ); - else setSelectedPlugins( { ...currentData?.data?.siteFeatures } ); + } else { + setSelectedPlugins( { ...currentData?.data?.siteFeatures } ); + } setCustomPluginsList( customPlugins.body ); }