Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check is enabled in send massage #24

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

wirwolf
Copy link

@wirwolf wirwolf commented Mar 6, 2018

If sentry module disabled and i call \Yii::$app->sentry->captureMessage

Exception 'Error' with message 'Call to a member function captureMessage() on array'

in /var/www/html/vendor/mito/yii2-sentry/src/Component.php:141

Copy link
Collaborator

@nkovacs nkovacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I've left some comments.

@@ -137,16 +143,28 @@ private function registerAssets()

public function captureMessage($message, $params, $levelOrOptions = [], $stack = false, $vars = null)
{
if (!$this->enabled) {
Yii::trace(Json::encode([$message, $params, $levelOrOptions]), __CLASS__);
Copy link
Collaborator

@nkovacs nkovacs Mar 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yii::trace is deprecated, please use Yii::debug.

Copy link
Author

@wirwolf wirwolf Mar 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All those who use Yii2.0.13 will not be able to use this extension. I propose to correct this problem, and only then do support 2.0.14

@@ -106,7 +112,7 @@ private function setRavenClient()
} elseif (!is_object($this->client) || $this->client instanceof Closure) {
$this->client = Yii::createObject($this->client);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this trailing whitespace please.

@@ -137,16 +143,28 @@ private function registerAssets()

public function captureMessage($message, $params, $levelOrOptions = [], $stack = false, $vars = null)
{
if (!$this->enabled) {
Yii::trace(Json::encode([$message, $params, $levelOrOptions]), __CLASS__);
return '-1';
Copy link
Collaborator

@nkovacs nkovacs Mar 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captureMessage normally returns the event id as a string, but it can also return null according to its doc.

We should also return null if the component is not enabled.

return $this->client->captureMessage($message, $params, $levelOrOptions, $stack, $vars);
}

public function captureException($exception, $culpritOrOptions = null, $logger = null, $vars = null)
{
if (!$this->enabled) {
Yii::trace(Json::encode([$message, $params, $levelOrOptions]), __CLASS__);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 there is no $message, $params and $levelOrOptions variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants