diff --git a/README.md b/README.md index 435a0f6..50d70e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Rapidez Sentry -This package integrates Sentry Vue into a Rapidez project. +This package integrates Sentry Laravel and Sentry Vue into a Rapidez project. ## Installation @@ -8,33 +8,36 @@ yarn add @sentry/vue --dev composer require rapidez/sentry ``` -You will need to add the following line to your .env: +You will need to add the following lines to your .env: ``` -VITE_SENTRY_DSN=[your sentry DSN url here] +SENTRY_LARAVEL_DSN=___PUBLIC_DSN___ +VITE_SENTRY_DSN="${SENTRY_LARAVEL_DSN}" ``` -Setting your Sentry DSN to be public like this is [safe](https://docs.sentry.io/concepts/key-terms/dsn-explainer/). +You don't need the `VITE_SENTRY_DSN` line if you don't want to use the Sentry Vue package. Note that setting your Sentry DSN to be public like this is [safe](https://docs.sentry.io/concepts/key-terms/dsn-explainer/). -You can also disable this package in your .env by adding: +You can disable the Vue package in your .env by adding: ``` -SENTRY_ENABLED=false +SENTRY_VUE_ENABLED=false ``` ## Configuration -You can publish the config with: +You can publish the (vue-specific) config with: ``` php artisan vendor:publish --tag=rapidez-sentry-config ``` -Some basic configuration settings can also be set in your env, for example: +Some basic configuration settings for Vue can also be set in your env, for example: ``` -SENTRY_SAMPLE_RATE=50 -SENTRY_INTEGRATION_REPLAY=true +SENTRY_VUE_SAMPLE_RATE=50 +SENTRY_VUE_INTEGRATION_REPLAY=true ``` +Check out the [sentry/sentry-laravel readme](https://github.com/getsentry/sentry-laravel) for configuration of the laravel package. + ## License GNU General Public License v3. Please see [License File](LICENSE) for more information. diff --git a/composer.json b/composer.json index e5e6bd5..1af580b 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "prefer-stable": true, "require": { "php": "^8.1|^8.2|^8.3", - "rapidez/core": "^1.0|^2.0" + "rapidez/core": "^1.0|^2.0", + "sentry/sentry-laravel": "^4.7" }, "autoload": { "psr-4": { diff --git a/config/rapidez/sentry-vue.php b/config/rapidez/sentry-vue.php new file mode 100644 index 0000000..696b678 --- /dev/null +++ b/config/rapidez/sentry-vue.php @@ -0,0 +1,33 @@ + [ + 'enabled' => env('SENTRY_VUE_ENABLED', true), + + // Amount of errors to be logged to sentry (1.00 = 100%) + 'sampleRate' => env('SENTRY_VUE_SAMPLE_RATE', 100) / 100, + ], + + // For integrations, see: https://docs.sentry.io/platforms/javascript/guides/vue/configuration/integrations/ + // If you want to add extra configuration to the constructor of an integration, change the `true` to an array like so: + // 'replay' => [ + // 'maskAllText' => true, + // 'blockAllMedia' => true, + // ], + 'integrations' => [ + 'browserProfiling' => env('SENTRY_VUE_INTEGRATION_BROWSER_PROFILING', false), + 'browserTracing' => env('SENTRY_VUE_INTEGRATION_BROWSER_TRACING', false), + 'captureConsole' => env('SENTRY_VUE_INTEGRATION_CAPTURE_CONSOLE', false), + 'contextLines' => env('SENTRY_VUE_INTEGRATION_CONTEXT_LINES', false), + 'debug' => env('SENTRY_VUE_INTEGRATION_DEBUG', false), + 'extraErrorData' => env('SENTRY_VUE_INTEGRATION_EXTRA_ERROR_DATA', false), + 'httpClient' => env('SENTRY_VUE_INTEGRATION_HTTP_CLIENT', false), + 'moduleMetadata' => env('SENTRY_VUE_INTEGRATION_MODULE_METADATA', false), + 'rewriteFrames' => env('SENTRY_VUE_INTEGRATION_REWRITE_FRAMES', false), + 'replay' => env('SENTRY_VUE_INTEGRATION_REPLAY', false), + 'replayCanvas' => env('SENTRY_VUE_INTEGRATION_REPLAY_CANVAS', false), + 'reportingObserver' => env('SENTRY_VUE_INTEGRATION_REPORTING_OBSERVER', false), + 'sessionTiming' => env('SENTRY_VUE_INTEGRATION_SESSION_TIMING', false), + ], +]; diff --git a/config/rapidez/sentry.php b/config/rapidez/sentry.php deleted file mode 100644 index 675bf2c..0000000 --- a/config/rapidez/sentry.php +++ /dev/null @@ -1,33 +0,0 @@ - [ - 'enabled' => env('SENTRY_ENABLED', true), - - // Amount of errors to be logged to sentry (1.00 = 100%) - 'sampleRate' => env('SENTRY_SAMPLE_RATE', 100) / 100, - ], - - // For integrations, see: https://docs.sentry.io/platforms/javascript/guides/vue/configuration/integrations/ - // If you want to add extra configuration to the constructor of an integration, change the `true` to an array like so: - // 'replay' => [ - // 'maskAllText' => true, - // 'blockAllMedia' => true, - // ], - 'integrations' => [ - 'browserProfiling' => env('SENTRY_INTEGRATION_BROWSER_PROFILING', false), - 'browserTracing' => env('SENTRY_INTEGRATION_BROWSER_TRACING', false), - 'captureConsole' => env('SENTRY_INTEGRATION_CAPTURE_CONSOLE', false), - 'contextLines' => env('SENTRY_INTEGRATION_CONTEXT_LINES', false), - 'debug' => env('SENTRY_INTEGRATION_DEBUG', false), - 'extraErrorData' => env('SENTRY_INTEGRATION_EXTRA_ERROR_DATA', false), - 'httpClient' => env('SENTRY_INTEGRATION_HTTP_CLIENT', false), - 'moduleMetadata' => env('SENTRY_INTEGRATION_MODULE_METADATA', false), - 'rewriteFrames' => env('SENTRY_INTEGRATION_REWRITE_FRAMES', false), - 'replay' => env('SENTRY_INTEGRATION_REPLAY', false), - 'replayCanvas' => env('SENTRY_INTEGRATION_REPLAY_CANVAS', false), - 'reportingObserver' => env('SENTRY_INTEGRATION_REPORTING_OBSERVER', false), - 'sessionTiming' => env('SENTRY_INTEGRATION_SESSION_TIMING', false), - ], -]; diff --git a/src/Http/ViewComposers/ConfigComposer.php b/src/Http/ViewComposers/ConfigComposer.php index 71fc908..636c0dc 100644 --- a/src/Http/ViewComposers/ConfigComposer.php +++ b/src/Http/ViewComposers/ConfigComposer.php @@ -9,8 +9,8 @@ class ConfigComposer { public function compose(View $view) { - Config::set('frontend.sentry.configuration', config('rapidez.sentry.configuration')); - Config::set('frontend.sentry.enabled', config('rapidez.sentry.configuration.enabled')); - Config::set('frontend.sentry.integrations', config('rapidez.sentry.integrations')); + Config::set('frontend.sentry.configuration', config('rapidez.sentry-vue.configuration')); + Config::set('frontend.sentry.enabled', config('rapidez.sentry-vue.configuration.enabled')); + Config::set('frontend.sentry.integrations', config('rapidez.sentry-vue.integrations')); } } diff --git a/src/SentryServiceProvider.php b/src/SentryServiceProvider.php index cdc0250..dc60c1f 100644 --- a/src/SentryServiceProvider.php +++ b/src/SentryServiceProvider.php @@ -10,13 +10,13 @@ class SentryServiceProvider extends ServiceProvider { public function register() { - $this->mergeConfigFrom(__DIR__.'/../config/rapidez/sentry.php', 'rapidez.sentry'); + $this->mergeConfigFrom(__DIR__.'/../config/rapidez/sentry-vue.php', 'rapidez.sentry-vue'); } public function boot() { $this->publishes([ - __DIR__.'/../config/rapidez/sentry.php' => config_path('rapidez/sentry.php'), + __DIR__.'/../config/rapidez/sentry-vue.php' => config_path('rapidez/sentry-vue.php'), ], 'rapidez-sentry-config'); View::composer('rapidez::layouts.app', ConfigComposer::class);