Skip to content

Commit b8221ef

Browse files
committed
[FIX] - possible fix for failures with area code already set - added proxy to customer session - refactor of setappstate with emulateAreaCode
1 parent 4a815b5 commit b8221ef

File tree

5 files changed

+6
-20
lines changed

5 files changed

+6
-20
lines changed

Helper/Data.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ class Data extends AbstractHelper
4747
* @param StoreManagerInterface $storeManager
4848
* @param State $appState
4949
*/
50-
public function __construct(
51-
Context $context,
52-
StoreManagerInterface $storeManager,
53-
State $appState,
54-
ProductMetadataInterface $productMetadataInterface
50+
public function __construct(Context $context, StoreManagerInterface $storeManager, State $appState, ProductMetadataInterface $productMetadataInterface
5551
) {
5652
$this->storeManager = $storeManager;
5753
$this->appState = $appState;
@@ -111,13 +107,7 @@ public function isActive()
111107
*/
112108
public function isProductionMode()
113109
{
114-
try {
115-
$this->appState->setAreaCode(Area::AREA_GLOBAL);
116-
} catch (LocalizedException $e) {
117-
//intentionally left empty
118-
}
119-
120-
return $this->getAppState() == 'production';
110+
return $this->appState->emulateAreaCode(Area::AREA_GLOBAL, [$this, 'getAppState']) == 'production';
121111
}
122112

123113
/**

Model/SentryLog.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SentryLog extends Monolog
4040
public function __construct(
4141
$name,
4242
Data $data,
43-
Session $customerSession,
43+
Session\Proxy $customerSession,
4444
array $handlers = [],
4545
array $processors = []
4646
) {

Plugin/ExceptionCatcher.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ class ExceptionCatcher
4141
* @param State $state
4242
* @param SentryLog $logger
4343
*/
44-
public function __construct(
45-
Data $data,
46-
Monolog $monolog,
47-
SentryLog $sentryLog
48-
) {
44+
public function __construct(Data $data, Monolog $monolog, SentryLog $sentryLog) {
4945
$this->sentryHelper = $data;
5046
$this->monolog = $monolog;
5147
$this->sentryLog = $sentryLog;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This Magento 2 module integrates the [Sentry sdk](https://github.com/getsentry/s
1414
- Optional you can configure custom error pages in pub/errors. You can use the sentry feedback form and insert here the sentry log ID. The Sentry Log Id is captured in de customer session and can be retrieved in `processor.php`. Soon I'll integrate this in the module.
1515

1616
## Compability
17-
The module is tested on Magento version 2.1.x & 2.2.x with sentry sdk version 1.9.x
17+
The module is tested on Magento version 2.2.x & 2.3.x with sentry sdk version 1.10.x
1818

1919
## Ideas, bugs or suggestions?
2020
Please create a [issue](https://github.com/justbetter/magento2-sentry/issues) or a [pull request](https://github.com/justbetter/magento2-sentry/pulls).

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"require": {
88
"php": ">=7.0",
9-
"sentry/sentry": "^1.9",
9+
"sentry/sentry": "^1.10",
1010
"monolog/monolog": "*",
1111
"magento/framework": "*"
1212
},

0 commit comments

Comments
 (0)