Add events for PersonalizationTags usage
MAILPOET-6365
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
760c6e7506
commit
c3cb92cd47
@ -7,6 +7,7 @@ import { useState } from '@wordpress/element';
|
|||||||
import { CategoryMenu } from './category-menu';
|
import { CategoryMenu } from './category-menu';
|
||||||
import { CategorySection } from './category-section';
|
import { CategorySection } from './category-section';
|
||||||
import { LinkModal } from './link-modal';
|
import { LinkModal } from './link-modal';
|
||||||
|
import { recordEvent, recordEventOnce } from '../../events';
|
||||||
|
|
||||||
const PersonalizationTagsModal = ( {
|
const PersonalizationTagsModal = ( {
|
||||||
onInsert,
|
onInsert,
|
||||||
@ -42,6 +43,8 @@ const PersonalizationTagsModal = ( {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recordEventOnce( 'personalization_tags_modal_opened' );
|
||||||
|
|
||||||
const groupedTags: Record< string, PersonalizationTag[] > = list.reduce(
|
const groupedTags: Record< string, PersonalizationTag[] > = list.reduce(
|
||||||
( groups, item ) => {
|
( groups, item ) => {
|
||||||
const { category, name, token } = item;
|
const { category, name, token } = item;
|
||||||
@ -65,7 +68,10 @@ const PersonalizationTagsModal = ( {
|
|||||||
<Modal
|
<Modal
|
||||||
size="medium"
|
size="medium"
|
||||||
title={ __( 'Personalization Tags', 'mailpoet' ) }
|
title={ __( 'Personalization Tags', 'mailpoet' ) }
|
||||||
onRequestClose={ closeCallback }
|
onRequestClose={ () => {
|
||||||
|
recordEvent( 'personalization_tags_modal_closed' );
|
||||||
|
closeCallback();
|
||||||
|
} }
|
||||||
className="mailpoet-personalization-tags-modal"
|
className="mailpoet-personalization-tags-modal"
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
@ -73,20 +79,52 @@ const PersonalizationTagsModal = ( {
|
|||||||
'Insert personalization tags to dynamically fill in information and personalize your emails.',
|
'Insert personalization tags to dynamically fill in information and personalize your emails.',
|
||||||
'mailpoet'
|
'mailpoet'
|
||||||
) }{ ' ' }
|
) }{ ' ' }
|
||||||
<ExternalLink href="https://kb.mailpoet.com/article/435-a-guide-to-personalisation-tags-for-tailored-newsletters#list">
|
<ExternalLink
|
||||||
|
href="https://kb.mailpoet.com/article/435-a-guide-to-personalisation-tags-for-tailored-newsletters#list"
|
||||||
|
onClick={ () =>
|
||||||
|
recordEvent(
|
||||||
|
'personalization_tags_modal_learn_more_link_clicked'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
{ __( 'Learn more', 'mailpoet' ) }
|
{ __( 'Learn more', 'mailpoet' ) }
|
||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
</p>
|
</p>
|
||||||
<SearchControl onChange={ setSearchQuery } value={ searchQuery } />
|
<SearchControl
|
||||||
|
onChange={ ( theSearchQuery ) => {
|
||||||
|
setSearchQuery( theSearchQuery );
|
||||||
|
recordEventOnce(
|
||||||
|
'personalization_tags_modal_search_control_input_updated'
|
||||||
|
);
|
||||||
|
} }
|
||||||
|
value={ searchQuery }
|
||||||
|
/>
|
||||||
<CategoryMenu
|
<CategoryMenu
|
||||||
groupedTags={ groupedTags }
|
groupedTags={ groupedTags }
|
||||||
activeCategory={ activeCategory }
|
activeCategory={ activeCategory }
|
||||||
onCategorySelect={ setActiveCategory }
|
onCategorySelect={ ( category ) => {
|
||||||
|
setActiveCategory( category );
|
||||||
|
recordEvent(
|
||||||
|
'personalization_tags_modal_category_menu_clicked',
|
||||||
|
{
|
||||||
|
category,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} }
|
||||||
/>
|
/>
|
||||||
<CategorySection
|
<CategorySection
|
||||||
groupedTags={ groupedTags }
|
groupedTags={ groupedTags }
|
||||||
activeCategory={ activeCategory }
|
activeCategory={ activeCategory }
|
||||||
onInsert={ onInsert }
|
onInsert={ ( insertedTag ) => {
|
||||||
|
onInsert( insertedTag );
|
||||||
|
recordEvent(
|
||||||
|
'personalization_tags_modal_tag_insert_button_clicked',
|
||||||
|
{
|
||||||
|
insertedTag,
|
||||||
|
activeCategory,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} }
|
||||||
closeCallback={ closeCallback }
|
closeCallback={ closeCallback }
|
||||||
canInsertLink={ canInsertLink }
|
canInsertLink={ canInsertLink }
|
||||||
openLinkModal={ ( tag ) => {
|
openLinkModal={ ( tag ) => {
|
||||||
|
@ -12,6 +12,7 @@ import { RichText } from '@wordpress/block-editor';
|
|||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { PersonalizationTagsPopover } from './personalization-tags-popover';
|
import { PersonalizationTagsPopover } from './personalization-tags-popover';
|
||||||
import { create, insert, toHTMLString } from '@wordpress/rich-text';
|
import { create, insert, toHTMLString } from '@wordpress/rich-text';
|
||||||
|
import { recordEvent, recordEventOnce } from '../../events';
|
||||||
|
|
||||||
export function RichTextWithButton( {
|
export function RichTextWithButton( {
|
||||||
label,
|
label,
|
||||||
@ -67,7 +68,16 @@ export function RichTextWithButton( {
|
|||||||
className="mailpoet-settings-panel__personalization-tags-button"
|
className="mailpoet-settings-panel__personalization-tags-button"
|
||||||
icon="shortcode"
|
icon="shortcode"
|
||||||
title={ __( 'Personalization Tags', 'mailpoet' ) }
|
title={ __( 'Personalization Tags', 'mailpoet' ) }
|
||||||
onClick={ () => setIsModalOpened( true ) }
|
onClick={ () => {
|
||||||
|
setIsModalOpened( true );
|
||||||
|
recordEvent(
|
||||||
|
'rich_text_with_button_personalization_tags_shortcode_icon_clicked',
|
||||||
|
{
|
||||||
|
attributeName,
|
||||||
|
label,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} }
|
||||||
/>
|
/>
|
||||||
{ labelSuffix }
|
{ labelSuffix }
|
||||||
</>
|
</>
|
||||||
@ -94,6 +104,13 @@ export function RichTextWithButton( {
|
|||||||
selectionRange
|
selectionRange
|
||||||
);
|
);
|
||||||
setIsModalOpened( false );
|
setIsModalOpened( false );
|
||||||
|
recordEvent(
|
||||||
|
'rich_text_with_button_personalization_tags_inserted',
|
||||||
|
{
|
||||||
|
attributeName,
|
||||||
|
value,
|
||||||
|
}
|
||||||
|
);
|
||||||
} }
|
} }
|
||||||
closeCallback={ () => setIsModalOpened( false ) }
|
closeCallback={ () => setIsModalOpened( false ) }
|
||||||
/>
|
/>
|
||||||
@ -147,6 +164,12 @@ export function RichTextWithButton( {
|
|||||||
list
|
list
|
||||||
);
|
);
|
||||||
updateEmailMailPoetProperty( attributeName, value );
|
updateEmailMailPoetProperty( attributeName, value );
|
||||||
|
recordEventOnce(
|
||||||
|
'rich_text_with_button_input_field_updated',
|
||||||
|
{
|
||||||
|
attributeName,
|
||||||
|
}
|
||||||
|
);
|
||||||
} }
|
} }
|
||||||
value={ mailpoetEmailData[ attributeName ] ?? '' }
|
value={ mailpoetEmailData[ attributeName ] ?? '' }
|
||||||
data-automation-id={ `email_${ attributeName }` }
|
data-automation-id={ `email_${ attributeName }` }
|
||||||
|
@ -72,7 +72,8 @@ export function DetailsPanel() {
|
|||||||
onClick={ () =>
|
onClick={ () =>
|
||||||
recordEvent(
|
recordEvent(
|
||||||
'details_panel_preheader_help_text_link_clicked'
|
'details_panel_preheader_help_text_link_clicked'
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -93,7 +94,9 @@ export function DetailsPanel() {
|
|||||||
<ExternalLink
|
<ExternalLink
|
||||||
href="https://kb.mailpoet.com/article/435-a-guide-to-personalisation-tags-for-tailored-newsletters#list"
|
href="https://kb.mailpoet.com/article/435-a-guide-to-personalisation-tags-for-tailored-newsletters#list"
|
||||||
onClick={ () =>
|
onClick={ () =>
|
||||||
recordEvent( 'details_panel_personalisation_tags_guide_link_clicked' )
|
recordEvent(
|
||||||
|
'details_panel_personalisation_tags_guide_link_clicked'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{ __( 'Guide', 'mailpoet' ) }
|
{ __( 'Guide', 'mailpoet' ) }
|
||||||
|
Reference in New Issue
Block a user