Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add identifiers when the error state is triggered #590

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import {
ACTION_ONBOARDING_CHAPTER_COMPLETE,
ACTION_ONBOARDING_CHAPTER_STARTED,
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
} from '../../../utils/analytics/hiive/constants';
import { SITEGEN_FLOW } from '../../../data/flows/constants';
import { stepTheFork } from '../../../steps/TheFork/step';
Expand Down Expand Up @@ -99,7 +100,7 @@
initializeThemes();
initializeSettings();
getEditedEntityRecord( 'root', 'site' );
}, [] );

Check warning on line 103 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'getEditedEntityRecord'. Either include it or remove the dependency array

Check warning on line 103 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'getEditedEntityRecord'. Either include it or remove the dependency array

useEffect( () => {
document.body.classList.add( `nfd-brand-${ newfoldBrand }` );
Expand All @@ -107,20 +108,20 @@

useEffect( () => {
trackChapters();
}, [ currentStep ] );

Check warning on line 111 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'trackChapters'. Either include it or remove the dependency array

Check warning on line 111 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'trackChapters'. Either include it or remove the dependency array

useEffect( () => {
if ( initialize ) {
initializePlugins( pluginInstallHash );
setInterval( cronTrigger, 45000 );
}
}, [ initialize ] );

Check warning on line 118 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'pluginInstallHash'. Either include it or remove the dependency array

Check warning on line 118 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'pluginInstallHash'. Either include it or remove the dependency array

useEffect( () => {
syncStoreToDB();
generateSiteGenData();
handlePreviousStepTracking();
}, [ location.pathname ] );

Check warning on line 124 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'generateSiteGenData', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array

Check warning on line 124 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'generateSiteGenData', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array

useEffect( () => {
if (
Expand All @@ -130,7 +131,7 @@
generateSiteGenData();
}
prevSiteGenErrorStatus.current = siteGenErrorStatus;
}, [ siteGenErrorStatus ] );

Check warning on line 134 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'generateSiteGenData'. Either include it or remove the dependency array

Check warning on line 134 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'generateSiteGenData'. Either include it or remove the dependency array

async function syncStoreToDB() {
// The First Fork Step doesn't have any Store changes
Expand Down Expand Up @@ -176,6 +177,16 @@
return prevState;
} );

trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
identifier,
{
source: SITEGEN_FLOW,
}
)
);

if ( siteGenErrorStatus === false ) {
updateSiteGenErrorStatus( true );
setIsGeneratingSiteMeta( false );
Expand Down Expand Up @@ -214,6 +225,15 @@
);

if ( response.error ) {
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
'homepages',
{
source: SITEGEN_FLOW,
}
)
);
updateSiteGenErrorStatus( true );
setIsGeneratingHomepages( false );
setCurrentOnboardingData( currentData );
Expand Down
22 changes: 1 addition & 21 deletions src/OnboardingSPA/components/StateHandlers/SiteGen/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// WordPress
import { Fragment, useEffect } from '@wordpress/element';
import { Fragment } from '@wordpress/element';
import { useSelect } from '@wordpress/data';

// Classes and functions
import {
OnboardingEvent,
trackOnboardingEvent,
} from '../../../utils/analytics/hiive';

// Components
import SiteGenStepErrorState from '../../ErrorState/Step/SiteGen';

// Misc
import { store as nfdOnboardingStore } from '../../../store';
import { ACTION_SITEGEN_ERROR_STATE_TRIGGERED } from '../../../utils/analytics/hiive/constants';
import { SITEGEN_FLOW } from '../../../data/flows/constants';

const SiteGenStateHandler = ( { children } ) => {
const { siteGenErrorStatus } = useSelect( ( select ) => {
Expand All @@ -25,20 +19,6 @@ const SiteGenStateHandler = ( { children } ) => {
};
} );

useEffect( () => {
if ( true === siteGenErrorStatus ) {
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
undefined,
{
source: SITEGEN_FLOW,
}
)
);
}
}, [ siteGenErrorStatus ] );

const handleRender = () => {
if ( siteGenErrorStatus ) {
return <SiteGenStepErrorState />;
Expand Down
30 changes: 29 additions & 1 deletion src/OnboardingSPA/steps/SiteGen/Migration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import {
OnboardingEvent,
sendOnboardingEvent,
trackOnboardingEvent,
} from '../../../utils/analytics/hiive';
import { SITEGEN_FLOW } from '../../../data/flows/constants';
import { ACTION_MIGRATION_INITIATED } from '../../../utils/analytics/hiive/constants';
import { ACTION_MIGRATION_INITIATED, ACTION_SITEGEN_ERROR_STATE_TRIGGERED } from '../../../utils/analytics/hiive/constants';

const StepSiteGenMigration = () => {
const {
Expand Down Expand Up @@ -66,14 +67,41 @@
window.open( migrateUrl, '_self' );
}, 3000 );
} else {
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
'migration',
{
source: SITEGEN_FLOW,
}
)
);
updateSiteGenErrorStatus( true );
}
} else {
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
'migration',
{
source: SITEGEN_FLOW,
}
)
);
updateSiteGenErrorStatus( true );
}
} catch ( error ) {
// eslint-disable-next-line no-console
console.error( 'Failed to fetch migration URL:', error );
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
'migration',
{
source: SITEGEN_FLOW,
}
)
);
updateSiteGenErrorStatus( true );
}
};
Expand All @@ -99,13 +127,13 @@
setHeaderActiveView( HEADER_SITEGEN );
setDrawerActiveView( false );
setFooterActiveView( FOOTER_SITEGEN );
}, [] );

Check warning on line 130 in src/OnboardingSPA/steps/SiteGen/Migration/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'allSteps', 'setDrawerActiveView', 'setFooterActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsHeaderEnabled', 'setIsHeaderNavigationEnabled', 'setSidebarActiveView', and 'updateAllSteps'. Either include them or remove the dependency array

Check warning on line 130 in src/OnboardingSPA/steps/SiteGen/Migration/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'allSteps', 'setDrawerActiveView', 'setFooterActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsHeaderEnabled', 'setIsHeaderNavigationEnabled', 'setSidebarActiveView', and 'updateAllSteps'. Either include them or remove the dependency array

useEffect( () => {
if ( siteGenErrorStatus === false ) {
loadData();
}
}, [ siteGenErrorStatus ] );

Check warning on line 136 in src/OnboardingSPA/steps/SiteGen/Migration/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadData'. Either include it or remove the dependency array

Check warning on line 136 in src/OnboardingSPA/steps/SiteGen/Migration/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadData'. Either include it or remove the dependency array

const content = getContents( currentBrandName );
return (
Expand Down
10 changes: 10 additions & 0 deletions src/OnboardingSPA/steps/SiteGen/Preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

// Misc
import {
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
ACTION_SITEGEN_HOMEPAGE_FAVORITED,
ACTION_SITEGEN_HOMEPAGE_REGENERATED,
ACTION_SITEGEN_HOMEPAGE_SELECTED,
Expand Down Expand Up @@ -79,7 +80,7 @@
setDrawerActiveView( false );
updateInitialize( true );
setIsHeaderNavigationEnabled( false );
}, [] );

Check warning on line 83 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'setDrawerActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsHeaderEnabled', 'setIsHeaderNavigationEnabled', 'setSidebarActiveView', and 'updateInitialize'. Either include them or remove the dependency array

Check warning on line 83 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'setDrawerActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsHeaderEnabled', 'setIsHeaderNavigationEnabled', 'setSidebarActiveView', and 'updateInitialize'. Either include them or remove the dependency array

useEffect( () => {
if (
Expand All @@ -91,7 +92,7 @@
setIsHeaderNavigationEnabled( false );
}
prevSiteGenErrorStatus.current = siteGenErrorStatus;
}, [ siteGenErrorStatus ] );

Check warning on line 95 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'loadHomepages' and 'setIsHeaderNavigationEnabled'. Either include them or remove the dependency array

Check warning on line 95 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'loadHomepages' and 'setIsHeaderNavigationEnabled'. Either include them or remove the dependency array

const loadHomepages = async () => {
setIsPreviewLoading( true );
Expand All @@ -112,6 +113,15 @@

if ( response.error ) {
setIsPreviewLoading( false );
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
'homepages',
{
source: SITEGEN_FLOW,
}
)
);
updateSiteGenErrorStatus( true );
return;
}
Expand Down Expand Up @@ -152,7 +162,7 @@
loadHomepages();
loadGlobalStyles();
}
}, [ themeStatus ] );

Check warning on line 165 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadHomepages'. Either include it or remove the dependency array

Check warning on line 165 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadHomepages'. Either include it or remove the dependency array

const handlePreview = ( slug, position ) => {
if ( ! ( slug in homepages ) ) {
Expand Down
10 changes: 10 additions & 0 deletions src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { store as nfdOnboardingStore } from '../../../store';
import { HEADER_SITEGEN } from '../../../../constants';
import {
ACTION_LOGO_ADDED,
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
ACTION_SITEGEN_LOGO_SKIPPED,
} from '../../../utils/analytics/hiive/constants';
import { SITEGEN_FLOW } from '../../../data/flows/constants';
Expand Down Expand Up @@ -105,6 +106,15 @@ const SiteGenSiteLogo = () => {
};

const handleFailure = () => {
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
'site-logo',
{
source: SITEGEN_FLOW,
}
)
);
updateSiteGenErrorStatus( true );
};

Expand Down
10 changes: 10 additions & 0 deletions src/OnboardingSPA/steps/SiteGen/SocialMedia/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { SiteGenStateHandler } from '../../../components/StateHandlers';
import { store as nfdOnboardingStore } from '../../../store';
import { HEADER_SITEGEN } from '../../../../constants';
import {
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
ACTION_SITEGEN_SOCIAL_CONNECTED,
ACTION_SITEGEN_SOCIAL_CONNECT_SKIPPED,
} from '../../../utils/analytics/hiive/constants';
Expand Down Expand Up @@ -83,6 +84,15 @@ const SiteGenSiteSocialMedia = () => {
if ( 404 === error?.data?.status ) {
return;
}
trackOnboardingEvent(
new OnboardingEvent(
ACTION_SITEGEN_ERROR_STATE_TRIGGERED,
'social-media',
{
source: SITEGEN_FLOW,
}
)
);
updateSiteGenErrorStatus( true );
};

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 @@ -66,4 +66,5 @@ export const ACTION_TO_LABEL_KEY_MAP = {
[ ACTION_SITEGEN_HOMEPAGE_RENAMED ]: 'version',
[ ACTION_SITEGEN_SITE_GENERATION_TIME ]: 'time',
[ ACTION_MIGRATION_INITIATED ]: 'path',
[ ACTION_SITEGEN_ERROR_STATE_TRIGGERED ]: 'identifier',
};
Loading