Add event tracking for auto-saved content
MAILPOET-6365
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
5de7df1433
commit
9f65f04271
@ -1,6 +1,7 @@
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { useEffect } from '@wordpress/element';
|
||||
import { storeName } from '../../store';
|
||||
import { recordEvent } from '../../events';
|
||||
|
||||
/**
|
||||
* This component is simplified version of the original one from @wordpress/editor package.
|
||||
@ -25,6 +26,7 @@ export function AutosaveMonitor() {
|
||||
if ( hasEdits && autosaveInterval > 0 ) {
|
||||
autosaveTimer = setTimeout( () => {
|
||||
void saveEditedEmail();
|
||||
recordEvent( 'editor_content_auto_saved' );
|
||||
}, autosaveInterval * 1000 );
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
import { storeName } from '../../store';
|
||||
import { recordEvent } from '../../events';
|
||||
|
||||
export function SentEmailNotice() {
|
||||
const { isEmailSent } = useSelect(
|
||||
@ -27,6 +28,7 @@ export function SentEmailNotice() {
|
||||
context: 'email-editor',
|
||||
}
|
||||
);
|
||||
recordEvent( 'editor_showed_email_sent_notice' );
|
||||
}
|
||||
}, [ isEmailSent ] );
|
||||
|
||||
|
@ -102,7 +102,6 @@ export function* saveEditedEmail() {
|
||||
);
|
||||
|
||||
result.then( () => {
|
||||
recordEvent( 'editor-content-saved', { postId } );
|
||||
void dispatch( noticesStore ).createErrorNotice(
|
||||
__( 'Email saved!', 'mailpoet' ),
|
||||
{
|
||||
@ -114,7 +113,6 @@ export function* saveEditedEmail() {
|
||||
} );
|
||||
|
||||
result.catch( () => {
|
||||
recordEvent( 'editor-content-not-saved', { postId } );
|
||||
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.',
|
||||
|
Reference in New Issue
Block a user