Skip to content

Commit

Permalink
Merge pull request #526 from newfold-labs/add/error-event
Browse files Browse the repository at this point in the history
Sitegen: Report an event when the error state is triggered
  • Loading branch information
arunshenoy99 authored Mar 20, 2024
2 parents 442d210 + d658e1d commit 934795e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js
Original file line number Diff line number Diff line change
@@ -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 ) => {
Expand All @@ -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 <SiteGenSiteError />;
Expand Down
1 change: 1 addition & 0 deletions src/OnboardingSPA/utils/analytics/hiive/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 934795e

Please sign in to comment.