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

Add max_breadcrumbs config option #496

Merged
merged 1 commit into from
Oct 24, 2022
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Changelog
* Added support for Monolog 3.0
[#489](https://github.com/bugsnag/bugsnag-laravel/pull/489)

* Add `max_breadcrumbs` config option for configuring the maximum number of breadcrumbs to attach to a report
[#496](https://github.com/bugsnag/bugsnag-laravel/pull/496)

## 2.24.0 (2022-05-20)

### Enhancements
Expand Down
12 changes: 12 additions & 0 deletions config/bugsnag.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,16 @@
*/

'feature_flags' => [],

/*
|--------------------------------------------------------------------------
| Max breadcrumbs
|--------------------------------------------------------------------------
|
| The maximum number of breadcrumbs to send with a report.
|
| This should be an integer between 0-100 (inclusive).
*/

'max_breadcrumbs' => null,
];
4 changes: 4 additions & 0 deletions src/BugsnagServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ public function register()
$client->addFeatureFlags($featureFlags);
}

if (isset($config['max_breadcrumbs'])) {
$client->setMaxBreadcrumbs($config['max_breadcrumbs']);
}

return $client;
});

Expand Down
16 changes: 16 additions & 0 deletions tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,20 @@ public function testFeatureFlagsAreNotSetWhenNotAnArray()

$this->assertSame([], $actual);
}

public function testMaxBreadcrumbsCanBeSetFromConfig()
{
/** @var \Illuminate\Config\Repository $laravelConfig */
$laravelConfig = $this->app->config;
$bugsnagConfig = $laravelConfig->get('bugsnag');
$bugsnagConfig['max_breadcrumbs'] = 73;

$laravelConfig->set('bugsnag', $bugsnagConfig);

/** @var Client $client */
$client = $this->app->make(Client::class);

$this->assertInstanceOf(Client::class, $client);
$this->assertSame(73, $client->getMaxBreadcrumbs());
}
}