diff --git a/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks.js b/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks.js index c577e7e6833..46c1be0d87b 100644 --- a/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks.js +++ b/plugins/woocommerce-admin/client/customer-effort-score-tracks/customer-effort-score-tracks.js @@ -7,7 +7,7 @@ import { recordEvent } from '@woocommerce/tracks'; import CustomerEffortScore from '@woocommerce/customer-effort-score'; import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; -import { OPTIONS_STORE_NAME, MONTH } from '@woocommerce/data'; +import { OPTIONS_STORE_NAME, WEEK } from '@woocommerce/data'; import { __ } from '@wordpress/i18n'; const SHOWN_FOR_ACTIONS_OPTION_NAME = 'woocommerce_ces_shown_for_actions'; @@ -27,7 +27,7 @@ const ALLOW_TRACKING_OPTION_NAME = 'woocommerce_allow_tracking'; * @param {Array} props.cesShownForActions The array of actions that the CES modal has been shown for. * @param {boolean} props.allowTracking Whether tracking is allowed or not. * @param {boolean} props.resolving Are values still being resolved. - * @param {number} props.storeAge The age of the store in months. + * @param {number} props.storeAgeInWeeks The age of the store in weeks. * @param {Function} props.updateOptions Function to update options. * @param {Function} props.createNotice Function to create a snackbar. */ @@ -39,7 +39,7 @@ function CustomerEffortScoreTracks( { cesShownForActions, allowTracking, resolving, - storeAge, + storeAgeInWeeks, updateOptions, createNotice, } ) { @@ -68,7 +68,7 @@ function CustomerEffortScoreTracks( { const onNoticeShown = () => { recordEvent( 'ces_snackbar_view', { action, - store_age: storeAge, + store_age: storeAgeInWeeks, ...trackProps, } ); }; @@ -85,7 +85,7 @@ function CustomerEffortScoreTracks( { const onNoticeDismissed = () => { recordEvent( 'ces_snackbar_dismiss', { action, - store_age: storeAge, + store_age: storeAgeInWeeks, ...trackProps, } ); @@ -97,7 +97,7 @@ function CustomerEffortScoreTracks( { recordEvent( 'ces_view', { action, - store_age: storeAge, + store_age: storeAgeInWeeks, ...trackProps, } ); @@ -109,7 +109,7 @@ function CustomerEffortScoreTracks( { action, score, comments: comments || '', - store_age: storeAge, + store_age: storeAgeInWeeks, ...trackProps, } ); createNotice( 'success', onSubmitLabel ); @@ -165,9 +165,9 @@ CustomerEffortScoreTracks.propTypes = { */ resolving: PropTypes.bool.isRequired, /** - * The age of the store in months. + * The age of the store in weeks. */ - storeAge: PropTypes.number, + storeAgeInWeeks: PropTypes.number, /** * Function to update options. */ @@ -190,7 +190,7 @@ export default compose( // Date.now() is ms since Unix epoch, adminInstallTimestamp is in // seconds since Unix epoch. const storeAgeInMs = Date.now() - adminInstallTimestamp * 1000; - const storeAge = Math.round( storeAgeInMs / MONTH ); + const storeAgeInWeeks = Math.round( storeAgeInMs / WEEK ); const allowTrackingOption = getOption( ALLOW_TRACKING_OPTION_NAME ) || 'no'; @@ -206,7 +206,7 @@ export default compose( return { cesShownForActions, allowTracking, - storeAge, + storeAgeInWeeks, resolving, }; } ), diff --git a/plugins/woocommerce-admin/packages/data/src/constants.js b/plugins/woocommerce-admin/packages/data/src/constants.js index 20def762926..4839bc0dd56 100644 --- a/plugins/woocommerce-admin/packages/data/src/constants.js +++ b/plugins/woocommerce-admin/packages/data/src/constants.js @@ -10,6 +10,7 @@ export const SECOND = 1000; export const MINUTE = 60 * SECOND; export const HOUR = 60 * MINUTE; export const DAY = 24 * HOUR; +export const WEEK = 7 * DAY; export const MONTH = ( 365 * DAY ) / 12; export const DEFAULT_REQUIREMENT = { diff --git a/plugins/woocommerce-admin/packages/data/src/index.js b/plugins/woocommerce-admin/packages/data/src/index.js index 37f540ff0f1..1ae0eac09eb 100644 --- a/plugins/woocommerce-admin/packages/data/src/index.js +++ b/plugins/woocommerce-admin/packages/data/src/index.js @@ -47,6 +47,7 @@ export { MINUTE, HOUR, DAY, + WEEK, MONTH, } from './constants';