# `PhoenixKit.Modules.CustomerService.Events`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.87/lib/modules/customer_service/events.ex#L1)

PubSub events for PhoenixKit Customer Service system.

Broadcasts ticket-related events for real-time updates in LiveViews.
Uses `PhoenixKit.PubSub.Manager` for self-contained PubSub operations.

## Topics

- `"customer_service:all"` - All tickets (for admins)
- `"customer_service:user:{user_uuid}"` - Tickets for specific user
- `"customer_service:{uuid}"` - Specific ticket (for detail view)

## Events

### Ticket Events
- `{:ticket_created, ticket}` - New ticket created
- `{:ticket_updated, ticket}` - Ticket updated
- `{:ticket_status_changed, ticket, old_status, new_status}` - Status transition
- `{:ticket_assigned, ticket, old_assignee_uuid, new_assignee_uuid}` - Assignment change
- `{:ticket_priority_changed, ticket, old_priority, new_priority}` - Priority change
- `{:tickets_bulk_updated, tickets, changes}` - Bulk update operation

### Comment Events
- `{:comment_created, comment, ticket}` - Public comment added
- `{:internal_note_created, comment, ticket}` - Internal note added (staff only)

## Usage Examples

    # Subscribe to all ticket events (admin view)
    PhoenixKit.Modules.CustomerService.Events.subscribe_to_all()

    # Subscribe to user's tickets
    PhoenixKit.Modules.CustomerService.Events.subscribe_to_user_tickets(user_uuid)

    # Subscribe to specific ticket (detail view)
    PhoenixKit.Modules.CustomerService.Events.subscribe_to_ticket(ticket_uuid)

    # Handle in LiveView
    def handle_info({:ticket_created, ticket}, socket) do
      # Update UI
      {:noreply, socket}
    end

# `broadcast_comment_created`

Broadcasts public comment created event.

# `broadcast_internal_note_created`

Broadcasts internal note created event (staff only).

# `broadcast_ticket_assigned`

Broadcasts ticket assigned event.

# `broadcast_ticket_created`

Broadcasts ticket created event.

# `broadcast_ticket_priority_changed`

Broadcasts ticket priority changed event.

# `broadcast_ticket_status_changed`

Broadcasts ticket status changed event.

# `broadcast_ticket_updated`

Broadcasts ticket updated event.

# `broadcast_tickets_bulk_updated`

Broadcasts tickets bulk updated event.

# `subscribe_tickets`

Alias for subscribe_to_all/0 for consistency with naming convention.
Subscribes to all ticket events (for admin views).

# `subscribe_to_all`

Subscribes to all ticket events (for admin views).

# `subscribe_to_ticket`

Subscribes to events for a specific ticket (for detail views).

# `subscribe_to_user_tickets`

Subscribes to ticket events for a specific user.

# `ticket_topic`

Returns the PubSub topic for a specific ticket.

# `unsubscribe_from_all`

Unsubscribes from all ticket events.

# `unsubscribe_from_ticket`

Unsubscribes from a specific ticket's events.

# `unsubscribe_from_user_tickets`

Unsubscribes from a specific user's ticket events.

# `user_topic`

Returns the PubSub topic for a specific user's tickets.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
