【发布时间】:2023-03-13 08:19:01
【问题描述】:
我正在努力将 mixpanel-ruby 与 Devise 集成。我有一个初学者问题,我应该在哪个函数中包含跟踪逻辑?
例如,为了跟踪成功登录,我应该覆盖SessionsController#create 还是after_sign_in_path_for(resource)?
如果覆盖创建,我应该在create 函数中插入代码还是以某种方式利用block?
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_flashing_format?
sign_in(resource_name, resource)
yield resource if block_given?
<<< insert mixpanel tracking code >>>
respond_with resource, location: after_sign_in_path_for(resource)
end
【问题讨论】:
标签: ruby-on-rails-3 devise mixpanel