Search documentation of phoenix_kit

# PhoenixKit.Admin.Events (phoenix_kit v1.7.87)

Copy Markdown View Source

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()

## Summary

### Functions

broadcast_anonymous_session_connected(session_id, session_info)

Broadcasts anonymous session connection event to admin panels.

broadcast_anonymous_session_disconnected(session_id)

Broadcasts anonymous session disconnection event to admin panels.

broadcast_module_disabled(module_key)

Broadcasts module disabled event to admin panels.

broadcast_module_enabled(module_key)

Broadcasts module enabled event to admin panels.

broadcast_permission_granted(role_uuid, module_key)

Broadcasts permission granted event to admin panels.

broadcast_permission_revoked(role_uuid, module_key)

Broadcasts permission revoked event to admin panels.

broadcast_permissions_synced(role_uuid, module_keys)

Broadcasts permissions synced event to admin panels.

broadcast_presence_stats_updated(stats)

Broadcasts presence statistics update event to admin panels.

broadcast_role_created(role)

Broadcasts role creation event to admin panels.

broadcast_role_deleted(role)

Broadcasts role deletion event to admin panels.

broadcast_role_updated(role)

Broadcasts role update event to admin panels.

broadcast_session_created(user, token_info)

Broadcasts session creation event to admin panels.

broadcast_session_revoked(token_uuid)

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(user)

Broadcasts user confirmation event to admin panels.

broadcast_user_created(user)

Broadcasts user creation event to admin panels.

broadcast_user_deleted(user)

Broadcasts user deletion event to admin panels.

broadcast_user_role_assigned(user, role_name)

Broadcasts user role assignment event to admin panels.

broadcast_user_role_removed(user, role_name)

Broadcasts user role removal event to admin panels.

broadcast_user_roles_synced(user, new_roles)

Broadcasts user roles synchronization event to admin panels.

broadcast_user_session_connected(user_uuid, session_info)

Broadcasts authenticated user session connection event to admin panels.

broadcast_user_session_disconnected(user_uuid, session_id)

Broadcasts authenticated user session disconnection event to admin panels.

broadcast_user_sessions_revoked(user_uuid, count)

Broadcasts user sessions revocation event to admin panels.

broadcast_user_unconfirmed(user)

Broadcasts user unconfirmation event to admin panels.

broadcast_user_updated(user)

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.

## Functions

# broadcast_anonymous_session_connected(session_id, session_info)

Broadcasts anonymous session connection event to admin panels.

# broadcast_anonymous_session_disconnected(session_id)

Broadcasts anonymous session disconnection event to admin panels.

# broadcast_module_disabled(module_key)

Broadcasts module disabled event to admin panels.

# broadcast_module_enabled(module_key)

Broadcasts module enabled event to admin panels.

# broadcast_permission_granted(role_uuid, module_key)

Broadcasts permission granted event to admin panels.

# broadcast_permission_revoked(role_uuid, module_key)

Broadcasts permission revoked event to admin panels.

# broadcast_permissions_synced(role_uuid, module_keys)

Broadcasts permissions synced event to admin panels.

# broadcast_presence_stats_updated(stats)

Broadcasts presence statistics update event to admin panels.

# broadcast_role_created(role)

Broadcasts role creation event to admin panels.

# broadcast_role_deleted(role)

Broadcasts role deletion event to admin panels.

# broadcast_role_updated(role)

Broadcasts role update event to admin panels.

# broadcast_session_created(user, token_info)

Broadcasts session creation event to admin panels.

# broadcast_session_revoked(token_uuid)

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(user)

Broadcasts user confirmation event to admin panels.

# broadcast_user_created(user)

Broadcasts user creation event to admin panels.

# broadcast_user_deleted(user)

Broadcasts user deletion event to admin panels.

# broadcast_user_role_assigned(user, role_name)

Broadcasts user role assignment event to admin panels.

# broadcast_user_role_removed(user, role_name)

Broadcasts user role removal event to admin panels.

# broadcast_user_roles_synced(user, new_roles)

Broadcasts user roles synchronization event to admin panels.

# broadcast_user_session_connected(user_uuid, session_info)

Broadcasts authenticated user session connection event to admin panels.

# broadcast_user_session_disconnected(user_uuid, session_id)

Broadcasts authenticated user session disconnection event to admin panels.

# broadcast_user_sessions_revoked(user_uuid, count)

Broadcasts user sessions revocation event to admin panels.

# broadcast_user_unconfirmed(user)

Broadcasts user unconfirmation event to admin panels.

# broadcast_user_updated(user)

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.