diff --git a/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js b/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js index 395ad21fd..273660a56 100644 --- a/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js +++ b/src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js @@ -1,7 +1,15 @@ -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 +19,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 = {