From 082b6c1089b13ec0ff8b6173de8234b26b740c78 Mon Sep 17 00:00:00 2001 From: Moon Date: Tue, 29 Dec 2020 13:21:24 -0800 Subject: [PATCH] Update ce4wp_referred_by option when Creative Mail gets activated during the onboarding process (https://github.com/woocommerce/woocommerce-admin/pull/5978) --- .../profile-wizard/steps/business-details.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/plugins/woocommerce-admin/client/profile-wizard/steps/business-details.js b/plugins/woocommerce-admin/client/profile-wizard/steps/business-details.js index 55f50e284aa..f41407e8b8b 100644 --- a/plugins/woocommerce-admin/client/profile-wizard/steps/business-details.js +++ b/plugins/woocommerce-admin/client/profile-wizard/steps/business-details.js @@ -31,6 +31,7 @@ import { PLUGINS_STORE_NAME, pluginNames, SETTINGS_STORE_NAME, + OPTIONS_STORE_NAME, } from '@woocommerce/data'; import { recordEvent } from '@woocommerce/tracks'; @@ -102,6 +103,25 @@ class BusinessDetails extends Component { this.numberFormat = this.numberFormat.bind( this ); } + onCreativeMailInstallAndActivated() { + const { updateOptions } = this.props; + updateOptions( { + ce4wp_referred_by: { + plugin: 'woocommerce', + version: getSetting( 'wcVersion' ), + time: Math.floor( new Date().getTime() / 1000 ), + source: 'onboarding', + }, + } ); + } + + onPostInstallAndActivePlugins( response ) { + const activated = response.data.activated; + if ( activated.includes( 'creative-mail-by-constant-contact' ) ) { + this.onCreativeMailInstallAndActivated(); + } + } + async onContinue( values ) { const { createNotice, @@ -176,6 +196,7 @@ class BusinessDetails extends Component { installAndActivatePlugins( businessExtensions ) .then( ( response ) => { createNoticesFromResponse( response ); + this.onPostInstallAndActivePlugins( response ); } ) .catch( ( error ) => { createNoticesFromResponse( error ); @@ -1007,11 +1028,13 @@ export default compose( const { updateProfileItems } = dispatch( ONBOARDING_STORE_NAME ); const { installAndActivatePlugins } = dispatch( PLUGINS_STORE_NAME ); const { createNotice } = dispatch( 'core/notices' ); + const { updateOptions } = dispatch( OPTIONS_STORE_NAME ); return { createNotice, installAndActivatePlugins, updateProfileItems, + updateOptions, }; } ) )( BusinessDetails );