diff --git a/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/index.tsx b/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/index.tsx index d04f74f7e9376f..2f94e188c743ac 100644 --- a/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/index.tsx +++ b/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/index.tsx @@ -76,6 +76,13 @@ const SiteMigrationInstructions: Step = function () { } }, [ fromUrl, hasErrorGetMigrationKey ] ); + useEffect( () => { + if ( showSupportMessage ) { + recordTracksEvent( 'calypso_onboarding_site_migration_instructions_preparation_failed', { + error: setupError?.message, + } ); + } + } ); useEffect( () => { if ( isSetupCompleted ) { recordTracksEvent( 'calypso_site_migration_instructions_preparation_complete' ); diff --git a/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/test/index.tsx b/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/test/index.tsx index 5f36c8ae12f222..4191d36e31ad84 100644 --- a/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/test/index.tsx +++ b/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-instructions-i2/test/index.tsx @@ -6,11 +6,13 @@ import userEvent from '@testing-library/user-event'; import nock from 'nock'; import React from 'react'; import { useSite } from 'calypso/landing/stepper/hooks/use-site'; +import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; import SiteMigrationInstructions from '..'; import { StepProps } from '../../../types'; import { mockStepProps, renderStep } from '../../test/helpers'; jest.mock( 'calypso/landing/stepper/hooks/use-site' ); +jest.mock( 'calypso/lib/analytics/tracks' ); ( useSite as jest.Mock ).mockReturnValue( { ID: 123, @@ -36,6 +38,7 @@ describe( 'SiteMigrationInstructions i2', () => { beforeEach( () => { nock.cleanAll(); + ( recordTracksEvent as jest.Mock ).mockClear(); nock( 'https://public-api.wordpress.com' ) .get( `/wpcom/v2/sites/123/atomic-migration-status/migrate-guru-key` ) @@ -151,5 +154,9 @@ describe( 'SiteMigrationInstructions i2', () => { render(); expect( await getSupportMessage() ).toBeVisible(); + expect( recordTracksEvent ).toHaveBeenCalledWith( + 'calypso_onboarding_site_migration_instructions_preparation_failed', + expect.objectContaining( { error: expect.any( String ) } ) + ); } ); } );