diff --git a/app/Console/Commands/SendExperimentFunnelReportCommand.php b/app/Console/Commands/SendExperimentFunnelReportCommand.php index 92e60e7a..18bfa2c2 100644 --- a/app/Console/Commands/SendExperimentFunnelReportCommand.php +++ b/app/Console/Commands/SendExperimentFunnelReportCommand.php @@ -10,7 +10,7 @@ use Illuminate\Console\Command; class SendExperimentFunnelReportCommand extends Command { - protected $signature = 'stats:experiment-funnel'; + protected $signature = 'stats:experiment-funnel {--no-discord : Print the report to the console only, without posting to Discord}'; protected $description = 'Post the trial/pricing experiment funnel (per variant) to Discord'; @@ -39,6 +39,12 @@ class SendExperimentFunnelReportCommand extends Command $this->line($line); } + if ($this->option('no-discord')) { + $this->info('Skipped Discord (--no-discord).'); + + return self::SUCCESS; + } + $webhookUrl = config('services.discord.ai_cohort_webhook_url') ?: config('services.discord.webhook_url'); diff --git a/tests/Feature/SendExperimentFunnelReportCommandTest.php b/tests/Feature/SendExperimentFunnelReportCommandTest.php index 4cc30c24..4654740a 100644 --- a/tests/Feature/SendExperimentFunnelReportCommandTest.php +++ b/tests/Feature/SendExperimentFunnelReportCommandTest.php @@ -168,3 +168,19 @@ it('does not post when the experiment has not started', function () { Http::assertNothingSent(); }); + +it('prints the report without posting to discord when --no-discord is set', function () { + config(['services.discord.ai_cohort_webhook_url' => 'https://discord.test/hook']); + Http::fake(['discord.test/*' => Http::response('', 204)]); + + experimentUser(SubscriptionExperiment::CONTROL, CarbonImmutable::parse('2026-06-05'), [ + 'status' => 'active', + 'at' => CarbonImmutable::parse('2026-06-05'), + ]); + + artisan('stats:experiment-funnel', ['--no-discord' => true]) + ->expectsOutputToContain('control') + ->assertSuccessful(); + + Http::assertNothingSent(); +});