Files
piratepoet/mailpoet/lib/Twig/Helpscout.php
Rodrigo Primo f19de77f70 Fix sending system info when creating a HelpScout ticket
We were calling the wrong Beacon API method to send system info
data to HelpScout when users create tickets inside WordPress. This
commit fixes this by calling the method `session-data` instead of
`identify`. It is likely that `identify` was the correct method in the
past, but the Beacon API changed
(https://developer.helpscout.com/beacon-2/web/javascript-api/).
Nowadays, the `identify` method is used to add data to the HelpScout
users and fields need to be created in advance in the HelpScout web
interface. `session-data` is used to add information to the ticket which
is what we are trying to achieve. Only `name` and `email` should still
be passed to `identify` to make it possible to match the correct
HelpScout user.

[MAILPOET-4525]
2022-08-18 15:43:12 +02:00

33 lines
807 B
PHP

<?php
namespace MailPoet\Twig;
use MailPoet\DI\ContainerWrapper;
use MailPoet\Helpscout\Beacon;
use MailPoetVendor\Twig\TwigFunction;
class Helpscout extends \MailPoetVendor\Twig\Extension\AbstractExtension {
public function getFunctions() {
return [
new TwigFunction(
'get_helpscout_user_data',
[$this, 'getHelpscoutUserData'],
['is_safe' => ['all']]
),
new TwigFunction(
'get_helpscout_site_data',
[$this, 'getHelpscoutSiteData'],
['is_safe' => ['all']]
),
];
}
public function getHelpscoutUserData() {
return ContainerWrapper::getInstance()->get(Beacon::class)->getUserData();
}
public function getHelpscoutSiteData() {
return ContainerWrapper::getInstance()->get(Beacon::class)->getSiteData();
}
}