Skip to content

Commit 2f1bbd7

Browse files
authored
Ask user to configure send_default_pii in publish command (#987)
1 parent 2c0e6ce commit 2f1bbd7

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

src/Sentry/Laravel/Console/PublishCommand.php

+20-26
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,17 @@
1010

1111
class PublishCommand extends Command
1212
{
13-
/**
14-
* The name and signature of the console command.
15-
*
16-
* @var string
17-
*/
18-
protected $signature = 'sentry:publish {--dsn=}
19-
{--without-performance-monitoring}
20-
{--without-test}
21-
{--without-javascript-sdk}';
22-
23-
/**
24-
* The console command description.
25-
*
26-
* @var string
27-
*/
13+
protected $signature = <<<COMMAND
14+
sentry:publish
15+
{ --dsn= : The DSN to configure }
16+
{ --without-test : Do not send a test event }
17+
{ --with-send-default-pii : Include information such as request headers, IP address and the authenticated user to events collected by the SDK }
18+
{ --without-performance-monitoring : Do not enable performance monitoring }
19+
{ --without-javascript-sdk : Do not enable the JavaScript SDK (deprecated; option unused) }
20+
COMMAND;
21+
2822
protected $description = 'Publishes and configures the Sentry config.';
2923

30-
protected const SDK_CHOICE_BROWSER = 'JavaScript (default)';
31-
protected const SDK_CHOICE_VUE = 'Vue.js';
32-
protected const SDK_CHOICE_REACT = 'React';
33-
protected const SDK_CHOICE_ANGULAR = 'Angular';
34-
protected const SDK_CHOICE_SVELTE = 'Svelte';
35-
36-
/**
37-
* Execute the console command.
38-
*
39-
* @return int
40-
*/
4124
public function handle(): int
4225
{
4326
$arg = [];
@@ -62,6 +45,17 @@ public function handle(): int
6245
$arg['--dsn'] = $dsn;
6346
}
6447

48+
$sendDefaultPii = $this->confirm(
49+
"Do you want to include information such as request headers, IP address and the authenticated user to events collected by the SDK?\n You can read more about this on https://docs.sentry.io/platforms/php/guides/laravel/data-management/data-collected/",
50+
$this->option('with-send-default-pii') === true
51+
);
52+
53+
if ($sendDefaultPii) {
54+
$env['SENTRY_SEND_DEFAULT_PII'] = 'true';
55+
} elseif ($this->isEnvKeySet('SENTRY_SEND_DEFAULT_PII')) {
56+
$env['SENTRY_SEND_DEFAULT_PII'] = 'false';
57+
}
58+
6559
$testCommandPrompt = 'Do you want to send a test event to Sentry?';
6660

6761
if ($this->confirm('Enable Performance Monitoring?', !$this->option('without-performance-monitoring'))) {

0 commit comments

Comments
 (0)