Update track name prefix for core profiler (#38710)

* Use coreprofiler_ prefix

* Add Changelog

* Track name changes

* Rename intro_optin to intro_opt_in

* Extracted out recordFailedPluginInstallations and recordSuccessfulPluginInstallation to tracks

* Fix js lint error -- remove unused import
This commit is contained in:
Moon 2023-06-15 13:37:14 -07:00 committed by GitHub
parent 723c68e240
commit d51f69d2d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 75 deletions

View File

@ -12,8 +12,15 @@ import {
UserProfileEvent, UserProfileEvent,
BusinessInfoEvent, BusinessInfoEvent,
PluginsLearnMoreLinkClicked, PluginsLearnMoreLinkClicked,
PluginsInstallationCompletedWithErrorsEvent,
PluginsInstallationCompletedEvent,
} from '..'; } from '..';
import { POSSIBLY_DEFAULT_STORE_NAMES } from '../pages/BusinessInfo'; import { POSSIBLY_DEFAULT_STORE_NAMES } from '../pages/BusinessInfo';
import {
InstalledPlugin,
PluginInstallError,
} from '../services/installAndActivatePlugins';
import { getPluginTrackKey, getTimeFrame } from '~/utils';
const recordTracksStepViewed = ( const recordTracksStepViewed = (
_context: unknown, _context: unknown,
@ -21,7 +28,7 @@ const recordTracksStepViewed = (
{ action }: { action: unknown } { action }: { action: unknown }
) => { ) => {
const { step } = action as { step: string }; const { step } = action as { step: string };
recordEvent( 'storeprofiler_step_view', { recordEvent( 'coreprofiler_step_view', {
step, step,
wc_version: getSetting( 'wcVersion' ), wc_version: getSetting( 'wcVersion' ),
} ); } );
@ -33,12 +40,12 @@ const recordTracksStepSkipped = (
{ action }: { action: unknown } { action }: { action: unknown }
) => { ) => {
const { step } = action as { step: string }; const { step } = action as { step: string };
recordEvent( `storeprofiler_${ step }_skip` ); recordEvent( `coreprofiler_${ step }_skip` );
}; };
const recordTracksIntroCompleted = () => { const recordTracksIntroCompleted = () => {
recordEvent( 'storeprofiler_step_complete', { recordEvent( 'coreprofiler_step_complete', {
step: 'store_details', step: 'intro_opt_in',
wc_version: getSetting( 'wcVersion' ), wc_version: getSetting( 'wcVersion' ),
} ); } );
}; };
@ -47,12 +54,12 @@ const recordTracksUserProfileCompleted = (
_context: CoreProfilerStateMachineContext, _context: CoreProfilerStateMachineContext,
event: Extract< UserProfileEvent, { type: 'USER_PROFILE_COMPLETED' } > event: Extract< UserProfileEvent, { type: 'USER_PROFILE_COMPLETED' } >
) => { ) => {
recordEvent( 'storeprofiler_step_complete', { recordEvent( 'coreprofiler_step_complete', {
step: 'user_profile', step: 'user_profile',
wc_version: getSetting( 'wcVersion' ), wc_version: getSetting( 'wcVersion' ),
} ); } );
recordEvent( 'storeprofiler_user_profile', { recordEvent( 'coreprofiler_user_profile', {
business_choice: event.payload.userProfile.businessChoice, business_choice: event.payload.userProfile.businessChoice,
selling_online_answer: event.payload.userProfile.sellingOnlineAnswer, selling_online_answer: event.payload.userProfile.sellingOnlineAnswer,
selling_platforms: event.payload.userProfile.sellingPlatforms selling_platforms: event.payload.userProfile.sellingPlatforms
@ -62,7 +69,7 @@ const recordTracksUserProfileCompleted = (
}; };
const recordTracksSkipBusinessLocationCompleted = () => { const recordTracksSkipBusinessLocationCompleted = () => {
recordEvent( 'storeprofiler_step_complete', { recordEvent( 'coreprofiler_step_complete', {
step: 'skip_business_location', step: 'skip_business_location',
wc_version: getSetting( 'wcVersion' ), wc_version: getSetting( 'wcVersion' ),
} ); } );
@ -72,12 +79,12 @@ const recordTracksBusinessInfoCompleted = (
_context: CoreProfilerStateMachineContext, _context: CoreProfilerStateMachineContext,
event: Extract< BusinessInfoEvent, { type: 'BUSINESS_INFO_COMPLETED' } > event: Extract< BusinessInfoEvent, { type: 'BUSINESS_INFO_COMPLETED' } >
) => { ) => {
recordEvent( 'storeprofiler_step_complete', { recordEvent( 'coreprofiler_step_complete', {
step: 'business_info', step: 'business_info',
wc_version: getSetting( 'wcVersion' ), wc_version: getSetting( 'wcVersion' ),
} ); } );
recordEvent( 'storeprofiler_business_info', { recordEvent( 'coreprofiler_business_info', {
business_name_filled: business_name_filled:
POSSIBLY_DEFAULT_STORE_NAMES.findIndex( POSSIBLY_DEFAULT_STORE_NAMES.findIndex(
( name ) => name === event.payload.storeName ( name ) => name === event.payload.storeName
@ -96,12 +103,57 @@ const recordTracksPluginsLearnMoreLinkClicked = (
{ action }: { action: unknown } { action }: { action: unknown }
) => { ) => {
const { step } = action as { step: string }; const { step } = action as { step: string };
recordEvent( `storeprofiler_${ step }_learn_more_link_clicked`, { recordEvent( `coreprofiler_${ step }_learn_more_link_clicked`, {
plugin: _event.payload.plugin, plugin: _event.payload.plugin,
link: _event.payload.learnMoreLink, link: _event.payload.learnMoreLink,
} ); } );
}; };
const recordFailedPluginInstallations = (
_context: unknown,
_event: PluginsInstallationCompletedWithErrorsEvent
) => {
recordEvent( 'coreprofiler_store_extensions_installed_and_activated', {
success: false,
failed_extensions: _event.payload.errors.map(
( error: PluginInstallError ) => getPluginTrackKey( error.plugin )
),
} );
};
const recordSuccessfulPluginInstallation = (
_context: unknown,
_event: PluginsInstallationCompletedEvent
) => {
const installationCompletedResult =
_event.payload.installationCompletedResult;
const trackData: {
success: boolean;
installed_extensions: string[];
total_time: string;
[ key: string ]: number | boolean | string | string[];
} = {
success: true,
installed_extensions: installationCompletedResult.installedPlugins.map(
( installedPlugin: InstalledPlugin ) =>
getPluginTrackKey( installedPlugin.plugin )
),
total_time: getTimeFrame( installationCompletedResult.totalTime ),
};
for ( const installedPlugin of installationCompletedResult.installedPlugins ) {
trackData[
'install_time_' + getPluginTrackKey( installedPlugin.plugin )
] = getTimeFrame( installedPlugin.installTime );
}
recordEvent(
'coreprofiler_store_extensions_installed_and_activated',
trackData
);
};
export default { export default {
recordTracksStepViewed, recordTracksStepViewed,
recordTracksStepSkipped, recordTracksStepSkipped,
@ -110,4 +162,6 @@ export default {
recordTracksSkipBusinessLocationCompleted, recordTracksSkipBusinessLocationCompleted,
recordTracksBusinessInfoCompleted, recordTracksBusinessInfoCompleted,
recordTracksPluginsLearnMoreLinkClicked, recordTracksPluginsLearnMoreLinkClicked,
recordFailedPluginInstallations,
recordSuccessfulPluginInstallation,
}; };

View File

@ -26,7 +26,6 @@ import {
Extension, Extension,
GeolocationResponse, GeolocationResponse,
} from '@woocommerce/data'; } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
import { initializeExPlat } from '@woocommerce/explat'; import { initializeExPlat } from '@woocommerce/explat';
import { CountryStateOption } from '@woocommerce/onboarding'; import { CountryStateOption } from '@woocommerce/onboarding';
@ -49,7 +48,7 @@ import { BusinessLocation } from './pages/BusinessLocation';
import { getCountryStateOptions } from './services/country'; import { getCountryStateOptions } from './services/country';
import { Loader } from './pages/Loader'; import { Loader } from './pages/Loader';
import { Plugins } from './pages/Plugins'; import { Plugins } from './pages/Plugins';
import { getPluginSlug, getPluginTrackKey, getTimeFrame } from '~/utils'; import { getPluginSlug } from '~/utils';
import './style.scss'; import './style.scss';
import { import {
InstallationCompletedResult, InstallationCompletedResult,
@ -693,7 +692,7 @@ export const coreProfilerStateMachineDefinition = createMachine( {
entry: [ entry: [
{ {
type: 'recordTracksStepViewed', type: 'recordTracksStepViewed',
step: 'store_details', step: 'intro_opt_in',
}, },
{ type: 'updateQueryStep', step: 'intro-opt-in' }, { type: 'updateQueryStep', step: 'intro-opt-in' },
], ],
@ -709,7 +708,7 @@ export const coreProfilerStateMachineDefinition = createMachine( {
actions: [ actions: [
{ {
type: 'recordTracksStepSkipped', type: 'recordTracksStepSkipped',
step: 'store_details', step: 'intro_opt_in',
}, },
], ],
}, },
@ -1222,73 +1221,16 @@ export const coreProfilerStateMachineDefinition = createMachine( {
event event
) => event.payload.errors, ) => event.payload.errors,
} ), } ),
( _context, event ) => { {
recordEvent( type: 'recordFailedPluginInstallations',
'storeprofiler_store_extensions_installed_and_activated',
{
success: false,
failed_extensions:
event.payload.errors.map(
(
error: PluginInstallError
) =>
getPluginTrackKey(
error.plugin
)
),
}
);
}, },
], ],
}, },
PLUGINS_INSTALLATION_COMPLETED: { PLUGINS_INSTALLATION_COMPLETED: {
target: 'postPluginInstallation', target: 'postPluginInstallation',
actions: [ actions: [
( _context, event ) => { {
const installationCompletedResult = type: 'recordSuccessfulPluginInstallation',
event.payload
.installationCompletedResult;
const trackData: {
success: boolean;
installed_extensions: string[];
total_time: string;
[ key: string ]:
| number
| boolean
| string
| string[];
} = {
success: true,
installed_extensions:
installationCompletedResult.installedPlugins.map(
(
installedPlugin: InstalledPlugin
) =>
getPluginTrackKey(
installedPlugin.plugin
)
),
total_time: getTimeFrame(
installationCompletedResult.totalTime
),
};
for ( const installedPlugin of installationCompletedResult.installedPlugins ) {
trackData[
'install_time_' +
getPluginTrackKey(
installedPlugin.plugin
)
] = getTimeFrame(
installedPlugin.installTime
);
}
recordEvent(
'storeprofiler_store_extensions_installed_and_activated',
trackData
);
}, },
], ],
}, },

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Use coreprofiler_ prefix for core profiler track names