Skip to content

Commit

Permalink
Merge pull request #363 from bugsnag/next
Browse files Browse the repository at this point in the history
Release v2.17.0
  • Loading branch information
tomlongridge authored Aug 29, 2019
2 parents a992206 + 0271a22 commit 761e9f9
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ sudo: false
matrix:
include:
- php: 5.5.9
dist: trusty
env:
- GUZZLE_VERSION=^5.3
- LARAVEL_VERSION=5.1.*
- php: 5.5.9
dist: trusty
env:
- GUZZLE_VERSION=^6.0
- LARAVEL_VERSION=5.1.*
- php: 5.5
dist: trusty
env:
- GUZZLE_VERSION=^5.3
- LARAVEL_VERSION=5.1.*
- php: 5.5
dist: trusty
env:
- GUZZLE_VERSION=^6.0
- LARAVEL_VERSION=5.1.*
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
Changelog
=========

## 2.17.0 (2019-08-29)

### Enhancements

* Allow installation on Laravel 6 projects
[#360](https://github.com/bugsnag/bugsnag-laravel/pull/360)
[taylorotwell](https://github.com/taylorotwell)

### Fixes

* Disabled automatic session capturing for Lumen 5.3+ (where `session()` is not available)
[#358](https://github.com/bugsnag/bugsnag-laravel/pull/358)

## 2.16.0 (2019-06-17)

### Enhancements

* Add Laravel/Lumen version string to report and session payloads (device.runtimeVersions)
[#352](https://github.com/bugsnag/bugsnag-laravel/pull/352)

## Fixes
### Fixes

* Changed caching TTL to use DateTime instead.
[#344](https://github.com/bugsnag/bugsnag-laravel/pull/344)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
],
"require": {
"php": ">=5.5",
"illuminate/contracts": "^5.0",
"illuminate/support": "^5.0",
"illuminate/contracts": "^5.0|^6.0",
"illuminate/support": "^5.0|^6.0",
"bugsnag/bugsnag": "^3.17.0",
"bugsnag/bugsnag-psr-logger": "^1.4",
"monolog/monolog": "^1.12"
Expand Down
45 changes: 45 additions & 0 deletions features/runtime_versions.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Feature: Reporting runtime versions

Background:
Given I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint

Scenario: report for handled event contains runtime version information
Given I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I start the laravel fixture
And I wait for the app to respond on the appropriate port
When I navigate to the route "/handled_exception"
And I wait for 1 second
Then I should receive a request
And the request is a valid for the error reporting API
And the event "unhandled" is false
And the event "device.runtimeVersions.php" matches "(\d+\.){2}\d+"
And the event "device.runtimeVersions.laravel" matches "(\d+\.){2}\d+"

Scenario: report for unhandled event contains runtime version information
Given I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I start the laravel fixture
And I wait for the app to respond on the appropriate port
When I navigate to the route "/unhandled_exception"
And I wait for 1 second
Then I should receive a request
And the request is a valid for the error reporting API
And the event "unhandled" is true
And the event "device.runtimeVersions.php" matches "(\d+\.){2}\d+"
And the event "device.runtimeVersions.laravel" matches "(\d+\.){2}\d+"

Scenario: session payload contains runtime version information
Given I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I enable session tracking
And I start the laravel fixture
And I wait for the app to respond on the appropriate port
When I navigate to the route "/unhandled_controller_exception"
And I wait for 1 second
Then I should receive 2 requests
And the request 0 is valid for the session tracking API
And the payload has a valid sessions array for request 0
And the payload field "device.runtimeVersions.php" matches the regex "(\d+\.){2}\d+"
And the payload field "device.runtimeVersions.laravel" matches the regex "(\d+\.){2}\d+"
26 changes: 21 additions & 5 deletions src/BugsnagServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Bugsnag\PsrLogger\BugsnagLogger;
use Bugsnag\PsrLogger\MultiLogger as BaseMultiLogger;
use Bugsnag\Report;
use DateTime;
use Illuminate\Auth\GenericUser;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
Expand All @@ -27,7 +28,6 @@
use Monolog\Handler\PsrHandler;
use Monolog\Logger;
use ReflectionClass;
use DateTime;

class BugsnagServiceProvider extends ServiceProvider
{
Expand All @@ -36,7 +36,7 @@ class BugsnagServiceProvider extends ServiceProvider
*
* @var string
*/
const VERSION = '2.16.0';
const VERSION = '2.17.0';

/**
* Boot the service provider.
Expand Down Expand Up @@ -82,7 +82,7 @@ protected function setupConfig(Container $app)
*/
protected function setupEvents(Dispatcher $events, array $config)
{
if (isset($config['auto_capture_sessions']) && $config['auto_capture_sessions']) {
if ($this->isSessionTrackingAllowed($config)) {
$events->listen(RouteMatched::class, function ($event) {
$this->app->bugsnag->getSessionTracker()->startSession();
});
Expand Down Expand Up @@ -213,7 +213,7 @@ public function register()
$client->setFilters($config['filters']);
}

if (isset($config['auto_capture_sessions']) && $config['auto_capture_sessions']) {
if ($this->isSessionTrackingAllowed($config)) {
$endpoint = isset($config['session_endpoint']) ? $config['session_endpoint'] : null;
$this->setupSessionTracking($client, $endpoint, $this->app->events);
}
Expand Down Expand Up @@ -416,8 +416,24 @@ protected function getRuntimeVersion()
if (preg_match('/(\d+\.\d+\.\d+)/', $version, $versionMatches)) {
$version = $versionMatches[0];
}
return [ ($this->app instanceof LumenApplication ? 'lumen' : 'laravel' ) => $version ];

return [($this->app instanceof LumenApplication ? 'lumen' : 'laravel') => $version];
}

/**
* Tests whether session tracking can/should be enabled.
*
* @param array $config The configuration array
*
* @return bool true if session tracking should be enabled.
*/
protected function isSessionTrackingAllowed($config)
{
// Session support removed in Lumen 5.3 - only setup automatic session
// tracking if the session function is avaiable
return isset($config['auto_capture_sessions'])
&& $config['auto_capture_sessions']
&& function_exists('session');
}

/**
Expand Down

0 comments on commit 761e9f9

Please sign in to comment.