sentry-laravel
sentry-laravel copied to clipboard
addBreadcrumb data is getting lost
Environment
Laravel 9 Php 8.0 sentry-laravel ^2.13
Expected Result
I created a helper function to send a log message and add some Breadcrumbs before that message.
I'm adding according to an array of information, but sometimes some of the data doesn't match what was informed. since I debugged and the correct information is going, but after checking online, the information does not match.
My Function
class SentryLog {
/**
* @param string $message A mensagem de log.
* @param array|null $context (opcional): O contexto adicional para incluir na mensagem de log.
* @param string $level (opcional): O nível de log (info, warning, error, etc.).
*/
public static function send(string $message, ?array $context = [], string $level = 'info', bool $addContextToBreadcrumb = true) {
$context = array_merge([
'Horário local' => \Illuminate\Support\Carbon::now()->format(\App\Enums\Timezone\TimezoneTzEnum::W3C)
], $context);
if($context && $addContextToBreadcrumb) {
\Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($context) {
foreach ($context as $key => $value) {
$scope->addBreadcrumb(new \Sentry\Breadcrumb(
\Sentry\Breadcrumb::LEVEL_INFO,
\Sentry\Breadcrumb::TYPE_DEFAULT,
gettype($key) != 'string' ? json_encode($key) : $key,
gettype($value) != 'string' ? json_encode($value) : $value
));
}
});
}
Log::channel('sentry')->$level("AUDIT LOG | {$message}", !$addContextToBreadcrumb ? ['extra' => $context] : []);
}
}
Call Funtion
SentryLog::send("message here", [
'data' => "any", // is going correctly
'Método' => "lancamento", // it's going wrong
'Status da nota' => $this->NotasEntrada['sne_status'], // is going correctly
]);
Actual Result

Thanks for reporting this.
You mentioned that you already checked what the SDK sends to Sentry and that it happens to look correct. Could you include the full event from the PayloadSeralizer in this issue as well (remove the DSN and other Pii/sensitive data)? Looking at your code, I can't spot an obvious issue, so this might indeed be a problem on the product instead.
I also wanted to point out that we released a new major version of the Laravel SDK a while ago. This won't fix your issue, but I encourage you to upgrade to v3.2.0 as v2.x won't receive any more updates.
@cleptric
I think I expressed myself poorly.
I analyzed the payload that I send to the SDK and it's right.
which is what I'm passing in SentryLog::send but it doesn't match what arrives on the online sentry platform, it seems that it gets lost in the scope and takes some information that is being captured by the sentry itself at that moment.
because if you look at Método, it should have taken lancamento but it was a query that if I don't send launch it goes into the sql.query category
Ok, this makes more sense. I'll take a look!
Closing this issue because it is quite old and it has been a long time since there was any activity, if there is still a problem please open a new issue.