From 469847174525441912715be4788bb319c46de90a Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 19 Mar 2024 22:50:02 +0530 Subject: [PATCH 1/2] Report an event when the error state is triggered --- .../StateHandlers/SitegenAi/index.js | 23 +++++++++++++++++-- .../utils/analytics/hiive/constants.js | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js b/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js index 395ad21fd..eac303daa 100644 --- a/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js +++ b/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js @@ -1,7 +1,12 @@ -import { Fragment } from '@wordpress/element'; -import SiteGenSiteError from '../../SiteGenError'; +import { Fragment, useEffect } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; + import { store as nfdOnboardingStore } from '../../../store'; +import { OnboardingEvent, trackOnboardingEvent } from '../../../utils/analytics/hiive'; +import { ACTION_SITEGEN_ERROR_STATE_TRIGGERED } from '../../../utils/analytics/hiive/constants'; +import { SITEGEN_FLOW } from '../../../data/flows/constants'; + +import SiteGenSiteError from '../../SiteGenError'; const SitegenAiStateHandler = ( { children } ) => { const { siteGenErrorStatus } = useSelect( ( select ) => { @@ -11,6 +16,20 @@ const SitegenAiStateHandler = ( { children } ) => { }; } ); + useEffect( () => { + if ( siteGenErrorStatus === true ) { + trackOnboardingEvent( + new OnboardingEvent( + ACTION_SITEGEN_ERROR_STATE_TRIGGERED, + undefined, + { + source: SITEGEN_FLOW, + } + ) + ); + } + }, [ siteGenErrorStatus ] ); + const handleRender = () => { if ( siteGenErrorStatus ) { return ; diff --git a/src/OnboardingSPA/utils/analytics/hiive/constants.js b/src/OnboardingSPA/utils/analytics/hiive/constants.js index 4c8ef4f0e..a6884950e 100644 --- a/src/OnboardingSPA/utils/analytics/hiive/constants.js +++ b/src/OnboardingSPA/utils/analytics/hiive/constants.js @@ -32,6 +32,7 @@ export const ACTION_SITEGEN_HOMEPAGE_FAVORITED = 'homepage_favorited'; export const ACTION_SITEGEN_HOMEPAGE_RENAMED = 'homepage_renamed'; export const ACTION_SITEGEN_SIDEBAR_OPENED = 'sidebar_opened'; export const ACTION_SITEGEN_SITE_GENERATION_TIME = 'site_generation_time'; +export const ACTION_SITEGEN_ERROR_STATE_TRIGGERED = 'error_state_triggered'; export const CATEGORY = 'wonder_start'; export const ACTION_TO_LABEL_KEY_MAP = { From d658e1dfc6ac9373f11b9c54b4f2fa31f85638a9 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 19 Mar 2024 22:55:43 +0530 Subject: [PATCH 2/2] Fix lint --- .../components/StateHandlers/SitegenAi/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js b/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js index eac303daa..273660a56 100644 --- a/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js +++ b/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js @@ -2,7 +2,10 @@ import { Fragment, useEffect } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { store as nfdOnboardingStore } from '../../../store'; -import { OnboardingEvent, trackOnboardingEvent } from '../../../utils/analytics/hiive'; +import { + OnboardingEvent, + trackOnboardingEvent, +} from '../../../utils/analytics/hiive'; import { ACTION_SITEGEN_ERROR_STATE_TRIGGERED } from '../../../utils/analytics/hiive/constants'; import { SITEGEN_FLOW } from '../../../data/flows/constants';