Skip to content

Commit 8a5598e

Browse files
committed
Merge branch 'release/2.0.0'
2 parents 0c4ad1c + b1a686b commit 8a5598e

File tree

33 files changed

+467
-190
lines changed

33 files changed

+467
-190
lines changed

.github/workflows/php.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: PHPCS
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@master
8+
- name: PHPCS
9+
run: docker run --rm -v $PWD:/code:ro domw/phpcs phpcs --colors --standard=Magento2 --report=full,summary,gitblame --extensions=php,phtml ./

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

Block/Adminhtml/System/Config/Button.php

100644100755
File mode changed.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace JustBetter\Sentry\Block\Adminhtml\System\Config;
4+
5+
use Magento\Config\Block\System\Config\Form\Field;
6+
use Magento\Framework\Data\Form\Element\AbstractElement;
7+
8+
class DeploymentConfigInfo extends Field
9+
{
10+
/**
11+
* @var string
12+
*/
13+
protected $_template = 'system/config/deployment-config-info.phtml';
14+
15+
public function render(AbstractElement $element)
16+
{
17+
return $this->_toHtml();
18+
}
19+
}

CHANGELOG.md

100644100755
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
CHANGELOG
22

3+
2019-11-19 - 2.0.0
4+
5+
* Merged PR (https://github.com/justbetter/magento2-sentry/pull/29) thanks to https://github.com/michielgerritsen
6+
* Merged PR (https://github.com/justbetter/magento2-sentry/pull/26) thanks to https://github.com/JosephMaxwell
7+
* Merged PR (https://github.com/justbetter/magento2-sentry/pull/27) thanks to https://github.com/DominicWatts
8+
39
2019-08-29 - 0.8.0
410

511
* Merged PR (https://github.com/justbetter/magento2-sentry/pull/24) thanks to https://github.com/kyriog
612
* Merged PR (https://github.com/justbetter/magento2-sentry/pull/22) thanks to https://github.com/fredden
713
* Merged PR (https://github.com/justbetter/magento2-sentry/pull/21) thanks to https://github.com/erikhansen
8-
14+
915
2019-06-19 - 0.7.2
1016

1117
* Reverted async attribute

Controller/Adminhtml/Test/Sentry.php

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public function execute()
8181
if ($sentryDomain && is_dir($composerBin)) {
8282
try {
8383
$result['status'] = true;
84-
$result['content'] = nl2br(shell_exec($composerBin . 'sentry test ' . escapeshellarg($sentryDomain) . ' -v'));
84+
$result['content'] = nl2br(shell_exec(
85+
$composerBin . 'sentry test ' . escapeshellarg($sentryDomain) . ' -v'
86+
));
8587
} catch (\Exception $e) {
8688
$result['content'] = $e->getMessage();
8789
$this->logger->critical($e);

Helper/Data.php

100644100755
Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\Helper\AbstractHelper;
1111
use Magento\Framework\Exception\LocalizedException;
1212
use Magento\Framework\App\ProductMetadataInterface;
13+
use Magento\Framework\App\DeploymentConfig;
1314

1415
class Data extends AbstractHelper
1516
{
@@ -25,12 +26,9 @@ class Data extends AbstractHelper
2526
*/
2627
protected $configKeys = [
2728
'domain',
28-
'enabled',
2929
'log_level',
3030
'mage_mode_development',
3131
'environment',
32-
'enable_script_tag',
33-
'script_tag_placement',
3432
];
3533

3634
/**
@@ -50,17 +48,39 @@ class Data extends AbstractHelper
5048
* @param StoreManagerInterface $storeManager
5149
* @param State $appState
5250
*/
53-
public function __construct(Context $context, StoreManagerInterface $storeManager, State $appState, ProductMetadataInterface $productMetadataInterface
51+
public function __construct(
52+
Context $context,
53+
StoreManagerInterface $storeManager,
54+
State $appState,
55+
ProductMetadataInterface $productMetadataInterface,
56+
DeploymentConfig $deploymentConfig
5457
) {
5558
$this->storeManager = $storeManager;
5659
$this->appState = $appState;
5760
$this->scopeConfig = $context->getScopeConfig();
5861
$this->productMetadataInterface = $productMetadataInterface;
62+
$this->deploymentConfig = $deploymentConfig;
5963
$this->collectModuleConfig();
6064

6165
parent::__construct($context);
6266
}
6367

68+
/**
69+
* @return mixed
70+
*/
71+
public function getDSN()
72+
{
73+
return $this->config['domain'];
74+
}
75+
76+
/**
77+
* @return mixed
78+
*/
79+
public function getEnvironment()
80+
{
81+
return $this->config['environment'];
82+
}
83+
6484
/**
6585
* @param $field
6686
* @param null $storeId
@@ -90,8 +110,10 @@ public function getGeneralConfig($code, $storeId = null)
90110
*/
91111
public function collectModuleConfig()
92112
{
93-
foreach ($this->configKeys as $key => $value) {
94-
$this->config[ $value ] = $this->getGeneralConfig($value);
113+
$this->config['enabled'] = $this->deploymentConfig->get('sentry') !== null;
114+
115+
foreach ($this->configKeys as $value) {
116+
$this->config[$value] = $this->deploymentConfig->get('sentry/' . $value);
95117
}
96118

97119
return $this->config;
@@ -102,7 +124,11 @@ public function collectModuleConfig()
102124
*/
103125
public function isActive()
104126
{
105-
return (! empty($this->config) && array_key_exists('enabled', $this->config) && $this->config['enabled'] && ($this->isProductionMode() || $this->isOverwriteProductionMode()));
127+
return !empty($this->config)
128+
&& array_key_exists('enabled', $this->config)
129+
&& $this->config['enabled']
130+
&& $this->getDSN()
131+
&& ($this->isProductionMode() || $this->isOverwriteProductionMode());
106132
}
107133

108134
/**
@@ -152,7 +178,7 @@ public function getStore()
152178
*/
153179
public function useScriptTag()
154180
{
155-
return isset($this->config['enable_script_tag']) && $this->config['enable_script_tag'];
181+
return $this->scopeConfig->isSetFlag(static::XML_PATH_SRS . 'enable_script_tag');
156182
}
157183

158184
/**
@@ -161,11 +187,12 @@ public function useScriptTag()
161187
*/
162188
public function showScriptTagInThisBlock($blockName)
163189
{
164-
if (!isset($this->config['script_tag_placement'])) {
190+
$config = $this->getGeneralConfig('script_tag_placement');
191+
if (!$config) {
165192
return false;
166193
}
167194

168-
$name = 'sentry.' . $this->config['script_tag_placement'];
195+
$name = 'sentry.' . $config;
169196

170197
return $name == $blockName;
171198
}

LICENSE

100644100755
File mode changed.

Model/Config/Source/LogLevel.php

100644100755
File mode changed.

Model/Config/Source/ScriptTagPlacement.php

100644100755
File mode changed.

0 commit comments

Comments
 (0)