PubSub helpers for broadcasting integration changes in real-time.
Allows multiple admins viewing the Integrations settings page to see changes immediately without page refresh. Also notifies other LiveViews that depend on integration status (e.g., document creator, AI endpoints).
Topic
All events are broadcast on the "phoenix_kit:integrations" topic.
Events
{:integration_setup_saved, provider_key, data}— setup credentials saved (client_id/secret, API key, etc.){:integration_connected, provider_key, data}— OAuth flow completed, integration is now connected{:integration_disconnected, provider_key}— integration was disconnected{:integration_validated, provider_key, :ok | {:error, reason}}— health check completed
Usage
# Subscribe in a LiveView mount
if connected?(socket), do: PhoenixKit.Integrations.Events.subscribe()
# Handle events
def handle_info({:integration_connected, provider_key, _data}, socket) do
{:noreply, reload_data(socket)}
end
Summary
Functions
Broadcast that an OAuth integration was connected (tokens obtained).
Broadcast that a new named connection was added for a provider.
Broadcast that a named connection was removed from a provider.
Broadcast that a named connection was renamed.
Broadcast that an integration was disconnected (tokens removed).
Broadcast that an integration's setup credentials were saved.
Broadcast that an integration's health check completed.
Subscribe to all integration change events.
Functions
Broadcast that an OAuth integration was connected (tokens obtained).
Broadcast that a new named connection was added for a provider.
Broadcast that a named connection was removed from a provider.
Broadcast that a named connection was renamed.
@spec broadcast_disconnected(String.t()) :: :ok
Broadcast that an integration was disconnected (tokens removed).
Broadcast that an integration's setup credentials were saved.
Broadcast that an integration's health check completed.
@spec subscribe() :: :ok | {:error, term()}
Subscribe to all integration change events.