Skip to content

Commit 892ec15

Browse files
authored
Add support for PHP to beforeSendTransaction (#5864)
1 parent df0db3e commit 892ec15

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
In the Laravel config, a closure can be used to modify the event or return a completely new one. If you return `null`, the event will be discarded.
2+
3+
```php {filename:config/sentry.php}
4+
'before_send_transaction' => function (\Sentry\Event $transaction): ?\Sentry\Event {
5+
return $transaction;
6+
},
7+
```
8+
9+
<Note>
10+
11+
Learn more in [Closures and Config Caching](/platforms/php/guides/laravel/configuration/laravel-options/#closures-and-config-caching).
12+
13+
</Note>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
In PHP, a closure can be used to modify the event or return a completely new one. If you return `null`, the event will be discarded.
2+
3+
```php
4+
\Sentry\init([
5+
'dsn' => '___PUBLIC_DSN___',
6+
'before_send_transaction' => function (\Sentry\Event $transaction): ?\Sentry\Event {
7+
return $transaction;
8+
},
9+
]);
10+
```

src/platforms/common/configuration/options.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ This function is called with an SDK-specific message or error event object, and
567567

568568
</ConfigKey>
569569

570-
<ConfigKey name="before-send-transaction" supported={["javascript", "node"]}>
570+
<ConfigKey name="before-send-transaction" supported={["javascript", "node", "php"]}>
571571

572572
This function is called with an SDK-specific transaction event object, and can return a modified transaction event object, or `null` to skip reporting the event. One way this might be used is for manual PII stripping before sending.
573573

0 commit comments

Comments
 (0)