Skip to content

Commit

Permalink
Merge pull request #928 from mollie/PIPRES-366/error-logging
Browse files Browse the repository at this point in the history
PIPRES-366/ Sentry error logger consent option addded
  • Loading branch information
GytisZum authored May 27, 2024
2 parents 5f6aab5 + 4d0396a commit c633438
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 0 deletions.
2 changes: 2 additions & 0 deletions controllers/admin/AdminMollieSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public function postProcess()
$this->module->getLocalPath() . 'views/templates/admin/logo.tpl'
);

$this->content .= $this->context->smarty->fetch($this->module->getLocalPath() . 'views/templates/admin/mollie-error-logger-modal.tpl') ?: '';

$this->initCloudSyncAndPsAccounts();

/** @var \Mollie\Repository\ModuleRepository $moduleRepository */
Expand Down
26 changes: 26 additions & 0 deletions src/Builder/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,32 @@ protected function getAccountSettingsSection($isApiKeyProvided)
],
];

$input[] = [
'type' => 'switch',
'label' => $this->module->l('Error Logging', self::FILE_NAME),
'tab' => $generalSettings,
'name' => Config::MOLLIE_ERROR_LOGGING[(int) $this->configuration->get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'],
'desc' => TagsUtility::ppTags(
$this->module->l('Read more about [1]Error Logging[/1] and how it improves your experience.', self::FILE_NAME),
[
$this->module->display($this->module->getPathUri(), 'views/templates/admin/mollie_error_logging_info.tpl'),
]
),
'is_bool' => true,
'values' => [
[
'id' => 'active_on',
'value' => true,
'label' => $this->module->l('Enabled', self::FILE_NAME),
],
[
'id' => 'active_off',
'value' => false,
'label' => $this->module->l('Disabled', self::FILE_NAME),
],
],
];

$input = array_merge($input, [
[
'type' => 'select',
Expand Down
6 changes: 6 additions & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ class Config
'sandbox' => 'MOLLIE_SANDBOX_SINGLE_CLICK_PAYMENT',
'production' => 'MOLLIE_PRODUCTION_SINGLE_CLICK_PAYMENT',
];

const MOLLIE_ERROR_LOGGING = [
'sandbox' => 'MOLLIE_SANDBOX_ERROR_LOGGING',
'production' => 'MOLLIE_PRODUCTION_ERROR_LOGGING',
];

const MOLLIE_IMAGES = 'MOLLIE_IMAGES';
const MOLLIE_SHOW_RESEND_PAYMENT_LINK = 'MOLLIE_SHOW_RESEND_PAYMENT_LINK';
const MOLLIE_ISSUERS = [
Expand Down
5 changes: 5 additions & 0 deletions src/Handler/ErrorHandler/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public function __construct(Mollie $module, Env $env = null)
*/
public function handle(\Throwable $error, ?int $code = null, ?bool $throw = true): void
{
// NOTE: The error is not being sent if the error logging is disabled
if ((int) !\Configuration::get(Config::MOLLIE_ERROR_LOGGING[\Configuration::get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'])) {
return;
}

$this->client->captureException($error, $this->exceptionContext);

if ($code && true === $throw) {
Expand Down
1 change: 1 addition & 0 deletions src/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ protected function initConfig()
$this->configurationAdapter->updateValue(Config::MOLLIE_BANCONTACT_QR_CODE_ENABLED, 0);

$this->configurationAdapter->updateValue(Config::MOLLIE_SUBSCRIPTION_ORDER_CARRIER_ID, 0);
$this->configurationAdapter->updateValue(Config::MOLLIE_ERROR_LOGGING, 0);
}

public function setDefaultCarrierStatuses()
Expand Down
1 change: 1 addition & 0 deletions src/Install/Uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private function deleteConfig()
Config::MOLLIE_MAIL_WHEN_COMPLETED,
Config::MOLLIE_API_KEY_TEST,
Config::MOLLIE_SUBSCRIPTION_ORDER_CARRIER_ID,
Config::MOLLIE_ERROR_LOGGING,
];

$this->deleteConfigurations($configurations);
Expand Down
1 change: 1 addition & 0 deletions src/Service/ConfigFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function getConfigFieldsValues()
Config::MOLLIE_SEND_ORDER_CONFIRMATION => $this->configurationAdapter->get(Config::MOLLIE_SEND_ORDER_CONFIRMATION),
Config::MOLLIE_IFRAME[(int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'] => $this->configurationAdapter->get(Config::MOLLIE_IFRAME),
Config::MOLLIE_SINGLE_CLICK_PAYMENT[(int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'] => $this->configurationAdapter->get(Config::MOLLIE_SINGLE_CLICK_PAYMENT),
Config::MOLLIE_ERROR_LOGGING[(int) $this->configurationAdapter->get(Config::MOLLIE_ENVIRONMENT) ? 'production' : 'sandbox'] => $this->configurationAdapter->get(Config::MOLLIE_ERROR_LOGGING),

Config::MOLLIE_CSS => $this->configurationAdapter->get(Config::MOLLIE_CSS),
Config::MOLLIE_IMAGES => $this->configurationAdapter->get(Config::MOLLIE_IMAGES),
Expand Down
3 changes: 3 additions & 0 deletions src/Service/SettingsSaveService.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ public function saveSettings(&$errors = [])
$mollieOrderConfirmationSand = $this->tools->getValue(Config::MOLLIE_SEND_ORDER_CONFIRMATION);
$mollieIFrameEnabled = $this->tools->getValue(Config::MOLLIE_IFRAME[$environment ? 'production' : 'sandbox']);
$mollieSingleClickPaymentEnabled = $this->tools->getValue(Config::MOLLIE_SINGLE_CLICK_PAYMENT[$environment ? 'production' : 'sandbox']);
$mollieErrorLoggingEnabled = $this->tools->getValue(Config::MOLLIE_ERROR_LOGGING[$environment ? 'production' : 'sandbox']);

$mollieImages = $this->tools->getValue(Config::MOLLIE_IMAGES);
$showResentPayment = $this->tools->getValue(Config::MOLLIE_SHOW_RESEND_PAYMENT_LINK);
$mollieIssuers = $this->tools->getValue(Config::MOLLIE_ISSUERS[$environment ? 'production' : 'sandbox']);
Expand Down Expand Up @@ -307,6 +309,7 @@ public function saveSettings(&$errors = [])
$this->configurationAdapter->updateValue(Config::MOLLIE_SEND_ORDER_CONFIRMATION, $mollieOrderConfirmationSand);
$this->configurationAdapter->updateValue(Config::MOLLIE_IFRAME, $mollieIFrameEnabled);
$this->configurationAdapter->updateValue(Config::MOLLIE_SINGLE_CLICK_PAYMENT, $mollieSingleClickPaymentEnabled);
$this->configurationAdapter->updateValue(Config::MOLLIE_ERROR_LOGGING, $mollieErrorLoggingEnabled);
$this->configurationAdapter->updateValue(Config::MOLLIE_IMAGES, $mollieImages);
$this->configurationAdapter->updateValue(Config::MOLLIE_SHOW_RESEND_PAYMENT_LINK, $showResentPayment);
$this->configurationAdapter->updateValue(Config::MOLLIE_ISSUERS, $mollieIssuers);
Expand Down
29 changes: 29 additions & 0 deletions upgrade/Upgrade-6.2.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Mollie https://www.mollie.nl
*
* @author Mollie B.V. <info@mollie.nl>
* @copyright Mollie B.V.
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md
*
* @see https://github.com/mollie/PrestaShop
*/

use Mollie\Adapter\ConfigurationAdapter;
use Mollie\Config\Config;
use Mollie\Utility\PsVersionUtility;

if (!defined('_PS_VERSION_')) {
exit;
}

function upgrade_module_6_2_0(Mollie $module): bool
{
/** @var ConfigurationAdapter $configuration */
$configuration = $module->getService(ConfigurationAdapter::class);

$configuration->updateValue(Config::MOLLIE_ERROR_LOGGING['sandbox'], 0);
$configuration->updateValue(Config::MOLLIE_ERROR_LOGGING['production'], 0);

return true;
}
35 changes: 35 additions & 0 deletions views/templates/admin/mollie-error-logger-modal.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{**
* Mollie https://www.mollie.nl
*
* @author Mollie B.V. <info@mollie.nl>
* @copyright Mollie B.V.
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md
*
* @see https://github.com/mollie/PrestaShop
* @codingStandardsIgnoreStart
*}
<!-- Modal -->
<div class="modal fade" id="errorLoggingModal" tabindex="-1" role="dialog" aria-labelledby="errorLoggingModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="errorLoggingModalTitle" style="font-weight: 600;">{l s='Error and Logging Information Sharing Consent' mod='mollie'}</h3>
</div>
<div class="modal-body">
<p class="h4">{l s='To provide you with a better experience and improve our services, we would like to collect error and logging information from your device. This information will help us identify and fix any issues you may encounter while using our application.' mod='mollie'}</p>
<p class="h4" style="font-weight: 600;">{l s='The error and logging information may include:' mod='mollie'}</p>
<ul class="h4">
<li>{l s='Error messages and the request code.' mod='mollie'}</li>
<li>{l s='Device information (such as device model, operating system version)' mod='mollie'}</li>
<li>{l s='Application version' mod='mollie'}</li>
<li>{l s='Time and date of the error occurrence' mod='mollie'}</li>
</ul>
<br>
<p class="h4">{l s='By granting consent, you agree to allow us to collect and analyze this information. Rest assured, all data will be treated in accordance with our privacy policy and will only be used for the purpose of improving our applications performance and stability.' mod='mollie'}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{l s='Close' mod='mollie'}</button>
</div>
</div>
</div>
</div>
14 changes: 14 additions & 0 deletions views/templates/admin/mollie_error_logging_info.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{**
* Mollie https://www.mollie.nl
*
* @author Mollie B.V. <info@mollie.nl>
* @copyright Mollie B.V.
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md
*
* @see https://github.com/mollie/PrestaShop
* @codingStandardsIgnoreStart
*}
<a data-toggle="modal" data-target="#errorLoggingModal" href="#"
target="_blank"
rel="noopener noreferrer"
>

0 comments on commit c633438

Please sign in to comment.