Display the last engagement on the subscribers stats page

[MAILPOET-3770]
This commit is contained in:
Pavel Dohnal
2021-09-08 09:08:06 +02:00
committed by Veljko V
parent 1aef43cfc9
commit 206dd92054
3 changed files with 14 additions and 0 deletions

View File

@ -19,6 +19,7 @@ export type StatsType = {
machine_open: number; machine_open: number;
click: number; click: number;
engagement_score: number; engagement_score: number;
last_engagement?: string;
woocommerce: { woocommerce: {
currency: string; currency: string;
value: number; value: number;
@ -65,6 +66,13 @@ export const SubscriberStats: React.FunctionComponent = () => {
return ( return (
<div className="mailpoet-subscriber-stats"> <div className="mailpoet-subscriber-stats">
<Heading email={stats.email} /> <Heading email={stats.email} />
<p>
{MailPoet.I18n.t('lastEngagement')}
{': '}
{
stats.last_engagement ? MailPoet.Date.format(stats.last_engagement) : MailPoet.I18n.t('never')
}
</p>
<div className="mailpoet-subscriber-stats-summary-grid"> <div className="mailpoet-subscriber-stats-summary-grid">
<Summary <Summary
click={stats.click} click={stats.click}

View File

@ -48,6 +48,10 @@ class SubscriberStats extends APIEndpoint {
'click' => $statistics->getClickCount(), 'click' => $statistics->getClickCount(),
'engagement_score' => $subscriber->getEngagementScore(), 'engagement_score' => $subscriber->getEngagementScore(),
]; ];
$lastEngagement = $subscriber->getLastEngagementAt();
if ($lastEngagement instanceof \DateTimeInterface) {
$response['last_engagement'] = $lastEngagement->format('Y-m-d H:i:s');
}
$woocommerce = $statistics->getWooCommerceRevenue(); $woocommerce = $statistics->getWooCommerceRevenue();
if ($woocommerce instanceof WooCommerceRevenue) { if ($woocommerce instanceof WooCommerceRevenue) {
$response['woocommerce'] = $woocommerce->asArray(); $response['woocommerce'] = $woocommerce->asArray();

View File

@ -56,6 +56,8 @@
'moveToTrash': __('Move to trash'), 'moveToTrash': __('Move to trash'),
'deletePermanently': __('Delete Permanently'), 'deletePermanently': __('Delete Permanently'),
'showMoreDetails': __('Show more details'), 'showMoreDetails': __('Show more details'),
'lastEngagement': __('Last engagement'),
'never': _x('never', 'when was the last time the subscriber engaged with the website?'),
'previousPage': __('Previous page'), 'previousPage': __('Previous page'),
'firstPage': __('First page'), 'firstPage': __('First page'),