-
Notifications
You must be signed in to change notification settings - Fork 29
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
|
@@ -96,7 +99,10 @@ private function setEnvironmentOptions() | |
} | ||
$this->jsOptions['environment'] = $this->environment; | ||
} | ||
|
||
|
||
/** | ||
* @throws InvalidConfigException | ||
*/ | ||
private function setRavenClient() | ||
{ | ||
if (is_array($this->client)) { | ||
|
@@ -106,7 +112,7 @@ private function setRavenClient() | |
} elseif (!is_object($this->client) || $this->client instanceof Closure) { | ||
$this->client = Yii::createObject($this->client); | ||
} | ||
|
||
if (!is_object($this->client)) { | ||
throw new InvalidConfigException(get_class($this) . '::' . 'client must be an object'); | ||
} | ||
|
@@ -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__); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yii::trace is deprecated, please use Yii::debug. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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__); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 there is no |
||
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); | ||
} | ||
|
||
|
There was a problem hiding this comment.
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.