Skip to content

Commit

Permalink
Announcement Modal: add tracks event for dismiss. (#57693)
Browse files Browse the repository at this point in the history
Co-authored-by: cpap <[email protected]>
  • Loading branch information
cpapazoglou and cpap authored Nov 10, 2021
1 parent b5fea2b commit 0178a4a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/blocks/announcement-modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button } from '@automattic/components';
import { Title } from '@automattic/onboarding';
import { Guide } from '@wordpress/components';
import { useSelector, useDispatch } from 'react-redux';
import { recordTracksEvent } from 'calypso/state/analytics/actions';
import { getCurrentUserId } from 'calypso/state/current-user/selectors';
import { savePreference } from 'calypso/state/preferences/actions';
import { getPreference, hasReceivedRemotePreferences } from 'calypso/state/preferences/selectors';
Expand Down Expand Up @@ -38,7 +39,7 @@ const Modal = ( { announcementId, pages, finishButtonText } ) => {
const dispatch = useDispatch();
const userId = useSelector( ( state ) => getCurrentUserId( state ) );
const hasPreferences = useSelector( hasReceivedRemotePreferences );
const dismissPreference = `announcement-modal-${ userId }-${ announcementId }`;
const dismissPreference = `announcement-modal-${ announcementId }-${ userId }`;
const isDismissed = useSelector( ( state ) => getPreference( state, dismissPreference ) );
const singlePage = pages.length === 1;

Expand All @@ -48,6 +49,11 @@ const Modal = ( { announcementId, pages, finishButtonText } ) => {

const handleDismiss = () => {
dispatch( savePreference( dismissPreference, 1 ) );
dispatch(
recordTracksEvent( 'calypso_announcement_modal_dismiss', {
announcement_id: announcementId,
} )
);
};

return (
Expand Down

0 comments on commit 0178a4a

Please sign in to comment.