Display nps statis meter
[MAILPOET-2549]
This commit is contained in:
committed by
Jack Kitterhing
parent
be0c9a726c
commit
a37d8888d9
@ -4,6 +4,7 @@ import MailPoet from 'mailpoet';
|
|||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Listing from 'listing/listing.jsx';
|
import Listing from 'listing/listing.jsx';
|
||||||
|
import withNpsPoll from 'nps_poll.jsx';
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
@ -229,4 +230,4 @@ FormList.propTypes = {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FormList;
|
export default withNpsPoll(FormList);
|
||||||
|
@ -29,8 +29,17 @@ const useNpsPoll = () => {
|
|||||||
const callSatismeter = (trackingData) => {
|
const callSatismeter = (trackingData) => {
|
||||||
const newUsersPollId = '6L479eVPXk7pBn6S';
|
const newUsersPollId = '6L479eVPXk7pBn6S';
|
||||||
const oldUsersPollId = 'k0aJAsQAWI2ERyGv';
|
const oldUsersPollId = 'k0aJAsQAWI2ERyGv';
|
||||||
|
const formPollId = 'EqOgKsgZd832Sz9w';
|
||||||
|
let writeKey;
|
||||||
|
if (window.mailpoet_display_nps_form) {
|
||||||
|
writeKey = formPollId;
|
||||||
|
} else if (window.mailpoet_is_new_user) {
|
||||||
|
writeKey = newUsersPollId;
|
||||||
|
} else {
|
||||||
|
writeKey = oldUsersPollId;
|
||||||
|
}
|
||||||
satismeter({
|
satismeter({
|
||||||
writeKey: window.mailpoet_is_new_user ? newUsersPollId : oldUsersPollId,
|
writeKey,
|
||||||
userId: window.mailpoet_current_wp_user.ID + window.mailpoet_site_url,
|
userId: window.mailpoet_current_wp_user.ID + window.mailpoet_site_url,
|
||||||
traits: {
|
traits: {
|
||||||
name: window.mailpoet_current_wp_user.user_nicename,
|
name: window.mailpoet_current_wp_user.user_nicename,
|
||||||
|
@ -5,7 +5,11 @@ namespace MailPoet\AdminPages\Pages;
|
|||||||
use MailPoet\AdminPages\PageRenderer;
|
use MailPoet\AdminPages\PageRenderer;
|
||||||
use MailPoet\Listing\PageLimit;
|
use MailPoet\Listing\PageLimit;
|
||||||
use MailPoet\Models\Segment;
|
use MailPoet\Models\Segment;
|
||||||
|
use MailPoet\Settings\SettingsController;
|
||||||
|
use MailPoet\Settings\UserFlagsController;
|
||||||
use MailPoet\Util\Installation;
|
use MailPoet\Util\Installation;
|
||||||
|
use MailPoet\Util\License\License;
|
||||||
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
class Forms {
|
class Forms {
|
||||||
/** @var PageRenderer */
|
/** @var PageRenderer */
|
||||||
@ -17,14 +21,29 @@ class Forms {
|
|||||||
/** @var Installation */
|
/** @var Installation */
|
||||||
private $installation;
|
private $installation;
|
||||||
|
|
||||||
|
/** @var UserFlagsController */
|
||||||
|
private $userFlags;
|
||||||
|
|
||||||
|
/** @var WPFunctions */
|
||||||
|
private $wp;
|
||||||
|
|
||||||
|
/** @var SettingsController */
|
||||||
|
private $settings;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PageRenderer $pageRenderer,
|
PageRenderer $pageRenderer,
|
||||||
PageLimit $listingPageLimit,
|
PageLimit $listingPageLimit,
|
||||||
Installation $installation
|
Installation $installation,
|
||||||
|
SettingsController $settings,
|
||||||
|
UserFlagsController $userFlags,
|
||||||
|
WPFunctions $wp
|
||||||
) {
|
) {
|
||||||
$this->pageRenderer = $pageRenderer;
|
$this->pageRenderer = $pageRenderer;
|
||||||
$this->listingPageLimit = $listingPageLimit;
|
$this->listingPageLimit = $listingPageLimit;
|
||||||
$this->installation = $installation;
|
$this->installation = $installation;
|
||||||
|
$this->userFlags = $userFlags;
|
||||||
|
$this->wp = $wp;
|
||||||
|
$this->settings = $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
@ -33,6 +52,24 @@ class Forms {
|
|||||||
$data['segments'] = Segment::findArray();
|
$data['segments'] = Segment::findArray();
|
||||||
$data['is_new_user'] = $this->installation->isNewInstallation();
|
$data['is_new_user'] = $this->installation->isNewInstallation();
|
||||||
|
|
||||||
|
$data = $this->getNPSSurveyData($data);
|
||||||
|
|
||||||
$this->pageRenderer->displayPage('forms.html', $data);
|
$this->pageRenderer->displayPage('forms.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNPSSurveyData($data) {
|
||||||
|
$data['display_nps_survey'] = false;
|
||||||
|
if ($this->userFlags->get('display_new_form_editor_nps_survey')) {
|
||||||
|
$data['current_wp_user'] = $this->wp->wpGetCurrentUser()->to_array();
|
||||||
|
$data['site_url'] = $this->wp->siteUrl();
|
||||||
|
$data['premium_plugin_active'] = License::getLicense();
|
||||||
|
$data['current_wp_user_firstname'] = $this->wp->wpGetCurrentUser()->user_firstname;
|
||||||
|
$installedAtDateTime = new \DateTime($this->settings->get('installed_at'));
|
||||||
|
$data['installed_days_ago'] = (int)$installedAtDateTime->diff(new \DateTime())->format('%a');
|
||||||
|
|
||||||
|
$data['display_nps_survey'] = true;
|
||||||
|
$this->userFlags->set('display_new_form_editor_nps_survey', false);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,18 @@
|
|||||||
'5ad9b1f22c7d3a0e93678640',
|
'5ad9b1f22c7d3a0e93678640',
|
||||||
'5d1f468504286369ad8d57ff'
|
'5d1f468504286369ad8d57ff'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var mailpoet_display_nps_poll = <%= json_encode(display_nps_survey) %>;
|
||||||
|
|
||||||
|
<%if display_nps_survey %>
|
||||||
|
var mailpoet_display_nps_form = true;
|
||||||
|
var mailpoet_premium_active = <%= json_encode(premium_plugin_active) %>;
|
||||||
|
var mailpoet_site_url = "<%= site_url %>";
|
||||||
|
var mailpoet_current_wp_user = <%= json_encode(current_wp_user) %>;
|
||||||
|
var mailpoet_current_wp_user_firstname = '<%= current_wp_user_firstname %>';
|
||||||
|
var mailpoet_review_request_illustration_url = '<%= cdn_url('review-request/review-request-illustration.20190815-1427.svg') %>';
|
||||||
|
var mailpoet_installed_days_ago = <%= installed_days_ago %>;
|
||||||
|
<%endif%>
|
||||||
</script>
|
</script>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user