Skip to content

Commit

Permalink
Adding breadcrumbs to sanitize / serialize. (#538) (plus fix CS)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0904031)
  • Loading branch information
ryantology authored and Jean85 committed Feb 7, 2018
1 parent 6c7893c commit 9bdcf52
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ public function sanitize(&$data)
if (!empty($data['contexts'])) {
$data['contexts'] = $this->serializer->serialize($data['contexts'], 5);
}
if (!empty($data['breadcrumbs'])) {
$data['breadcrumbs'] = $this->serializer->serialize($data['breadcrumbs'], 5);
}
}

public function sendUnsentErrors()
Expand Down
35 changes: 35 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,41 @@ public function testSanitizeContexts()
]], $data);
}

public function testSanitizeBreadcrumbs()
{
$client = ClientBuilder::create()->getClient();
$data = [
'breadcrumbs' => [
[
'message' => 'foo',
'utf8' => pack('NA3CC', 3, 'aBc', 0x0D, 0x0A),
'data' => [
'line' => 1216,
'bindings' => [
['foo', pack('NA3CC', 3, 'aBc', 0x0D, 0x0A)],
],
],
],
],
];
$client->sanitize($data);

$this->assertEquals([
'breadcrumbs' => [
[
'message' => 'foo',
'utf8' => mb_convert_encoding(pack('NA3CC', 3, 'aBc', 0x0D, 0x0A), 'UTF-8'),
'data' => [
'line' => 1216,
'bindings' => [
['foo', mb_convert_encoding(pack('NA3CC', 3, 'aBc', 0x0D, 0x0A), 'UTF-8')],
],
],
],
],
], $data);
}

/**
* @covers \Raven\Client::getShutdownFunctionHasBeenSet
*/
Expand Down
3 changes: 1 addition & 2 deletions tests/StacktraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,13 @@ public function testFromBacktraceWithAnonymousFrame()
$this->assertFrameEquals($frames[2], 'TestClass::triggerError', 'path/to/file', 12);
}


public function testInAppWithEmptyFrame()
{
$stack = [
[
'function' => '{closure}',
],
null
null,
];

$stacktrace = new Stacktrace($this->client);
Expand Down

0 comments on commit 9bdcf52

Please sign in to comment.