Skip to content

Commit

Permalink
Merge branch 'master' into next/4.0/main
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorell committed Jan 18, 2023
2 parents 308c6f5 + 4897fa2 commit dc89117
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 48 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci-1.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
# compatible version as well as the most-recent stable version. This will
# fail-fast by default, so we include our edgiest versions (currently 7.4)
# first as they're most likely to fail.
# @seealso https://freek.dev/1546
# @seealso https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest/
# @seealso https://github.com/actions/starter-workflows/blob/main/ci/php.yml
# @see https://freek.dev/1546
# @see https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest/
# @see https://github.com/actions/starter-workflows/blob/main/ci/php.yml
php-tests:
strategy:
matrix:
Expand All @@ -45,13 +45,13 @@ jobs:
steps:
- name: Checkout the next/1.x/main branch during scheduled builds
if: github.ref == 'refs/heads/master'
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: 'next/1.x/main'

- name: Checkout the pushed branch
if: github.ref != 'refs/heads/master'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install PHP and composer environment
uses: shivammathur/setup-php@v2
Expand All @@ -63,10 +63,10 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.dependency }}-
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci-2.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
# compatible version as well as the most-recent stable version. This will
# fail-fast by default, so we include our edgiest versions (currently 7.4)
# first as they're most likely to fail.
# @seealso https://freek.dev/1546
# @seealso https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest/
# @seealso https://github.com/actions/starter-workflows/blob/main/ci/php.yml
# @see https://freek.dev/1546
# @see https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest/
# @see https://github.com/actions/starter-workflows/blob/main/ci/php.yml
php-tests:
strategy:
matrix:
Expand Down Expand Up @@ -70,13 +70,13 @@ jobs:
steps:
- name: Checkout the next/2.x/main branch during scheduled builds
if: github.ref == 'refs/heads/master'
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: 'next/2.x/main'

- name: Checkout the pushed branch
if: github.ref != 'refs/heads/master'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install PHP and composer environment
uses: shivammathur/setup-php@v2
Expand All @@ -88,10 +88,10 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.dependency }}-
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
# compatible version as well as the most-recent stable version. This will
# fail-fast by default, so we include our edgiest versions (currently 7.4)
# first as they're most likely to fail.
# @seealso https://freek.dev/1546
# @seealso https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest/
# @see https://freek.dev/1546
# @see https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest/
php-tests:
strategy:
matrix:
# All the versions, OS, and dependency levels we want to support
php: [8.0, 8.1]
php: [8.0, 8.1, 8.2]
dependency: [stable] # TODO: lowest
os: [ubuntu] # TODO: windows, macos
# Our code has paths for with- and without- XDebug, and we want to test
Expand All @@ -46,7 +46,7 @@ jobs:
runs-on: ${{ matrix.os }}-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install PHP and composer environment
uses: shivammathur/setup-php@v2
Expand All @@ -58,10 +58,10 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.dependency }}-
Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
# Rollbar-PHP
<p align="center">
<img alt="rollbar-logo" src="https://user-images.githubusercontent.com/3300063/207964480-54eda665-d6fe-4527-ba51-b0ab3f41f10b.png" />
</p>

<h1 align="center">Rollbar PHP SDK</h1>

<p align="center">
<strong>Proactively discover, predict, and resolve errors in real-time with <a href="https://rollbar.com">Rollbar’s</a> error monitoring platform. <a href="https://rollbar.com/signup/">Start tracking errors today</a>!</strong>
</p>


[![Latest Version on Packagist](https://img.shields.io/packagist/v/rollbar/rollbar.svg?style=flat-square)](https://packagist.org/packages/rollbar/rollbar)
![Build Status](https://github.com/rollbar/rollbar-php/workflows/Rollbar-PHP%20CI/badge.svg)
[![Total Downloads](https://img.shields.io/packagist/dt/rollbar/rollbar.svg?style=flat-square)](https://packagist.org/packages/rollbar/rollbar)

This library detects errors and exceptions in your application and sends them
to [Rollbar] for alerts, reporting, and analysis.
---

## Key benefits of using Rollbar PHP SDK are:
- **Frameworks:** Rollbar php supports many popular php frameworks such as <a href="https://docs.rollbar.com/docs/laravel">Laravel</a>, <a href="https://docs.rollbar.com/docs/codeigniter">CodeIgniter</a>, <a href="https://docs.rollbar.com/docs/symfony">Symfony</a> and many more!
- **Plugins:** Rollbar php has plugin support for <a href="https://docs.rollbar.com/docs/php-heroku">Heroku</a>, <a href="https://docs.rollbar.com/docs/wordpress">Wordpress</a>, <a href="https://docs.rollbar.com/docs/php-integration-with-rollbarjs">Rollbar.js</a> and more.
- **Automatic error grouping:** Rollbar aggregates Occurrences caused by the same error into Items that represent application issues. <a href="https://docs.rollbar.com/docs/grouping-occurrences">Learn more about reducing log noise</a>.
- **Advanced search:** Filter items by many different properties. <a href="https://docs.rollbar.com/docs/search-items">Learn more about search</a>.
- **Customizable notifications:** Rollbar supports several messaging and incident management tools where your team can get notified about errors and important events by real-time alerts. <a href="https://docs.rollbar.com/docs/notifications">Learn more about Rollbar notifications</a>.


[Rollbar]: https://rollbar.com

# Quickstart

Expand Down
4 changes: 3 additions & 1 deletion src/ErrorWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
class ErrorWrapper extends \Exception
{
private static $constName;


public $isUncaught;

private $utilities;

private static function getConstName($const)
Expand Down
2 changes: 1 addition & 1 deletion src/RollbarJsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function addJs($headers = null, $nonce = null, $customJs = "")
*/
public function configJsTag()
{
return "var _rollbarConfig = " . json_encode($this->config, JSON_FORCE_OBJECT) . ";";
return "var _rollbarConfig = " . json_encode((object)$this->config) . ";";
}

/**
Expand Down
37 changes: 21 additions & 16 deletions src/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,28 @@ public static function serializeForRollbar(
}

foreach ($obj as $key => $val) {
if (is_object($val)) {
$val = self::serializeObject(
$val,
$customKeys,
$objectHashes,
$maxDepth,
$depth
);
} elseif (is_array($val)) {
$val = self::serializeForRollbar(
$val,
$customKeys,
$objectHashes,
$maxDepth,
$depth+1
);
try {
if (is_object($val)) {
$val = self::serializeObject(
$val,
$customKeys,
$objectHashes,
$maxDepth,
$depth
);
} elseif (is_array($val)) {
$val = self::serializeForRollbar(
$val,
$customKeys,
$objectHashes,
$maxDepth,
$depth+1
);
}
} catch (\Throwable $e) {
$val = 'Error during serialization: '.$e->getMessage();
}


if ($customKeys !== null && in_array($key, $customKeys)) {
$returnVal[$key] = $val;
Expand Down
22 changes: 16 additions & 6 deletions tests/JsHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,11 @@ public function scriptTagProvider(): array
);
}

public function testConfigJsTag(): void
/**
* @dataProvider configJsTagProvider
*/
public function testConfigJsTag($config, $expectedJson): void
{
$config = array(
'config1' => 'value 1'
);

$expectedJson = json_encode($config);
$expected = "var _rollbarConfig = $expectedJson;";

$helper = new RollbarJsHelper($config);
Expand All @@ -241,6 +239,18 @@ public function testConfigJsTag(): void
$this->assertEquals($expected, $result);
}

public function configJsTagProvider()
{
return array(
array(array(), '{}'),
array(array('config1' => 'value 1'), '{"config1":"value 1"}'),
array(
array('hostBlackList' => array('example.com', 'badhost.com')),
'{"hostBlackList":["example.com","badhost.com"]}'
),
);
}

/**
* @dataProvider addJsProvider
*/
Expand Down

0 comments on commit dc89117

Please sign in to comment.