Skip to content
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
18 changes: 0 additions & 18 deletions .github/workflows/phpstan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@ permissions:
contents: read

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

- name: Setup PHP
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4```
with:
php-version: '8.4'

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist

- name: Run script
run: vendor/bin/phpstan analyse

phpstan-agent:
name: PHPStan (agent)
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
->setFinder(
PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/agent/src',
])
);
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ _Bad software is everywhere, and we're tired of it. Sentry is on a mission to he

### Install

Install the agent using [Composer](https://getcomposer.org/).
Install the agent alongside the [PHP SDK](https://github.com/getsentry/sentry-php) using [Composer](https://getcomposer.org/).

```bash
composer require sentry/sentry-agent
composer require sentry/sentry sentry/sentry-agent
```

### Configuration

The agent is configured as a custom HTTP client for the [PHP](https://github.com/getsentry/sentry-php) (also [Symfony](https://github.com/getsentry/sentry-symfony) & [Laravel](https://github.com/getsentry/sentry-laravel)) SDKs.
Use the SDK-provided agent client as the custom HTTP client for the [PHP](https://github.com/getsentry/sentry-php) (also [Symfony](https://github.com/getsentry/sentry-symfony) & [Laravel](https://github.com/getsentry/sentry-laravel)) SDKs.

```php
use Sentry\Agent\Transport\AgentClientBuilder;

Sentry\init([
'dsn' => '___PUBLIC_DSN___',
'http_client' => new \Sentry\Agent\Transport\AgentClient(),
'http_client' => AgentClientBuilder::create()->getClient(),
]);
```

Expand Down
2 changes: 1 addition & 1 deletion agent/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clue/mq-react": "^1.6",
"react/http": "^1.11",
"react/socket": "^1.16",
"sentry/sentry": "^4.19.1"
"sentry/sentry": "^4.26.0"
},
"autoload": {
"psr-4": {
Expand Down
36 changes: 21 additions & 15 deletions agent/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified bin/sentry-agent
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/sentry-agent.sig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
D8B94BAD7E5B61D6310089C043AA6B9A3BEFD4FB4B41752004863AB4B822A2A43B49CC2587FB83446D8AA5AC8FE6A5AA6095D8DC932DE00334D1359F70C1D9A8
F3CE4B37DC4AC5C3890CC9497A95351E29641DA3BAD0699B727A8D77002C6B36913EB82B55ACB1BA683D27CBAF123007D2CE68AA10773CF4012292D38E5F1904
23 changes: 3 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,20 @@
],
"require": {
"php": "^7.2|^8",
"ext-json": "*",
"sentry/sentry": "^4.19.1"
Comment thread
cursor[bot] marked this conversation as resolved.
},
"autoload": {
"psr-4": {
"Sentry\\Agent\\": "src/"
}
"ext-json": "*"
Comment on lines 14 to +15
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The composer.json for sentry/sentry-agent is missing a required dependency on sentry/sentry, which will cause a fatal error when AgentClientBuilder is not found.
Severity: CRITICAL

Suggested Fix

Add "sentry/sentry": "^4.19.1" back to the require section of the composer.json file. This will ensure that Composer correctly installs the sentry/sentry package, making the AgentClientBuilder class available.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: composer.json#L14-L15

Potential issue: The `composer.json` for the `sentry/sentry-agent` package omits a
required dependency on `sentry/sentry`. The `AgentClientBuilder` class, essential for
using the agent, was moved to the `sentry/sentry` package. Without this declared
dependency, Composer will not automatically install `sentry/sentry`. This will lead to a
fatal "Class not found" error for `AgentClientBuilder` at runtime if a user only
installs the `sentry/sentry-agent` package, breaking the package's functionality upon
installation.

Did we get this right? 👍 / 👎 to inform future reviews.

},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.70",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^8.5|^9.6"
},
"autoload-dev": {
"psr-4": {
"Sentry\\Agent\\Tests\\": "tests/"
}
"friendsofphp/php-cs-fixer": "^3.70"
},
"bin": [
"bin/sentry-agent"
],
"scripts": {
"check": [
"@cs-check",
"@phpstan",
"@tests"
"@cs-check"
],
"tests": "vendor/bin/phpunit --verbose",
"cs-check": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
"cs-fix": "vendor/bin/php-cs-fixer fix --verbose --diff",
"phpstan": "vendor/bin/phpstan analyse",
"build": "scripts/build.sh"
},
"config": {
Expand Down
10 changes: 7 additions & 3 deletions examples/send.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

declare(strict_types=1);

require_once __DIR__ . '/../vendor/autoload.php';
use Sentry\Agent\Transport\AgentClientBuilder;

require_once __DIR__ . '/../agent/vendor/autoload.php';

Sentry\init([
'dsn' => '___PUBLIC_DSN___',
'http_client' => new Sentry\Agent\Transport\AgentClient(),
'dsn' => getenv('SENTRY_DSN') ?: 'https://public@example.com/1',
'http_client' => AgentClientBuilder::create()
->disableFallbackClient()
->getClient(),
]);

$startTime = microtime(true);
Expand Down
4 changes: 0 additions & 4 deletions phpstan.neon

This file was deleted.

101 changes: 0 additions & 101 deletions src/Transport/AgentClient.php

This file was deleted.

Loading