Events (Audit Trail)
Understanding the event sourcing system for order tracking and auditing
Events (Audit Trail)
Rahal uses an event sourcing pattern to maintain a complete, immutable audit trail of everything that happens to an order. This provides transparency, debugging capabilities, and compliance support.
What Are Events?
Events are immutable records that capture significant actions or state changes in an order's lifecycle. Each event contains:
| Field | Description |
|---|---|
| ID | Unique event identifier |
| Entity ID | The order ID this event belongs to |
| Entity Type | Always ORDER for booking events |
| Version | Event version number |
| Event Type | Type of event (see catalog below) |
| Event Data | Details specific to the event type |
| Created At | Timestamp when event occurred |
Why Event Sourcing?
Event sourcing provides several benefits:
1. Complete Audit Trail
Every action is recorded. You can trace exactly what happened and when.
2. Debugging
When something goes wrong, the event log shows the exact sequence of operations.
3. Compliance
For corporate travel, auditors can verify the complete booking history.
4. Reconciliation
Events help reconcile internal records with external systems (payment providers, travel suppliers).
Event Catalog
Order Creation Events
| Event Type | Description | Data Includes |
|---|---|---|
| Order Created | Order was created | Flight route, dates, cabin class |
Payment Events
| Event Type | Description | Data Includes |
|---|---|---|
| Payment Verified | Payment confirmed by provider | - |
| BNPL Confirmed | Buy Now Pay Later payment confirmed | Installment plan details |
Reservation Events
| Event Type | Description | Data Includes |
|---|---|---|
| Reservation Created | Booking created with supplier | External reservation ID |
| Ticket Issued | Flight ticket issued | Reservation ID |
| Reservation Cancelled | Reservation cancelled | Reservation ID, reason |
| Switched to Credit | Hotel payment method changed | Booking details |
| Resolved Outside App | Manual resolution recorded | Resolution notes |
| Updated Outside App | External update recorded | Update details |
Status Change Events
| Event Type | Description | Data Includes |
|---|---|---|
| Status Manually Changed | Admin changed order status | Previous status, new status, reason |
| Manually Resolved | Admin resolved an issue | Resolution details |
Error Events
| Event Type | Description | Data Includes |
|---|---|---|
| Encountered Error | Error during processing | Error message, context |
| Cancelled Due to No Activity | Order cancelled after 24h unpaid | - |
Refund Events
| Event Type | Description | Data Includes |
|---|---|---|
| Order Refunded | Order was refunded | Refund amount, reason |
Event Flow Example
A typical successful order produces this event sequence:
| Step | Event | Description |
|---|---|---|
| 1 | Order Created | User initiates booking |
| 2 | Payment Verified | Payment confirmed |
| 3 | Reservation Created | Booking confirmed with supplier |
| 4 | Ticket Issued | E-ticket generated (flights only) |
| 5 | Status → Finalized | Order complete |
Viewing Events
Events are accessible in the dashboard:
- Navigate to Orders
- Click Details on an order
- Select the Events tab
Each event shows:
- Timestamp (with time)
- Event type
- Action to view full event data
Error events (ORDER_ENCOUNTERED_ERROR) are visually distinguished for quick identification during troubleshooting.
Event Data Structure
Event data is stored as a JSON string. When viewing an event, the data is parsed and displayed in a readable format.
Common Event Data Fields
| Field | Description |
|---|---|
reservationId | External reservation reference |
message | Human-readable description |
flightReservationInformation | Flight booking details |
reservationInformation | Error context for failed reservations |
Best Practices for Event Analysis
Troubleshooting Failed Orders
- Find the first
ORDER_ENCOUNTERED_ERRORevent - Check the
messageandreservationInformationfields - Look at subsequent events for recovery attempts
- Verify if the order was manually resolved
Verifying Successful Orders
- Confirm
ORDER_CREATEDexists - Verify
ORDER_PAYMENT_VERIFIED_TO_BE_PAIDfollows - Check for
ORDER_RESERVATION_CREATED(one per reservation) - For flights: verify
ORDER_RESERVATION_TICKET_ISSUED - Confirm order status is
FINALIZED
Auditing Corporate Orders
For corporate direct orders, also verify:
- Policy evaluation (logged separately in policy violations)
- Budget reservation (logged in budget transactions)
- Budget confirmation on finalization