Add event tracking for auto-saved content

MAILPOET-6365
This commit is contained in:
Oluwaseun Olorunsola
2024-12-19 12:10:09 +01:00
committed by Oluwaseun Olorunsola
parent 5de7df1433
commit 9f65f04271
3 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { useDispatch, useSelect } from '@wordpress/data'; import { useDispatch, useSelect } from '@wordpress/data';
import { useEffect } from '@wordpress/element'; import { useEffect } from '@wordpress/element';
import { storeName } from '../../store'; import { storeName } from '../../store';
import { recordEvent } from '../../events';
/** /**
* This component is simplified version of the original one from @wordpress/editor package. * This component is simplified version of the original one from @wordpress/editor package.
@ -25,6 +26,7 @@ export function AutosaveMonitor() {
if ( hasEdits && autosaveInterval > 0 ) { if ( hasEdits && autosaveInterval > 0 ) {
autosaveTimer = setTimeout( () => { autosaveTimer = setTimeout( () => {
void saveEditedEmail(); void saveEditedEmail();
recordEvent( 'editor_content_auto_saved' );
}, autosaveInterval * 1000 ); }, autosaveInterval * 1000 );
} }

View File

@ -4,6 +4,7 @@ import { store as noticesStore } from '@wordpress/notices';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { storeName } from '../../store'; import { storeName } from '../../store';
import { recordEvent } from '../../events';
export function SentEmailNotice() { export function SentEmailNotice() {
const { isEmailSent } = useSelect( const { isEmailSent } = useSelect(
@ -27,6 +28,7 @@ export function SentEmailNotice() {
context: 'email-editor', context: 'email-editor',
} }
); );
recordEvent( 'editor_showed_email_sent_notice' );
} }
}, [ isEmailSent ] ); }, [ isEmailSent ] );

View File

@ -102,7 +102,6 @@ export function* saveEditedEmail() {
); );
result.then( () => { result.then( () => {
recordEvent( 'editor-content-saved', { postId } );
void dispatch( noticesStore ).createErrorNotice( void dispatch( noticesStore ).createErrorNotice(
__( 'Email saved!', 'mailpoet' ), __( 'Email saved!', 'mailpoet' ),
{ {
@ -114,7 +113,6 @@ export function* saveEditedEmail() {
} ); } );
result.catch( () => { result.catch( () => {
recordEvent( 'editor-content-not-saved', { postId } );
void dispatch( noticesStore ).createErrorNotice( void dispatch( noticesStore ).createErrorNotice(
__( __(
'The email could not be saved. Please, clear browser cache and reload the page. If the problem persists, duplicate the email and try again.', 'The email could not be saved. Please, clear browser cache and reload the page. If the problem persists, duplicate the email and try again.',