Event System
Current Event Wiring
Use the current event/provider registration and actual producers when tracing a workflow. Broadcast/API, outgoing subscriptions and device messages are distinct contracts. The outgoing registry marks dispatchable aliases; documented DTO/event names without a producer do not imply a delivery. Do not substitute a guessed AttendeeCheckedIn class for the current attendee event/processing chain.
Overview
GxP uses application events, queued listeners/jobs, browser broadcasts, outgoing subscriptions and recorded analytics for different purposes. Trace the actual producer and registered consumer for the behavior being investigated. A declared event class or successful dispatch does not establish delivery, downstream completion or exactly-once execution.
A synchronous listener runs within the dispatch path; queued work crosses a serialization/retry boundary. A broadcast event describes browser delivery through the configured broadcaster and authorized channel. Analytics and outgoing webhooks have separate ingestion/delivery paths. Keep their identifiers and final outcomes distinct.
Table of Contents
- How Events Work
- Event Categories
- Key Listeners & Subscribers
- Queue Architecture
- Adding a New Event
- Event Flow Diagram
How Events Work
Trace an event in this order:
- Find its actual producer: observer, controller, service or prior job. Check whether it runs inside a transaction or suppresses dispatch for batch processing.
- Inspect
EventServiceProviderregistrations, including$listen,$subscribeandboot()registrations. Automatic event discovery is disabled by this provider. - Inspect each consumer's queue/transaction contract, payload, retry and failure handling. A listener can schedule another job rather than perform the final operation itself.
- If it broadcasts, inspect
broadcastOn, alias and payload plus channel authorization. A received signal is not a substitute for authorized current state. - Check separate outgoing-webhook or analytics consumers when those outcomes are required.
Registration
The provider explicitly wires, among other mappings:
| Event | Registered consumer |
|---|---|
AttendeeChanged | AttendeeChangeListener |
AttendeeLoggedIn | AttendeeLoggedInListener |
SyncBatchCompleted | SyncBatchStatusListener |
AiSessionMessageCompleted | AiSessionMessageWorkflowSignalListener |
AdminWorkflowExportCompleted | AdminWorkflowExportSignalListener |
NotificationCampaignCompleted / NotificationCampaignFailed | NotificationCampaignStatusListener |
NotificationCampaignCancelled | NotificationCampaignCancelledListener |
QuizQuestionAnswered | BroadcastLiveQuizAnalytics |
SurveyResponseSubmitted | BroadcastSurveyLiveResults |
This is a selected wiring map, not a complete event inventory. Subscribers and boot() registrations are additional entry points. In particular, webhook success, failed-attempt and final-failure signals use different listener methods; a retryable attempt failure must not be confused with a terminal delivery failure.
Event Categories
Attendee lifecycle and changes
AttendeeObserver handles created/updated/deleted/restored occurrences. Its normal path captures AttendeeOccurrenceSnapshot synchronously, then chains UpdateAttendeesDynamicGroupsJob and BroadcastAttendeeEvent. Workflow batch context can suppress per-entity dispatch. Erased-attendee handling has a separate snapshot path.
The created/updated/deleted lifecycle classes share BaseAttendeeEvent, which implements workflow contracts, ShouldBroadcast and ShouldDispatchAfterCommit. It carries occurrence/provenance information through the queue chain; a model rehydrated later is not automatically a snapshot of the original occurrence. Do not assume every event whose name starts with Attendee extends this base or has the same constructor/payload.
The snapshot stores attendee/project/team IDs, group IDs and slugs as they stood, a once-minted occurrence token and batch context. Carry the token across retries instead of deriving identity from a later updated_at. Capture delete membership before deletion removes pivots; current model timestamps and memberships cannot reconstruct that occurrence.
Restore currently dispatches AttendeeCreated again, so consumers of that trigger must consider restores too. AttendeeChanged is a separate change/debounce path: its listener retains changes, source event/integration and workflow origin for later work. Inspect the consuming workflow and loop-prevention logic before replaying a source mutation.
Use Real-time events for supported browser subscriptions and Admin Workflows for automation. Domain event names, broadcast payloads and analytics event names are different contracts.
Workflow Events
AdminWorkflowSubscriber derives its subscriptions from AdminWorkflowTrigger::getAvailableEventTypes() plus internal subscriptions. A registry entry can supply an explicit event class and handler; otherwise the subscriber uses the conventional event namespace and handleGeneralEvent.
The general handler evaluates eligible workflows and triggers through the orchestration and trigger services. Do not build an integration around an assumed AdminWorkflowExecuted event. Workflow execution, step invocation and asynchronous completion signals are separate contracts; use the workflow guide for configuration and outcome inspection.
AI Events
Current AI message events include AiSessionMessageCompleted, AiSessionMessageUploadCompleted, AiSessionMessageVariantCompleted and AiSessionMessageVariantFailed. These names describe different message or attachment transitions, rather than a universal generation-start/generation-finish pair.
AiSessionMessageCompleted implements the workflow-trigger and broadcast contracts and dispatches after commit. It carries the message role, attendee, session, attachment presence and workflow-origin context. Session metadata can disable workflow dispatch. Its broadcast alias is AiSessionMessageCompleted; the model payload uses the bounded message projection in BroadcastsAiSessionMessage, which can truncate the prompt or drop attachment fields to fit the broadcast size budget. Fetch the full message through the message API when needed.
AiMessageGenerationCompleted is a separate timing event carrying model/interface/project/attendee identifiers and generation/queue durations. Its class does not implement ShouldBroadcast; its name alone does not establish a browser subscription.
Import/Export Events
| Contract | Meaning |
|---|---|
ImportCreated, ImportUpdated, ImportDeleted, ImportComplete, ImportFailed | Import model/status events using BaseImportEvent |
ImportCompleted | A separate aggregate workflow event carrying a batch manifest, entity type, member count, project/team and optional import/workflow-origin context |
ExportStatusUpdated | Immediate export status broadcast addressed to the owning administrator |
BaseImportEvent broadcasts to the private channel dashboard.project.{projectSlug}.import.{importId}. Its payload contains selected scalar import fields, projectSlug and a timestamp; it excludes unbounded metadata and import configuration. Treat a progress notification as a reason to refresh authoritative import state.
The similarly named ImportComplete and ImportCompleted are not interchangeable. The latter uses BaseAggregateBatchEvent and manifest-backed membership rather than embedding every imported entity ID.
ExportStatusUpdated implements ShouldBroadcastNow, uses the private channel App.Models.Admin.{adminId} and the alias ExportStatusUpdated. Its payload includes export_log_id, project_slug, status, download_url and error_message. The fromExportLog factory supplies a download URL only for completed exports. An event or queued export request is not evidence that a file is ready.
Print Events
PrintJobCreated and PrintJobUpdated extend BasePrintJobEvent. The base implements broadcasting and dispatch-after-commit; updates carry the print job model rather than separate started/completed/failed/cancelled event classes.
The base targets private portal.AccessPoint.{accessPointId} and portal.Project.{projectSlug} channels when those identifiers resolve. Its custom payload selects printable information for supported printable types. Consumers should inspect the job status and supported payload, rather than infer a successful physical print from an update notification.
Broadcast Events
A class name, listener name or domain-event dispatch does not establish a browser channel. Inspect the event's broadcast interface, broadcastOn(), optional broadcastAs() and payload method, then verify channel authorization for the intended identity. Use Real-time events for browser subscription guidance.
For example, BroadcastLiveQuizAnalytics is a queued listener for QuizQuestionAnswered. When live mode is enabled and active, the question resolves, an active question window exists and the throttle permits it, the listener emits QuizLiveAnalyticsUpdated, whose private channel is dashboard.project.{projectSlug}.quiz.{formSlug}.admin, alias is analytics.updated, and payload contains form/question IDs, response totals, answer distribution and update time.
BroadcastSurveyLiveResults is also a queued listener, but its current handler does not emit a WebSocket event. For survey forms with live results enabled, it invalidates the live-results cache through SurveyMetricsService; a subsequent results request retrieves fresh data.
Notification Events
The current campaign family includes NotificationCampaignPreparing, NotificationCampaignPreparingComplete, NotificationCampaignStarted, NotificationCampaignCompleted, NotificationCampaignFailed and NotificationCampaignCancelled.
These extend BaseNotificationCampaignEvent, which carries workflow, step, workflow data and batch details and broadcasts on the private channel dashboard.project.{projectSlug}.admin-workflows.{workflowId} when project lookup succeeds. The base binds the invocation identified by admin_workflow_step_invocation_id, avoiding a different concurrent execution's latest invocation.
NotificationCampaignStatusListener handles completed/failed campaign events synchronously. It requires a workflow execution and a resolvable step invocation, records the correlated outcome and delivers the invocation-specific workflow signal. In SendNotificationCampaignAction, the recipient batch allows failures. Its final callback emits NotificationCampaignCompleted with failed_job_count, which can be nonzero; the action-level exception path emits NotificationCampaignFailed. Invocation settlement uses outcome precedence so a later final callback must not overwrite cancellation. Inspect both the invocation and failure details. Campaign settlement is not proof that an individual recipient received or opened a message; inspect delivery evidence separately.
Key Listeners & Subscribers
| Listener / Subscriber | Triggers On | What It Does |
|---|---|---|
AdminWorkflowSubscriber | Multiple attendee events (AttendeeCreated, AttendeeUpdated, AttendeeAddedToGroup, etc.) | Uses registry-derived subscriptions and evaluates eligible workflows/triggers through orchestration services |
AttendeeChangeListener | AttendeeChanged | Retains changes, provenance and workflow origin for the change/debounce path |
AttendeeLoggedInListener | AttendeeLoggedIn | Queues a debounce/throttle path that inserts accumulated AttendeeLoginLog rows |
LeaderboardSubscriber | AttendeeAddedToGroup, AttendeeRemovedFromGroup | Queues membership handling on attendee-groups-bulk and dispatches UpdateGroupLeaderboardJob for eligible groups |
NotificationCampaignStatusListener | NotificationCampaignCompleted, NotificationCampaignFailed | Settles the correlated step invocation and delivers its completion/failure signal |
BroadcastLiveQuizAnalytics | Quiz answer submission events | Computes real-time answer distribution and pushes aggregated analytics to the presenter dashboard via WebSocket |
BroadcastSurveyLiveResults | SurveyResponseSubmitted | Invalidates live-results cache for eligible survey forms; subsequent requests refresh results |
MessageSendingListener | Laravel MessageSending (email pre-send) | Creates a Sending email log with export tokens redacted from stored subject/body and attaches the correlation header to the outbound message |
MessageSentListener | Laravel MessageSent (email post-send) | Reads the correlation header and marks the existing email log Sent; this is transport evidence, not inbox delivery |
SyncBatchStatusListener | Sync batch completion events | Evaluates batch outcome and signals the correlated workflow invocation; an intermediate failed-job callback need not be terminal |
SuccessfulLogin | Laravel Login (admin auth) | For the admin guard, records the login, clears the IP/email lockout and tracks session settings/session identity |
FailedLogin | Laravel Failed (admin auth) | Records failed login evidence and updates configured IP/email and IP-wide lockout counters |
Queue Architecture
config/queue.php defaults to the Redis connection, subject to environment configuration. Horizon manages Redis workers using defaults and environment-specific overrides in config/horizon.php. A queue name does not imply a fixed priority, process count or completion deadline.
Dispatch, listener execution and broadcasting are separate branches:
The diagram shows logical branches, not immediate dispatch guarantees: dispatch-after-commit contracts can defer the event itself.
A queued listener can reject unnecessary work through shouldQueue(). For example, AdminWorkflowSubscriber skips an explicitly disabled workflow event and checks active trigger names where possible; lookup failures favor queueing rather than silently dropping a potential trigger. LeaderboardSubscriber skips classified groups and checks game-linked membership, also favoring queueing on lookup failure.
Configured worker groups
The current Horizon defaults include these queue groups; deployments can override worker settings:
| Queue(s) | Separation in the checked-in configuration |
|---|---|
default, waldo | Shared general supervisor |
cloud-storage | Dedicated cloud-storage supervisor |
bg-removal | Dedicated background-removal supervisor |
workflows-control | Workflow orchestration control |
workflows-activity | Workflow activities |
workflows-fanout | Workflow per-entity fan-out |
long-running | Long-running provisioning/media work |
imports | Import parent/chunk work; worker timeout follows importer timeout plus margin |
attendee-groups, attendee-groups-bulk | Dedicated group-processing supervisor |
The workflow queues have separate supervisors so fan-out does not hold up orchestration. The Redis connection currently has a 1,800-second retry_after; worker/job timeouts must remain below the applicable retry interval to avoid a still-running job becoming eligible for another worker. Confirm the effective environment and job-level overrides before changing concurrency, retries or timeouts. Start with the producer’s onConnection/onQueue and batch/chain routing, then the job/listener properties and viaQueue methods, then configured defaults. Compare those with the connection and queue shown for the actual job in Horizon and the active supervisor’s consumed queues. A checked-in default is not evidence of a running worker’s configuration; have an authorized operator confirm deployed environment overrides.
The Redis connection's after_commit default is false. Dispatch-after-commit interfaces and explicit dispatch/batch choices therefore matter; do not assume all queued work waits for a database commit. A serialized model may be reloaded with newer state. Preserve immutable occurrence facts when the consumer must reason about the original change.
Monitoring and recovery
Horizon exposes queue and failure information through its configured dashboard route. HorizonServiceProvider restricts the non-local viewHorizon gate to super administrators. Access to the documentation or project dashboard does not grant Horizon access.
When investigating missing work, record the producer occurrence, consumer registration, selected connection/queue, job or batch identity and invocation identity. Distinguish waiting work, a failed attempt and a settled terminal outcome. Inspect application and worker errors before retrying. Replays can repeat provider calls or other side effects unless the operation implements an appropriate idempotency contract. Detailed production recovery procedures remain in operator runbooks.
Adding a New Event
This is a platform contributor workflow, not a way for a portal app to register arbitrary PHP listeners. Run PHP/Artisan and tests through the project's Docker development environment described in Local development setup.
- Choose the producer and occurrence boundary. Identify the authorized mutation that produces the event, its transaction, and whether batch processing suppresses individual occurrences. Define what the event proves and which facts must survive later model changes.
- Choose the contract. Use a plain domain event for internal consumers. Add workflow-trigger/origin contracts only when registering a supported workflow trigger. Add broadcasting only when clients need it, with a bounded payload and explicit authorized channels. Domain dispatch does not automatically create an outgoing subscription alias.
- Register the consumer. Add the explicit event/listener mapping, subscriber mapping or appropriate provider boot registration. Discovery is disabled. For workflow triggers, inspect the trigger registry and subscriber handler as well as the event class.
- Define asynchronous behavior. Select a queue actually consumed by the deployment. Specify transaction timing, retries, terminal failure handling and idempotency. Preserve workflow execution and step-invocation correlation through asynchronous completion paths.
- Authorize browser delivery independently. Implement and test channel authorization for the intended project, portal and identity. Verify the actual alias and payload. Use the real-time guide for frontend integration rather than copying a guessed channel name.
- Test each boundary. Assert the real producer dispatches the intended occurrence after successful mutation and does not dispatch on rollback where that is the contract. Test the listener separately, including retries and replay. A test using
Event::fake()proves dispatch assertions; it does not prove the faked listener executed. Add unauthorized-channel and bounded-payload tests for broadcasts, and concurrent invocation tests for workflow signals.
Source examples in the platform repository:
| Test path | Contract exercised |
|---|---|
testing/Unit/Listeners/AdminWorkflowSubscriberSubscriptionMapTest.php | Registry-to-class/handler mapping |
testing/Integration/Broadcasting/ImportBroadcastsTest.php | Import channels, selected payload and serialization round-trip |
testing/Integration/Broadcasting/BroadcastRetryWiringTest.php | Queued broadcast payload retry defaults |
testing/Integration/Workflows/AdminWorkflowSignalCorrelationTest.php | Workflow completion signal correlation |
These are platform tests, not tests in this documentation repository. From the platform container's application directory, an isolated test invocation is:
vendor/bin/pest --configuration phpunit.xml --test-directory=testing testing/Unit/Listeners/AdminWorkflowSubscriberSubscriptionMapTest.php
Use a disposable test database and the platform test setup; do not point integration tests at a project database. The subscription-map suite was verified offline with 4 tests/67 assertions; the two import/broadcast suites passed with 24 tests/71 assertions. Those runs establish these scoped contracts, not deployed Redis workers, browser delivery or channel authorization.
Event Flow Diagram
The normal attendee lifecycle path is the following ordered chain. It is distinct from login tracking, the change/debounce path and aggregate batch processing:
Do not infer an unconditional welcome message, remote CRM write or gamification award from this chain. Those outcomes require their own configured consumer, trigger and execution evidence. Restore currently reuses AttendeeCreated, so occurrence type and replay behavior matter when designing side effects.
For an import, follow the import record's status/stage and its actual jobs. Use BaseImportEvent broadcasts to refresh state and the separate manifest-backed ImportCompleted contract for aggregate workflow handling. A progress notification or completed queue batch alone does not establish that every imported row or downstream integration succeeded.
Key Files
| Source | Use |
|---|---|
app/Providers/EventServiceProvider.php | Explicit mappings, subscribers, boot registrations and discovery setting |
app/Events/ | Domain, aggregate and broadcast event contracts |
app/Events/BaseAttendeeEvent.php | Attendee lifecycle occurrence/workflow/broadcast contract |
app/Events/BaseImportEvent.php | Bounded import status broadcast |
app/Events/BasePrintJobEvent.php | Print channels and selected printable payload |
app/Events/Concerns/BroadcastsAiSessionMessage.php | Bounded AI message payload and channels |
app/Observers/AttendeeObserver.php | Lifecycle producer, snapshots, chain and batch suppression |
app/Listeners/AdminWorkflowSubscriber.php | Registry-derived workflow trigger handling |
app/Listeners/LeaderboardSubscriber.php | Group membership handling for leaderboards |
app/Listeners/AttendeeLoggedInListener.php | Debounced login-log insertion |
app/Listeners/MessageSendingListener.php, MessageSentListener.php | Pre-send logging/correlation and transport-sent update |
config/queue.php, config/horizon.php | Queue connections, retry interval and supervisor configuration |
app/Providers/HorizonServiceProvider.php | Non-local monitoring authorization |
config/broadcasting.php, routes/admin/channels.php, routes/portal/channels.php | Broadcaster configuration and channel authorization |
Use these entry points to trace a particular feature; this list is not an exhaustive inventory or a guarantee that the deployed workers use the checked-in defaults.