Track site visibility setting actions (#46078)

* Track site visibility actions

* Move private link text box to prevent accidental toggle

* Add changefile(s) from automation for the following project(s): woocommerce

* Restirct site visibility settings to general tab

* Remove unnecessary site visibility render logic

* Lint fix

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Moon 2024-04-04 16:50:26 -07:00 committed by GitHub
parent def3ac920d
commit 1907016893
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 49 additions and 13 deletions

View File

@ -12,6 +12,7 @@ import { registerPlugin } from '@wordpress/plugins';
import { __ } from '@wordpress/i18n';
import classNames from 'classnames';
import { useCopyToClipboard } from '@wordpress/compose';
import { recordEvent } from '@woocommerce/tracks';
/**
* Internal dependencies
@ -91,6 +92,9 @@ const SiteVisibility = () => {
<RadioControl
onChange={ () => {
setComingSoon( 'yes' );
recordEvent( 'site_visibility_toggle', {
status: 'coming_soon',
} );
} }
options={ [
{
@ -130,10 +134,16 @@ const SiteVisibility = () => {
</>
}
checked={ storePagesOnly === 'yes' }
onChange={ () => {
onChange={ ( enabled ) => {
setStorePagesOnly(
storePagesOnly === 'yes' ? 'no' : 'yes'
);
recordEvent(
'site_visibility_restrict_store_pages_only_toggle',
{
enabled,
}
);
} }
/>
<ToggleControl
@ -149,32 +159,46 @@ const SiteVisibility = () => {
'woocommerce'
) }
</p>
{ privateLink === 'yes' && (
<div className="site-visibility-settings-slotfill-private-link">
{ getPrivateLink() }
<Button
ref={ copyClipboardRef }
variant="link"
>
{ copyLinkText }
</Button>
</div>
) }
</>
}
checked={ privateLink === 'yes' }
onChange={ () => {
onChange={ ( enabled ) => {
setPrivateLink(
privateLink === 'yes' ? 'no' : 'yes'
);
recordEvent(
'site_visibility_share_private_link_toggle',
{
enabled,
}
);
} }
/>
</div>
{ privateLink === 'yes' && (
<div className="site-visibility-settings-slotfill-private-link">
{ getPrivateLink() }
<Button
ref={ copyClipboardRef }
variant="link"
onClick={ () => {
recordEvent(
'site_visibility_private_link_copy'
);
} }
>
{ copyLinkText }
</Button>
</div>
) }
</div>
<div className="site-visibility-settings-slotfill-section">
<RadioControl
onChange={ () => {
setComingSoon( 'no' );
recordEvent( 'site_visibility_toggle', {
status: 'live',
} );
} }
options={ [
{

View File

@ -9,6 +9,7 @@
}
.site-visibility-settings-slotfill-private-link {
margin-left: 73px;
padding: 8px 16px;
border-radius: 4px;
border: 1px solid #dcdcde;

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Add tracks for site visibility settings

View File

@ -37,13 +37,20 @@ class LaunchYourStore {
'woocommerce_private_link' => array( 'yes', 'no' ),
);
$at_least_one_saved = false;
foreach ( $options as $name => $option ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( isset( $_POST[ $name ] ) && in_array( $_POST[ $name ], $option, true ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
update_option( $name, wp_unslash( $_POST[ $name ] ) );
$at_least_one_saved = true;
}
}
if ( $at_least_one_saved ) {
wc_admin_record_tracks_event( 'site_visibility_saved' );
}
}
/**