1120-messages/client/client-events-implementation-plan.md
2025-04-10 13:59:03 +01:00

3.1 KiB

Client Events Implementation Plan

Implementation Status

The implementation of the client-side event tracking system has been completed:

1. Core Services

  • ClientEventStore - Tracks outgoing KIND 21120 events and incoming KIND 21121 responses

    • Stores events with metadata (status, timestamps, etc.)
    • Associates responses with their original requests via e tags
    • Provides methods for tracking, querying, and updating events
  • client-event-handler.ts - Coordinates event tracking and relay subscriptions

    • Initializes the ClientEventStore
    • Sets up subscriptions to KIND 21121 responses
    • Provides methods for tracking outgoing events
    • Handles incoming response events

2. UI Components

  • ClientEventsTable - Displays tracked events in a table format
    • Shows timestamps, target servers, and event status
    • Updates in real-time when events are added or updated
    • Provides detailed view through modal dialog
    • Displays both request and response content when available

3. Styling

  • client-events-table.css - Provides styling for the events table and modal
    • Matches the look and feel of the existing application
    • Includes styles for the modal tabs and content views
    • Handles different event statuses with appropriate highlighting

4. Integration

  • 1120_client.html - Updated to include the client events table

    • Added container for the events table
    • Included link to the CSS file
  • client.ts - Updated to initialize and use the event tracking system

    • Initializes client-event-handler with the relay service
    • Tracks outgoing events when published
    • Hooks into the existing event publishing flow

Features

The implementation provides the following features:

  1. Event Tracking: All outgoing 21120 events are automatically tracked
  2. Response Association: Incoming 21121 responses are associated with their original requests
  3. Status Updates: Event status is updated as they progress through their lifecycle
  4. Visual Interface: A table displays all events with their current status
  5. Detailed View: A modal dialog shows detailed information about events and their responses
  6. Real-time Updates: The UI updates automatically when events change or responses arrive

Usage

The client events table is automatically initialized when the client page loads. It will:

  1. Show all outgoing HTTP requests (KIND 21120 events)
  2. Update when responses (KIND 21121 events) are received
  3. Allow clicking on any event to see full details
  4. Display HTTP formatted content for easy reading

No additional user steps are required to use this functionality - it works automatically when sending HTTP requests through the client page.

Next Steps

Potential future enhancements could include:

  1. Add filters to the event table (by status, target server, etc.)
  2. Implement persistence via local storage to maintain history between sessions
  3. Add export/import functionality for offline analysis
  4. Add ability to retry failed requests
  5. Improve visualization with charts or graphs of request/response patterns