Add human and machine opens setting

[MAILPOET-6164]
This commit is contained in:
alex-mpoet
2024-08-19 20:04:47 +03:00
committed by Aschepikov
parent c987733fba
commit ee1043fce9
6 changed files with 60 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { SaveButton } from 'settings/components';
import { TaskScheduler } from './task-scheduler';
import { Roles } from './roles';
import { EngagementTracking } from './engagement-tracking';
import { HumanAndMachineOpens } from './human-and-machine-opens';
import { Transactional } from './transactional';
import { InactiveSubscribers } from './inactive-subscribers';
import { ShareData } from './share-data';
@ -19,6 +20,7 @@ export function Advanced() {
<TaskScheduler />
<Roles />
<EngagementTracking />
<HumanAndMachineOpens />
<Transactional />
<RecalculateSubscriberScore />
<InactiveSubscribers />

View File

@ -0,0 +1,45 @@
import { ReactElement } from 'react';
import { t } from 'common/functions';
import { Radio } from 'common/form/radio/radio';
import { useSetting } from 'settings/store/hooks';
import { Label, Inputs } from 'settings/components';
export function HumanAndMachineOpens(): ReactElement {
const [opens, setOpensMode] = useSetting('tracking', 'opens');
return (
<>
<Label
title={t('humanAndMachineOpensTitle')}
description={t('humanAndMachineOpensDescription')}
htmlFor="opens_mode"
/>
<Inputs>
<div className="mailpoet-settings-inputs-row">
<Radio
id="opens-merged"
value="merged"
checked={opens === 'merged'}
onCheck={setOpensMode}
automationId="opens-merged-radio"
/>
<label htmlFor="opens-merged">
{t('humanAndMachineOpensMerged')}
</label>
</div>
<div className="mailpoet-settings-inputs-row">
<Radio
id="opens-separated"
value="separated"
checked={opens === 'separated'}
onCheck={setOpensMode}
automationId="opens-separated-radio"
/>
<label htmlFor="opens-separated">
{t('humanAndMachineOpensSeparated')}
</label>
</div>
</Inputs>
</>
);
}

View File

@ -115,7 +115,10 @@ export function normalizeSettings(data: Record<string, unknown>): Settings {
'Action Scheduler',
),
}),
tracking: asObject({ level: asEnum(['full', 'partial', 'basic'], 'full') }),
tracking: asObject({
level: asEnum(['full', 'partial', 'basic'], 'full'),
opens: asEnum(['merged', 'separated'], 'merged'),
}),
send_transactional_emails: disabledRadio,
deactivate_subscriber_after_inactive_days: asEnum(
['', '90', '180', '365', '540'],

View File

@ -49,6 +49,7 @@ export type Settings = {
};
tracking: {
level: 'full' | 'basic' | 'partial';
opens: 'merged' | 'separated';
};
'3rd_party_libs': {
enabled: '' | '1';

View File

@ -64,6 +64,7 @@ function WooCommerceController({
MailPoet.trackingConfig.level === 'basic' ? 'basic' : 'partial';
const trackingData: Settings['tracking'] = {
level: allowed ? 'full' : trackingLevelForDisabledCookies,
opens: 'merged',
};
const subscribeOldCustomersData: Settings['mailpoet_subscribe_old_woocommerce_customers'] =
{
@ -77,6 +78,8 @@ function WooCommerceController({
// cookies allowed
'tracking.level': trackingData.level,
'woocommerce.accept_cookie_revenue_tracking.set': '1',
// human and machine opens
'tracking.opens': trackingData.opens,
};
await updateSettings(settings);
setTracking(trackingData);

View File

@ -233,4 +233,9 @@
'engagementTrackingFull': __('Full additionally use browser cookies to improve the site and email engagement tracking and abandoned cart email accuracy.'),
'engagementTrackingPartial': __('Partial additionally track email engagement (opens, clicks). Disable cookie-based tracking.'),
'engagementTrackingBasic': __('Basic only use data your site already has about your subscribers. Disable email engagement and cookie-based tracking, and re-engagement emails.'),
'humanAndMachineOpensTitle': __('Human and machine opens'),
'humanAndMachineOpensDescription': __('Choose how human and machine opens should be displayed.'),
'humanAndMachineOpensMerged': __('Merged both are counted as total opens. Similar to other email marketing tools.'),
'humanAndMachineOpensSeparated': __('Separated only human opens are counted as total opens. More accurate, but the numbers tend to be lower.'),
}) %>