Send store age in weeks to tracks (https://github.com/woocommerce/woocommerce-admin/pull/5817)
Co-authored-by: Rebecca Scott <me@becdetat.com>
This commit is contained in:
parent
8b9a2fdd23
commit
baaac28228
|
@ -7,7 +7,7 @@ import { recordEvent } from '@woocommerce/tracks';
|
||||||
import CustomerEffortScore from '@woocommerce/customer-effort-score';
|
import CustomerEffortScore from '@woocommerce/customer-effort-score';
|
||||||
import { compose } from '@wordpress/compose';
|
import { compose } from '@wordpress/compose';
|
||||||
import { withSelect, withDispatch } from '@wordpress/data';
|
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';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
const SHOWN_FOR_ACTIONS_OPTION_NAME = 'woocommerce_ces_shown_for_actions';
|
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 {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.allowTracking Whether tracking is allowed or not.
|
||||||
* @param {boolean} props.resolving Are values still being resolved.
|
* @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.updateOptions Function to update options.
|
||||||
* @param {Function} props.createNotice Function to create a snackbar.
|
* @param {Function} props.createNotice Function to create a snackbar.
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,7 @@ function CustomerEffortScoreTracks( {
|
||||||
cesShownForActions,
|
cesShownForActions,
|
||||||
allowTracking,
|
allowTracking,
|
||||||
resolving,
|
resolving,
|
||||||
storeAge,
|
storeAgeInWeeks,
|
||||||
updateOptions,
|
updateOptions,
|
||||||
createNotice,
|
createNotice,
|
||||||
} ) {
|
} ) {
|
||||||
|
@ -68,7 +68,7 @@ function CustomerEffortScoreTracks( {
|
||||||
const onNoticeShown = () => {
|
const onNoticeShown = () => {
|
||||||
recordEvent( 'ces_snackbar_view', {
|
recordEvent( 'ces_snackbar_view', {
|
||||||
action,
|
action,
|
||||||
store_age: storeAge,
|
store_age: storeAgeInWeeks,
|
||||||
...trackProps,
|
...trackProps,
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
@ -85,7 +85,7 @@ function CustomerEffortScoreTracks( {
|
||||||
const onNoticeDismissed = () => {
|
const onNoticeDismissed = () => {
|
||||||
recordEvent( 'ces_snackbar_dismiss', {
|
recordEvent( 'ces_snackbar_dismiss', {
|
||||||
action,
|
action,
|
||||||
store_age: storeAge,
|
store_age: storeAgeInWeeks,
|
||||||
...trackProps,
|
...trackProps,
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ function CustomerEffortScoreTracks( {
|
||||||
|
|
||||||
recordEvent( 'ces_view', {
|
recordEvent( 'ces_view', {
|
||||||
action,
|
action,
|
||||||
store_age: storeAge,
|
store_age: storeAgeInWeeks,
|
||||||
...trackProps,
|
...trackProps,
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ function CustomerEffortScoreTracks( {
|
||||||
action,
|
action,
|
||||||
score,
|
score,
|
||||||
comments: comments || '',
|
comments: comments || '',
|
||||||
store_age: storeAge,
|
store_age: storeAgeInWeeks,
|
||||||
...trackProps,
|
...trackProps,
|
||||||
} );
|
} );
|
||||||
createNotice( 'success', onSubmitLabel );
|
createNotice( 'success', onSubmitLabel );
|
||||||
|
@ -165,9 +165,9 @@ CustomerEffortScoreTracks.propTypes = {
|
||||||
*/
|
*/
|
||||||
resolving: PropTypes.bool.isRequired,
|
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.
|
* Function to update options.
|
||||||
*/
|
*/
|
||||||
|
@ -190,7 +190,7 @@ export default compose(
|
||||||
// Date.now() is ms since Unix epoch, adminInstallTimestamp is in
|
// Date.now() is ms since Unix epoch, adminInstallTimestamp is in
|
||||||
// seconds since Unix epoch.
|
// seconds since Unix epoch.
|
||||||
const storeAgeInMs = Date.now() - adminInstallTimestamp * 1000;
|
const storeAgeInMs = Date.now() - adminInstallTimestamp * 1000;
|
||||||
const storeAge = Math.round( storeAgeInMs / MONTH );
|
const storeAgeInWeeks = Math.round( storeAgeInMs / WEEK );
|
||||||
|
|
||||||
const allowTrackingOption =
|
const allowTrackingOption =
|
||||||
getOption( ALLOW_TRACKING_OPTION_NAME ) || 'no';
|
getOption( ALLOW_TRACKING_OPTION_NAME ) || 'no';
|
||||||
|
@ -206,7 +206,7 @@ export default compose(
|
||||||
return {
|
return {
|
||||||
cesShownForActions,
|
cesShownForActions,
|
||||||
allowTracking,
|
allowTracking,
|
||||||
storeAge,
|
storeAgeInWeeks,
|
||||||
resolving,
|
resolving,
|
||||||
};
|
};
|
||||||
} ),
|
} ),
|
||||||
|
|
|
@ -10,6 +10,7 @@ export const SECOND = 1000;
|
||||||
export const MINUTE = 60 * SECOND;
|
export const MINUTE = 60 * SECOND;
|
||||||
export const HOUR = 60 * MINUTE;
|
export const HOUR = 60 * MINUTE;
|
||||||
export const DAY = 24 * HOUR;
|
export const DAY = 24 * HOUR;
|
||||||
|
export const WEEK = 7 * DAY;
|
||||||
export const MONTH = ( 365 * DAY ) / 12;
|
export const MONTH = ( 365 * DAY ) / 12;
|
||||||
|
|
||||||
export const DEFAULT_REQUIREMENT = {
|
export const DEFAULT_REQUIREMENT = {
|
||||||
|
|
|
@ -47,6 +47,7 @@ export {
|
||||||
MINUTE,
|
MINUTE,
|
||||||
HOUR,
|
HOUR,
|
||||||
DAY,
|
DAY,
|
||||||
|
WEEK,
|
||||||
MONTH,
|
MONTH,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue