Skip to content

Commit

Permalink
View if requirements for extension to function correcly have been met
Browse files Browse the repository at this point in the history
  • Loading branch information
tonning committed May 10, 2024
1 parent f8a1121 commit 116cd41
Show file tree
Hide file tree
Showing 12 changed files with 37,294 additions and 15 deletions.
3 changes: 0 additions & 3 deletions mix-manifest.json

This file was deleted.

101 changes: 101 additions & 0 deletions public/css/backend.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* Stylesheet for sentry */
.sentry-relative {
position: relative
}
.sentry-flex {
display: flex
}
.sentry-h-2 {
height: 0.5rem
}
.sentry-w-2 {
width: 0.5rem
}
.sentry-min-w-0 {
min-width: 0px
}
.sentry-flex-auto {
flex: 1 1 auto
}
.sentry-flex-none {
flex: none
}
.sentry-items-center {
align-items: center
}
.sentry-gap-x-2 {
-moz-column-gap: 0.5rem;
column-gap: 0.5rem
}
.sentry-gap-x-2\.5 {
-moz-column-gap: 0.625rem;
column-gap: 0.625rem
}
.sentry-gap-x-3 {
-moz-column-gap: 0.75rem;
column-gap: 0.75rem
}
.sentry-space-x-4 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)))
}
.sentry-divide-y > :not([hidden]) ~ :not([hidden]) {
--tw-divide-y-reverse: 0;
border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
border-bottom-width: calc(1px * var(--tw-divide-y-reverse))
}
.sentry-truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap
}
.sentry-rounded-full {
border-radius: 9999px
}
.sentry-bg-current {
background-color: currentColor
}
.sentry-bg-gray-100\/10 {
background-color: rgb(243 244 246 / 0.1)
}
.sentry-p-1 {
padding: 0.25rem
}
.sentry-p-4 {
padding: 1rem
}
.sentry-text-sm {
font-size: 0.875rem;
line-height: 1.25rem
}
.sentry-text-xs {
font-size: 0.75rem;
line-height: 1rem
}
.sentry-font-semibold {
font-weight: 600
}
.sentry-leading-5 {
line-height: 1.25rem
}
.sentry-leading-6 {
line-height: 1.5rem
}
.sentry-text-gray-400 {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity))
}
.sentry-text-gray-700 {
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity))
}
.sentry-text-green-500 {
--tw-text-opacity: 1;
color: rgb(34 197 94 / var(--tw-text-opacity))
}
.sentry-text-red-500 {
--tw-text-opacity: 1;
color: rgb(239 68 68 / var(--tw-text-opacity))
}

37,090 changes: 37,089 additions & 1 deletion public/js/sentry.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"/js/sentry.js": "/js/sentry.js?id=91c50c4cdd5f0e09bd8df0dab3f38c78",
"/css/backend.css": "/css/backend.css?id=3e95d554899620e020a48f44a32c92da"
}
File renamed without changes.
8 changes: 0 additions & 8 deletions resources/views/backend.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
dsn: "{{ config('sentry.dsn') }}",
environment: "{{ app()->environment() }}",
beforeSend(event, hint) {
// Check if it is an exception, and if so, show the report dialog
if (event.exception && event.event_id) {
Sentry.showReportDialog({ eventId: event.event_id });
}
return event;
},
integrations: [
Sentry.feedbackIntegration({
// Additional SDK configuration goes in here, for example:
Expand Down
27 changes: 27 additions & 0 deletions resources/views/settings/peripherals/check-requirements.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@push('styles')
<link rel="stylesheet" href="{{ mix('css/backend.css', 'vendor/sentry') }}">
@endpush

<x-fab::lists.two-column title="Requirements for extension to function correctly">
<ul role="list" class="sentry-divide-y sentry-divide-gray/5">
@foreach($this->requirements() as $requirement)
<li class="sentry-relative sentry-flex sentry-items-center sentry-space-x-4 sentry-p-4">
<div class="sentry-min-w-0 sentry-flex-auto">
<div class="sentry-flex sentry-items-center sentry-gap-x-3">
<div class="sentry-flex-none sentry-rounded-full sentry-p-1 {{ $requirement->passed() ? 'sentry-text-green-500' : 'sentry-text-red-500' }} sentry-bg-gray-100/10">
<div class="sentry-h-2 sentry-w-2 sentry-rounded-full sentry-bg-current"></div>
</div>
<h2 class="sentry-min-w-0 sentry-text-sm sentry-font-semibold sentry-leading-6 sentry-text-gray-700">
<span class="sentry-truncate">{{ $requirement->title }}</span>
</h2>
</div>
@unless($requirement->passed())
<div class="sentry-flex sentry-items-center sentry-gap-x-2.5 sentry-text-xs sentry-leading-5 sentry-text-gray-400">
<p class="sentry-truncate">{{ $requirement->failed }}</p>
</div>
@endunless
</div>
</li>
@endforeach
</ul>
</x-fab::lists.two-column>
9 changes: 8 additions & 1 deletion src/SentryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Astrogoat\Sentry;

use Livewire\Livewire;
use Astrogoat\Sentry\Middleware\AddAdditionalSentryInfo;
use Astrogoat\Sentry\Settings\SentrySettings;
use Helix\Lego\Apps\App;
Expand All @@ -12,6 +13,7 @@
use Illuminate\Routing\Router;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Astrogoat\Sentry\Settings\Peripherals\CheckRequirements;

class SentryServiceProvider extends PackageServiceProvider
{
Expand All @@ -30,6 +32,7 @@ public function registerApp(App $app)
->includeBackendViews(function (IncludeBackendViews $backendViews) {
return $backendViews->addToHead('sentry::backend');
})
->publishOnInstall(['sentry-assets'])
->backendRoutes(__DIR__.'/../routes/backend.php')
->frontendRoutes(__DIR__.'/../routes/frontend.php');
}
Expand All @@ -50,10 +53,14 @@ public function bootingPackage()
__DIR__.'/../public' => public_path('vendor/sentry/'),
], 'sentry-assets');
}

Livewire::component('astrogoat.sentry.settings.peripherals.check-requirements', CheckRequirements::class);
}

public function configurePackage(Package $package): void
{
$package->name('sentry')->hasConfigFile()->hasViews();
$package->name('sentry')
->hasConfigFile()
->hasViews();
}
}
21 changes: 21 additions & 0 deletions src/Settings/Peripherals/CheckRequirements.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Astrogoat\Sentry\Settings\Peripherals;

use Helix\Lego\Settings\Peripherals\Peripheral;

class CheckRequirements extends Peripheral
{
public function requirements(): array
{
return [
Requirement::make(title: 'DNS', failed: 'A DNS configuration must be defined in "config/sentry.php".')
->passesWhen(filled(config('sentry.dsn'))),
];
}

public function render()
{
return view('sentry::settings.peripherals.check-requirements');
}
}
35 changes: 35 additions & 0 deletions src/Settings/Peripherals/Requirement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Astrogoat\Sentry\Settings\Peripherals;

use Closure;

readonly class Requirement
{
readonly bool|Closure $passes;

public function __construct(public string $title, public string $failed)
{
}

public static function make(string $title, string $failed)
{
return new Requirement($title, $failed);
}

public function passesWhen(bool|Closure $passes): static
{
$this->passes = $passes;

return $this;
}

public function passed(): bool
{
if (is_callable($this->passes)) {
return call_user_func($this->passes);
}

return $this->passes;
}
}
5 changes: 5 additions & 0 deletions src/Settings/SentrySettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
namespace Astrogoat\Sentry\Settings;

use Helix\Lego\Settings\AppSettings;
use Astrogoat\Sentry\Settings\Peripherals\CheckRequirements;

class SentrySettings extends AppSettings
{
protected array $peripherals = [
CheckRequirements::class,
];

public function description(): string
{
return 'Don’t just observe. Take action. The only app monitoring platform built for developers that gets to the root cause for every issue.';
Expand Down
6 changes: 4 additions & 2 deletions webpack.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ const mix = require('laravel-mix');
*/

mix
// .postCss('resources/css/sentry.css', 'public/css', [require("tailwindcss")])
.js('resources/js/sentry.js', 'public/js')
.postCss('resources/css/backend.css', 'css', [require("tailwindcss")])
.js('resources/js/sentry.js', 'js')
.version()
.setPublicPath('public/');

0 comments on commit 116cd41

Please sign in to comment.