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
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class Component extends \yii\base\Component
* @var \Raven_Client|array Raven client or configuration array used to instantiate one
*/
public $client = [];


/**
* @throws InvalidConfigException
*/
public function init()
{
if (!$this->enabled) {
Expand Down Expand Up @@ -96,7 +99,10 @@ private function setEnvironmentOptions()
}
$this->jsOptions['environment'] = $this->environment;
}


/**
* @throws InvalidConfigException
*/
private function setRavenClient()
{
if (is_array($this->client)) {
Expand All @@ -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.

if (!is_object($this->client)) {
throw new InvalidConfigException(get_class($this) . '::' . 'client must be an object');
}
Expand Down Expand Up @@ -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

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.

return '-1';
}
return $this->client->captureException($exception, $culpritOrOptions, $logger, $vars);
}

public function capture($data, $stack = null, $vars = null)
{
if (!$this->enabled) {
Yii::trace(Json::encode($data), __CLASS__);
return '-1';
}
return $this->client->capture($data, $stack, $vars);
}

Expand Down