-
Notifications
You must be signed in to change notification settings - Fork 42
Docs ‐ Events
papamarfo edited this page Jul 30, 2026
·
1 revision
Ussd dispatches two events you can listen for without touching any core classes: Speso\Ussd\Events\StateEntered, fired every time a state is resolved and rendered (including the very first request of a session), and Speso\Ussd\Events\SessionTerminated, fired once when a session ends — whether that's a normal Terminated state or an unhandled exception. Both carry the current Context, so you have the session's uid(), gid() and input() to hand; StateEntered also carries the resolved state's class name.
<?php
namespace App\Listeners;
use Illuminate\Support\Facades\Log;
use Speso\Ussd\Events\StateEntered;
class LogUssdNavigation
{
public function handle(StateEntered $event): void
{
Log::info("Ussd session {$event->context->uid()} entered {$event->state}");
}
}Register listeners the usual Laravel way — via Event::listen() in a service provider, or an auto-discovered listener class.
- Logging a session's navigation path for debugging.
- Tracking drop-off: which states users most often abandon a session at, using
SessionTerminatedalongside the lastStateEnteredfor that session. - Feeding an analytics pipeline without coupling your
Stateclasses to any specific analytics tool.