-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add MS Teams webhook handler #2002
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: main
Are you sure you want to change the base?
Conversation
|
|
||
| if ($this->includeContextAndExtra) { | ||
| $this->normalizerFormatter = new NormalizerFormatter(); | ||
| } |
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.
This is already done in ->includeContextAndExtra()
1e74014 to
953482c
Compare
| return $this->teamsRecord; | ||
| } | ||
|
|
||
| public function getWebhookUrl(): string |
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.
I don't think those getters should exist
| * @author Sébastien Alfaiate <[email protected]> | ||
| * @see https://learn.microsoft.com/adaptive-cards/authoring-cards/getting-started | ||
| */ | ||
| class TeamsRecord |
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.
This class should probably be @internal
| /** | ||
| * @return $this | ||
| */ | ||
| public function includeContextAndExtra(bool $includeContextAndExtra = false): self |
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.
No need to create public methods for that. The constructor should assign its config directly.
| public function getFormatter(): FormatterInterface | ||
| { | ||
| $formatter = parent::getFormatter(); | ||
| $this->teamsRecord->setFormatter($formatter); |
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.
Instead of those hacks to synchronize the formatter in the TeamsRecord helper, I would suggest passing the formatter of the handler as a parameter in getAdaptiveCardPayload instead.
| * @author Sébastien Alfaiate <[email protected]> | ||
| * @see https://learn.microsoft.com/adaptive-cards/authoring-cards/getting-started | ||
| */ | ||
| class TeamsRecord |
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.
This class name is weird to me. This helper is a service creating the payload for the Teams API. It is not the representation of a record (creating confusion with the LogRecord class of the public Monolog API)
| /** | ||
| * Returns MS Teams container style associated with provided level. | ||
| */ | ||
| public function getContainerStyle(Level $level): string |
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.
Those methods should be private as they are only used internally.
1744888 to
c093448
Compare
c093448 to
b7697f8
Compare
|
Hi @stof, Thanks for your review. I think all your comments are fixed now. Please note that my proposal was based on the Slack code, so most of your comments are also applicable to the Slack implementation. |
We are migrating from Slack to Microsoft Teams and we would like to continue receiving log notifications there, as this feature has been extremely useful for our workflow.
I am also planning to submit a PR on Laravel to support this handler if this PR is approved (Laravel already supports the slack handler).
The implementation is inspired from the existing
SlackWebhookHandler.This handler support an additional parameter
toggleFieldswhere we can specify the list of field we want to display using a toggle button (eg: useful for stacktrace)Here is how it looks:
(Note the username and avatar has to be configured when creating the webhook URL)
When we click on the toggle button: