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:
parent
723c68e240
commit
d51f69d2d7
|
@ -12,8 +12,15 @@ import {
|
|||
UserProfileEvent,
|
||||
BusinessInfoEvent,
|
||||
PluginsLearnMoreLinkClicked,
|
||||
PluginsInstallationCompletedWithErrorsEvent,
|
||||
PluginsInstallationCompletedEvent,
|
||||
} from '..';
|
||||
import { POSSIBLY_DEFAULT_STORE_NAMES } from '../pages/BusinessInfo';
|
||||
import {
|
||||
InstalledPlugin,
|
||||
PluginInstallError,
|
||||
} from '../services/installAndActivatePlugins';
|
||||
import { getPluginTrackKey, getTimeFrame } from '~/utils';
|
||||
|
||||
const recordTracksStepViewed = (
|
||||
_context: unknown,
|
||||
|
@ -21,7 +28,7 @@ const recordTracksStepViewed = (
|
|||
{ action }: { action: unknown }
|
||||
) => {
|
||||
const { step } = action as { step: string };
|
||||
recordEvent( 'storeprofiler_step_view', {
|
||||
recordEvent( 'coreprofiler_step_view', {
|
||||
step,
|
||||
wc_version: getSetting( 'wcVersion' ),
|
||||
} );
|
||||
|
@ -33,12 +40,12 @@ const recordTracksStepSkipped = (
|
|||
{ action }: { action: unknown }
|
||||
) => {
|
||||
const { step } = action as { step: string };
|
||||
recordEvent( `storeprofiler_${ step }_skip` );
|
||||
recordEvent( `coreprofiler_${ step }_skip` );
|
||||
};
|
||||
|
||||
const recordTracksIntroCompleted = () => {
|
||||
recordEvent( 'storeprofiler_step_complete', {
|
||||
step: 'store_details',
|
||||
recordEvent( 'coreprofiler_step_complete', {
|
||||
step: 'intro_opt_in',
|
||||
wc_version: getSetting( 'wcVersion' ),
|
||||
} );
|
||||
};
|
||||
|
@ -47,12 +54,12 @@ const recordTracksUserProfileCompleted = (
|
|||
_context: CoreProfilerStateMachineContext,
|
||||
event: Extract< UserProfileEvent, { type: 'USER_PROFILE_COMPLETED' } >
|
||||
) => {
|
||||
recordEvent( 'storeprofiler_step_complete', {
|
||||
recordEvent( 'coreprofiler_step_complete', {
|
||||
step: 'user_profile',
|
||||
wc_version: getSetting( 'wcVersion' ),
|
||||
} );
|
||||
|
||||
recordEvent( 'storeprofiler_user_profile', {
|
||||
recordEvent( 'coreprofiler_user_profile', {
|
||||
business_choice: event.payload.userProfile.businessChoice,
|
||||
selling_online_answer: event.payload.userProfile.sellingOnlineAnswer,
|
||||
selling_platforms: event.payload.userProfile.sellingPlatforms
|
||||
|
@ -62,7 +69,7 @@ const recordTracksUserProfileCompleted = (
|
|||
};
|
||||
|
||||
const recordTracksSkipBusinessLocationCompleted = () => {
|
||||
recordEvent( 'storeprofiler_step_complete', {
|
||||
recordEvent( 'coreprofiler_step_complete', {
|
||||
step: 'skip_business_location',
|
||||
wc_version: getSetting( 'wcVersion' ),
|
||||
} );
|
||||
|
@ -72,12 +79,12 @@ const recordTracksBusinessInfoCompleted = (
|
|||
_context: CoreProfilerStateMachineContext,
|
||||
event: Extract< BusinessInfoEvent, { type: 'BUSINESS_INFO_COMPLETED' } >
|
||||
) => {
|
||||
recordEvent( 'storeprofiler_step_complete', {
|
||||
recordEvent( 'coreprofiler_step_complete', {
|
||||
step: 'business_info',
|
||||
wc_version: getSetting( 'wcVersion' ),
|
||||
} );
|
||||
|
||||
recordEvent( 'storeprofiler_business_info', {
|
||||
recordEvent( 'coreprofiler_business_info', {
|
||||
business_name_filled:
|
||||
POSSIBLY_DEFAULT_STORE_NAMES.findIndex(
|
||||
( name ) => name === event.payload.storeName
|
||||
|
@ -96,12 +103,57 @@ const recordTracksPluginsLearnMoreLinkClicked = (
|
|||
{ action }: { action: unknown }
|
||||
) => {
|
||||
const { step } = action as { step: string };
|
||||
recordEvent( `storeprofiler_${ step }_learn_more_link_clicked`, {
|
||||
recordEvent( `coreprofiler_${ step }_learn_more_link_clicked`, {
|
||||
plugin: _event.payload.plugin,
|
||||
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 {
|
||||
recordTracksStepViewed,
|
||||
recordTracksStepSkipped,
|
||||
|
@ -110,4 +162,6 @@ export default {
|
|||
recordTracksSkipBusinessLocationCompleted,
|
||||
recordTracksBusinessInfoCompleted,
|
||||
recordTracksPluginsLearnMoreLinkClicked,
|
||||
recordFailedPluginInstallations,
|
||||
recordSuccessfulPluginInstallation,
|
||||
};
|
||||
|
|
|
@ -26,7 +26,6 @@ import {
|
|||
Extension,
|
||||
GeolocationResponse,
|
||||
} from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import { initializeExPlat } from '@woocommerce/explat';
|
||||
import { CountryStateOption } from '@woocommerce/onboarding';
|
||||
|
||||
|
@ -49,7 +48,7 @@ import { BusinessLocation } from './pages/BusinessLocation';
|
|||
import { getCountryStateOptions } from './services/country';
|
||||
import { Loader } from './pages/Loader';
|
||||
import { Plugins } from './pages/Plugins';
|
||||
import { getPluginSlug, getPluginTrackKey, getTimeFrame } from '~/utils';
|
||||
import { getPluginSlug } from '~/utils';
|
||||
import './style.scss';
|
||||
import {
|
||||
InstallationCompletedResult,
|
||||
|
@ -693,7 +692,7 @@ export const coreProfilerStateMachineDefinition = createMachine( {
|
|||
entry: [
|
||||
{
|
||||
type: 'recordTracksStepViewed',
|
||||
step: 'store_details',
|
||||
step: 'intro_opt_in',
|
||||
},
|
||||
{ type: 'updateQueryStep', step: 'intro-opt-in' },
|
||||
],
|
||||
|
@ -709,7 +708,7 @@ export const coreProfilerStateMachineDefinition = createMachine( {
|
|||
actions: [
|
||||
{
|
||||
type: 'recordTracksStepSkipped',
|
||||
step: 'store_details',
|
||||
step: 'intro_opt_in',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -1222,73 +1221,16 @@ export const coreProfilerStateMachineDefinition = createMachine( {
|
|||
event
|
||||
) => event.payload.errors,
|
||||
} ),
|
||||
( _context, event ) => {
|
||||
recordEvent(
|
||||
'storeprofiler_store_extensions_installed_and_activated',
|
||||
{
|
||||
success: false,
|
||||
failed_extensions:
|
||||
event.payload.errors.map(
|
||||
(
|
||||
error: PluginInstallError
|
||||
) =>
|
||||
getPluginTrackKey(
|
||||
error.plugin
|
||||
)
|
||||
),
|
||||
}
|
||||
);
|
||||
{
|
||||
type: 'recordFailedPluginInstallations',
|
||||
},
|
||||
],
|
||||
},
|
||||
PLUGINS_INSTALLATION_COMPLETED: {
|
||||
target: 'postPluginInstallation',
|
||||
actions: [
|
||||
( _context, event ) => {
|
||||
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(
|
||||
'storeprofiler_store_extensions_installed_and_activated',
|
||||
trackData
|
||||
);
|
||||
{
|
||||
type: 'recordSuccessfulPluginInstallation',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: update
|
||||
|
||||
Use coreprofiler_ prefix for core profiler track names
|
Loading…
Reference in New Issue