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

Enhancements and Refactoring #13

Merged
merged 6 commits into from
Dec 27, 2023
Merged

Enhancements and Refactoring #13

merged 6 commits into from
Dec 27, 2023

Conversation

butschster
Copy link
Member

@butschster butschster commented Dec 13, 2023

We're thrilled to announce a significant update to the Sentry-Bridge package. This update focuses on refining the codebase and introducing some highly requested features. Let's dive into the details:

More Control with Configuration

You can now set up your Sentry settings using environment variables or a config file. This includes your Sentry DSN, sample rates, whether to send default personally identifiable information (PII), and details about your environment and release version.

Via env variables

  • SENTRY_DSN: Specify your Sentry Data Source Name (DSN).
  • SENTRY_SAMPLE_RATE: Define the rate at which to sample events (e.g., 0.4).
  • SENTRY_TRACES_SAMPLE_RATE: Set the rate for tracing samples (e.g., 1.0).
  • SENTRY_SEND_DEFAULT_PII: Choose whether to send default personally identifiable information (true/false).
  • SENTRY_ENVIRONMENT: Set the environment (e.g., 'develop'). You can alternatively use APP_ENV.
  • SENTRY_RELEASE: Define the release version (e.g., '1.0.0'). Alternatively, use APP_VERSION.
SENTRY_DSN=http://...
SENTRY_SAMPLE_RATE=0.4
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_SEND_DEFAULT_PII=false

SENTRY_ENVIRONMENT=develop
SENTRY_RELEASE=1.0.0
// or
APP_ENV=develop 
APP_VERSION=1.0.0

Via config file

Offers similar settings as environment variables, with the added flexibility of a PHP array format for more complex configurations.

// config/sentry.php

return [
  'dsn' => 'http://...',
  'environment' => 'develop',
  'release' => '1.0.0',
  'sample_rate' => 1.0,
  'traces_sample_rate' => null,
  'send_default_pii' => true,
];

Custom Integrations Made Easy

The update introduces a streamlined way to register application-specific integrations via Spiral\Sentry\Bootloader\ClientBootloader. This makes it straightforward to add custom functionalities tailored to your application's needs.

Example of registering a custom integration:

use Spiral\Sentry\Bootloader\ClientBootloader;

public function init(ClientBootloader $sentry): void
{
    $sentry->addIntegration(new ExceptionContextIntegration());
}

Advanced Container Bindings

For developers seeking deeper integration and control, we've introduced new container bindings:

  • Sentry\Options: A configuration container for fine-tuning Sentry client settings.
  • Sentry\State\HubInterface: Provides access to Sentry's state and context management.
  • Sentry\ClientInterface: Facilitates direct interactions with the Sentry client.

These bindings offer granular control over the Sentry client, catering to advanced use cases.

Enhanced Request Integrations

We've improved how Sentry interacts with HTTP requests. The package now includes a more sophisticated integration using Sentry\Integration\RequestIntegration. This enhancement ensures that Sentry captures comprehensive information about application requests.

Moreover, we've added the Spiral\Sentry\Http\SetRequestIpMiddleware. This middleware is crucial for collecting user IP addresses when send_default_pii is enabled. It's an optional but powerful feature for those needing detailed user insights.

@butschster butschster added the enhancement New feature or request label Dec 13, 2023
@butschster butschster self-assigned this Dec 13, 2023
@butschster butschster marked this pull request as ready for review December 14, 2023 06:21
@butschster butschster changed the title Feature/code refactoring Code refactoring Dec 14, 2023
Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Attention: 30 lines in your changes are missing coverage. Please review.

Comparison is base (7f58855) 55.73% compared to head (08ab2df) 64.96%.
Report is 1 commits behind head on 2.0.

Files Patch % Lines
src/Http/SetRequestIpMiddleware.php 0.00% 9 Missing ⚠️
src/Bootloader/ClientBootloader.php 88.40% 8 Missing ⚠️
src/Client.php 37.50% 5 Missing ⚠️
src/Bootloader/SentryReporterBootloader.php 0.00% 4 Missing ⚠️
src/Http/RequestScope.php 20.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.0      #13      +/-   ##
============================================
+ Coverage     55.73%   64.96%   +9.23%     
- Complexity       24       51      +27     
============================================
  Files             6        9       +3     
  Lines            61      157      +96     
============================================
+ Hits             34      102      +68     
- Misses           27       55      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@butschster butschster changed the title Code refactoring Enhancements and Refactoring Dec 14, 2023
@butschster butschster merged commit 7a42ffc into 2.0 Dec 27, 2023
7 checks passed
@butschster butschster deleted the feature/code-refactoring branch December 27, 2023 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant