Skip to content
StatusSupportDashboard

Browser SDK Setup

Create a SafetyKit identity session before loading the browser SDK.

Create a SafetyKit identity session from server-side code before rendering pages that load the browser SDK. This call uses the SafetyKit server SDK against the normal authenticated SafetyKit API, such as api.safetykit.com.

require "safety_kit"
class ApplicationController
def safetykit_client_session
attributes = {}
attributes[:user_id] = current_user.id if logged_in?
attributes[:customer_session_id] = session.id if session&.id
safetykit.client_sessions.create_session(**attributes)
end
end

user_id and customer_session_id are optional. Omit them when they are not available.

See the client_sessions.create_session API reference for the full Ruby method signature, request parameters, and response fields.