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

PubSub event broadcasting for PhoenixKit admin panels.

This module provides functions to broadcast changes in users, roles, sessions, and
dashboard statistics to all connected admin interfaces.

## Topics

- `phoenix_kit:admin:users` - User changes (creation, updates, role changes)
- `phoenix_kit:admin:roles` - Role changes (creation, updates, deletion)
- `phoenix_kit:admin:sessions` - Session changes (creation, revocation)
- `phoenix_kit:admin:presence` - Anonymous and authenticated session presence
- `phoenix_kit:admin:stats` - Dashboard statistics updates
- `phoenix_kit:admin:modules` - Module enable/disable changes

## Events

### User Events
- `{:user_created, user}` - New user registered
- `{:user_updated, user}` - User profile/status updated
- `{:user_confirmed, user}` - User email confirmed
- `{:user_unconfirmed, user}` - User email unconfirmed
- `{:user_role_assigned, user, role_name}` - Role assigned to user
- `{:user_role_removed, user, role_name}` - Role removed from user
- `{:user_roles_synced, user, new_roles}` - User roles synchronized

### Role Events
- `{:role_created, role}` - New role created
- `{:role_updated, role}` - Role updated
- `{:role_deleted, role}` - Role deleted

### Session Events
- `{:session_created, user, token_info}` - New session created
- `{:session_revoked, token_uuid}` - Session revoked
- `{:user_sessions_revoked, user_uuid, count}` - All user sessions revoked
- `{:sessions_stats_updated, stats}` - Session statistics updated

### Presence Events
- `{:anonymous_session_connected, session_id, session_info}` - Anonymous visitor connected
- `{:anonymous_session_disconnected, session_id}` - Anonymous visitor disconnected
- `{:user_session_connected, user_uuid, session_info}` - Authenticated user connected
- `{:user_session_disconnected, user_uuid, session_id}` - Authenticated user disconnected
- `{:presence_stats_updated, stats}` - Real-time presence statistics updated

### Statistics Events
- `{:stats_updated, stats}` - Dashboard statistics updated

## Examples

    # Broadcast user creation
    PhoenixKit.Admin.Events.broadcast_user_created(user)

    # Broadcast role assignment
    PhoenixKit.Admin.Events.broadcast_user_role_assigned(user, "Admin")

    # Broadcast statistics update
    PhoenixKit.Admin.Events.broadcast_stats_updated()

# `broadcast_anonymous_session_connected`

Broadcasts anonymous session connection event to admin panels.

# `broadcast_anonymous_session_disconnected`

Broadcasts anonymous session disconnection event to admin panels.

# `broadcast_module_disabled`

Broadcasts module disabled event to admin panels.

# `broadcast_module_enabled`

Broadcasts module enabled event to admin panels.

# `broadcast_permission_granted`

Broadcasts permission granted event to admin panels.

# `broadcast_permission_revoked`

Broadcasts permission revoked event to admin panels.

# `broadcast_permissions_synced`

Broadcasts permissions synced event to admin panels.

# `broadcast_presence_stats_updated`

Broadcasts presence statistics update event to admin panels.

# `broadcast_role_created`

Broadcasts role creation event to admin panels.

# `broadcast_role_deleted`

Broadcasts role deletion event to admin panels.

# `broadcast_role_updated`

Broadcasts role update event to admin panels.

# `broadcast_session_created`

Broadcasts session creation event to admin panels.

# `broadcast_session_revoked`

Broadcasts session revocation event to admin panels.

# `broadcast_sessions_stats_updated`

Broadcasts session statistics update event to admin panels.

# `broadcast_stats_updated`

Broadcasts statistics update event to admin dashboard.

# `broadcast_user_confirmed`

Broadcasts user confirmation event to admin panels.

# `broadcast_user_created`

Broadcasts user creation event to admin panels.

# `broadcast_user_deleted`

Broadcasts user deletion event to admin panels.

# `broadcast_user_role_assigned`

Broadcasts user role assignment event to admin panels.

# `broadcast_user_role_removed`

Broadcasts user role removal event to admin panels.

# `broadcast_user_roles_synced`

Broadcasts user roles synchronization event to admin panels.

# `broadcast_user_session_connected`

Broadcasts authenticated user session connection event to admin panels.

# `broadcast_user_session_disconnected`

Broadcasts authenticated user session disconnection event to admin panels.

# `broadcast_user_sessions_revoked`

Broadcasts user sessions revocation event to admin panels.

# `broadcast_user_unconfirmed`

Broadcasts user unconfirmation event to admin panels.

# `broadcast_user_updated`

Broadcasts user update event to admin panels.

# `subscribe_to_all_admin_events`

Subscribes to all admin events.

# `subscribe_to_modules`

Subscribes to module events for admin panels.

# `subscribe_to_permissions`

Subscribes to permission events for admin panels.

# `subscribe_to_presence`

Subscribes to presence events for admin panels.

# `subscribe_to_roles`

Subscribes to role events for admin panels.

# `subscribe_to_sessions`

Subscribes to session events for admin panels.

# `subscribe_to_stats`

Subscribes to statistics events for admin dashboard.

# `subscribe_to_users`

Subscribes to user events for admin panels.

---

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