Skip to content

Commit

Permalink
Add tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcaires committed May 10, 2024
1 parent 23e16f2 commit 2a620b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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` )
Expand Down Expand Up @@ -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 ) } )
);
} );
} );

0 comments on commit 2a620b6

Please sign in to comment.