Skip to content

Commit fc5853f

Browse files
stayallivecleptric
andauthored
Simplify breadcrumb API (#1603)
Co-authored-by: Michi Hoffmann <[email protected]>
1 parent ab2e11f commit fc5853f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/functions.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,20 @@ function captureCheckIn(string $slug, CheckInStatus $status, $duration = null, ?
8585
* will be added to subsequent events to provide more context on user's
8686
* actions prior to an error or crash.
8787
*
88-
* @param Breadcrumb $breadcrumb The breadcrumb to record
88+
* @param Breadcrumb|string $category The category of the breadcrumb, can be a Breadcrumb instance as well (in which case the other parameters are ignored)
89+
* @param string|null $message Breadcrumb message
90+
* @param array<string, mixed> $metadata Additional information about the breadcrumb
91+
* @param string $level The error level of the breadcrumb
92+
* @param string $type The type of the breadcrumb
93+
* @param float|null $timestamp Optional timestamp of the breadcrumb
8994
*/
90-
function addBreadcrumb(Breadcrumb $breadcrumb): void
95+
function addBreadcrumb($category, ?string $message = null, array $metadata = [], string $level = Breadcrumb::LEVEL_INFO, string $type = Breadcrumb::TYPE_DEFAULT, ?float $timestamp = null): void
9196
{
92-
SentrySdk::getCurrentHub()->addBreadcrumb($breadcrumb);
97+
SentrySdk::getCurrentHub()->addBreadcrumb(
98+
$category instanceof Breadcrumb
99+
? $category
100+
: new Breadcrumb($level, $type, $category, $message, $metadata, $timestamp)
101+
);
93102
}
94103

95104
/**

0 commit comments

Comments
 (0)