-
Notifications
You must be signed in to change notification settings - Fork 21
Implement ability for users to register custom callbacks via service definition tags. #36
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
base: master
Are you sure you want to change the base?
Conversation
@samdjstevens doesn't seem to work for me 😞 either I'm doing wrong on implementation or It's just not working. |
@PReimers Are you getting any errors, or are you just not seeing the callbacks take affect on bugsnag notifications? Could you post your service class and definition configuration so I could take a look? |
I forked your repo and changed only the in my Symfony project I changed:
src/BrokerStar/CommonBundle/Bugsnag/MetadataCallback.php
src/BrokerStar/CommonBundle/Resources/config/service.yml
by the way how to customize the setUser function? |
@PReimers Your setup looks correct - when an exception is being thrown and reported to Bugsnag, do you see any errors, or is the information just missing from the report when you inspect it on the website? Also, what version of Symfony are you using? I've made a skeleton Symfony app replicating your integration here - which I have verified to be reporting the extra data to Bugsnag on exceptions. Can you scan this and see if there are any differences in your code? I assume that you are enabling the bundle and specifying the API key in your config? |
We do actually have an example apps in https://github.com/bugsnag/bugsnag-symfony/tree/master/example. |
@samdjstevens |
Just to confirm, you are enabling the bundle, setting your API key, and letting the bundle listener trigger the sending to Bugsnag? And when clicking through on the excpetion in Bugsnag, there is no "Installation" tab with the custom data, like this? Can you try downloading my sample project posted above, replacing the api key with yours, and seeing if the extra data is registered? |
@samdjstevens your test project is showing the information 😄 but why is it not shown on my project 🤔 btw. should we move the discussion to another place? (like gitter / slack ...) |
@samdjstevens @GrahamCampbell - This resolves #35 +1 for merging 👍 |
{ | ||
/** | ||
* @param \Bugsnag\Report $report | ||
*/ |
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.
Please add @return void
.
@GrahamCampbell - return tags added. |
Please don't comment any |
Whoops, usually catch those. Removed now. |
hi @GrahamCampbell - anything blocking this PR from merge still? |
Do you have any timescale of when you think this could be merged into master @GrahamCampbell? |
Not yet, sorry. Need to find the time to sit down and give this a detailed review, and try it out. |
Callbacks/UserSettingCallback.php
Outdated
* @param null|\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokens | ||
* @param null|\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $checker | ||
* @param bool $setUser | ||
*/ |
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.
Missing return void
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.
Ping.
BugsnagBundle.php
Outdated
@@ -12,4 +14,16 @@ class BugsnagBundle extends Bundle | |||
* @return string | |||
*/ | |||
const VERSION = '1.0.0'; | |||
|
|||
/** | |||
* {@inheritdoc} |
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.
Please just copy over the description rather than inherit. Makes it easy for a human to read the code and know what it does straight away.
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.
The description here would literally be "Builds the bundle." - is this really helpful? Anyone who isn't already familiar with Symfony, and what this file is for, would not really be looking at it.
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.
A better description would be "Setup the callback registering pass." or something.
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.
Ping.
BugsnagBundle.php
Outdated
@@ -12,4 +14,16 @@ class BugsnagBundle extends Bundle | |||
* @return string | |||
*/ | |||
const VERSION = '1.0.0'; | |||
|
|||
/** | |||
* {@inheritdoc} |
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.
A better description would be "Setup the callback registering pass." or something.
Are you able to squash and rebase please @samdjstevens, and then I will do another review. :) |
Sure - squashed and rebased |
Callbacks/UserSettingCallback.php
Outdated
* @param null|\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokens | ||
* @param null|\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $checker | ||
* @param bool $setUser | ||
*/ |
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.
Ping.
BugsnagBundle.php
Outdated
@@ -12,4 +14,16 @@ class BugsnagBundle extends Bundle | |||
* @return string | |||
*/ | |||
const VERSION = '1.0.0'; | |||
|
|||
/** | |||
* {@inheritdoc} |
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.
Ping.
# service_name: | ||
# class: AppBundle\Directory\ClassName | ||
# arguments: ["@another_service_name", "plain_value", "%parameter_name%"] | ||
|
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.
Please remove the extra blank line.
Requested changes made Edit: Can't see what StyleCI is failing for on this page: https://styleci.io/analyses/8LgvlG |
That link shows a diff, that has the change. |
Callbacks/UserSettingCallback.php
Outdated
@@ -44,6 +45,9 @@ public function __construct( | |||
} | |||
|
|||
/** | |||
* Define a callback to set the currently authenticated user as the user | |||
* on any BugSnag reports that are sent. |
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.
- Bugsnag
Yes, but what is it complaining about? I see no rule violation message or anything |
Yes I can see the diff. The diff shows 4 spaces before the asterisks, which is the same as the other lines. I'm asking what the actual rule violation is as this isn't shown anywhere on the StyleCI page. |
The rule is that there must be phpdoc formatting like that, in between |
Ahhh I see, the diff is the change I need to make, thanks. Patch applied |
protected $setUser; | ||
|
||
/** | ||
* @param null|\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokens |
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.
Please put null
on the right of the other type. :)
*/ | ||
protected $setUser; | ||
|
||
/** |
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.
Please add a description to this doc, similar to the others in the project.
|
||
/** | ||
* Define a callback to set the currently authenticated user as the user | ||
* on any Bugsnag reports that are sent. |
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.
Please change to:
/**
* Define a callback to set the currently authenticated user.
*
* @param \Bugsnag\Report $report
*
* @return void
*/
This is because "short descriptions" cannot span more than 1 line, and we also apply the extra cs constraint that they cannot be longer than 80 characters.
I think I'm going to bow out of this PR - it feels like the review process is endless CS requests that I don't know about. If anyone wants to take this over, please feel free too! |
Thanks for getting it this far, @samdjstevens. I think we can take it over the finish line and ensure that code style requirements are more clear in the future. 👍 |
Hi, any news on this PR? |
This is my attempt at resolving issue #35.
This PR enables custom callbacks to be registered to the Bugsnag
Client
object, by creating a service and tagging it with thebugsnag.callback
name.The service must implement a
registerCallback
method, which is used in the same way as theregisterCallback
method on the Bugsnag client. This method name is definable on a per-service basis, by setting themethod
attribute on the tag.I have also re-factored the existing user setting code in
ClientFactory
to be a callback service included in the bundle.I have made additions to the example apps in the repo to show an example callback service, but have not written any documentation for the new feature as they seem to live separately.
@PReimers - does this implementation solve your use case?