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

fixes #47 support workflows, thanks for Microsoft the old webhook is going to be abolished #49

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/Dispatcher/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public static function send(string $url, array $body, $proxy, string $method = '
{
$client = new Client();
$result = $client->request($method, $url, [
'headers' => [
'Content-Type' => 'application/json',
],
'proxy' => $proxy,
'connect_timeout' => 5.0,
'timeout' => 5.0,
Expand Down
106 changes: 60 additions & 46 deletions src/MicrosoftTeams/ExceptionOccurredCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,68 @@ public function __construct($exception, array $exceptionContext = [])
public function getCard()
{
return [
'@type' => 'MessageCard',
'@context' => 'http://schema.org/extensions',
'summary' => config('laravel_alert_notifications.microsoft_teams.cardSubject'),
'themeColor' => config('laravel_alert_notifications.themeColor'),
'title' => config('laravel_alert_notifications.cardSubject'),
'sections' => [
'type' => 'message',
'attachments' => [
[
'activityTitle' => config('laravel_alert_notifications.microsoft_teams.cardSubject'),
'activitySubtitle' => 'Error has occurred on '.config('app.name').' - '.config('app.name'),
'activityImage' => '',
'facts' => [
[
'name' => 'Environment:',
'value' => config('app.env'),
'contentType' => 'application/vnd.microsoft.card.adaptive',
'contentUrl' => null,
'content' => [
'\$schema' => 'http://adaptivecards.io/schemas/adaptive-card.json',
'type' => 'AdaptiveCard',
'version' => '1.4',
'accentColor' => 'bf0000',
'body' => [
[
'type' => 'TextBlock',
'text' => config('laravel_alert_notifications.microsoft_teams.cardSubject'),
'id' => 'title',
'size' => 'large',
'weight' => 'bolder',
'color' => 'accent',
],
[
'type' => 'FactSet',
'facts' => [
[
'title' => 'Environment:',
'value' => config('app.env'),
],
[
'title' => 'Server:',
'value' => Request::server('SERVER_NAME'),
],
[
'title' => 'Request Url:',
'value' => Request::fullUrl(),
],
[
'title' => 'Exception:',
'value' => get_class($this->exception),
],
[
'title' => 'Message:',
'value' => $this->exception->getMessage(),
],
[
'title' => 'Exception Code:',
'value' => $this->exception->getCode(),
],
[
'title' => 'In File:',
'value' => $this->exception->getFile() .' on line '.$this->exception->getLine(),
],
],
'id' => 'acFactSet',
],
[
'type' => 'CodeBlock',
'codeSnippet' => $this->exception->getTraceAsString(),
'fontType' => 'monospace',
'wrap' => true,
],
],
[
'name' => 'Server:',
'value' => Request::server('SERVER_NAME'),
],
[
'name' => 'Request Url:',
'value' => Request::fullUrl(),
],
[
'name' => 'Exception:',
'value' => get_class($this->exception),
],
[
'name' => 'Message:',
'value' => $this->exception->getMessage(),
],
[
'name' => 'Exception Code:',
'value' => $this->exception->getCode(),
],
[
'name' => 'In File:',
'value' => '<b style="color:red;">'
.$this->exception->getFile()
.' on line '.$this->exception->getLine().'</b>',
],
[
'name' => 'Stack Trace:',
'value' => '<pre>'.$this->exception->getTraceAsString().'</pre>',
],
[
'name' => 'Context:',
'value' => '<pre>$context = '.var_export($this->exceptionContext, true).';</pre>',
'msteams' => [
'width' => 'Full',
],
],
],
Expand Down
Loading