pull/698/merge
Pete Matsyburka 1 week ago
parent 85327760b9
commit 12b49f5fa7

@ -146,6 +146,8 @@ Rails.application.configure do
current_user = controller.instance_variable_get(:@current_user)
os = DetectBrowserDevice.os(controller.request.user_agent) if ENV['MULTITENANT'] == 'true'
{
host: controller.request.host,
fwd: controller.request.remote_ip,
@ -161,6 +163,7 @@ Rails.application.configure do
params[:submit_form_slug] ||
params[:template_slug]).to_s.first(5)
}.compact_blank,
**(os ? { os: } : {}),
uid: current_user.try(:id),
aid: current_user.try(:account_id),
rid: resource.try(:id),

@ -26,6 +26,45 @@ module DetectBrowserDevice
Silk
/ix
WINDOWS_USER_AGENT_REGEXP = /
Windows|
Win64 |
Win32 |
WOW64
/ix
ANDROID_USER_AGENT_REGEXP = /
Android|
Silk |
Kindle
/ix
IOS_USER_AGENT_REGEXP = /
iPhone|
iPad |
iPod |
iOS
/ix
MACOS_USER_AGENT_REGEXP = /
Macintosh |
Mac\ OS\ X |
MacIntel
/ix
LINUX_USER_AGENT_REGEXP = /
Linux |
X11 |
CrOS |
Ubuntu |
Fedora |
FreeBSD|
OpenBSD|
NetBSD
/ix
SDK_USER_AGENT_REGEXP = /\ADocuSeal (?<sdk>Ruby|Python|PHP|Java|C#|JS|Go|CLI) v/i
def call(user_agent)
return if user_agent.blank?
@ -34,4 +73,21 @@ module DetectBrowserDevice
'desktop'
end
def os(user_agent)
return if user_agent.blank?
sdk = user_agent[SDK_USER_AGENT_REGEXP, :sdk]
return sdk.downcase if sdk
case user_agent
when WINDOWS_USER_AGENT_REGEXP then 'windows'
when ANDROID_USER_AGENT_REGEXP then 'android'
when IOS_USER_AGENT_REGEXP then 'ios'
when MACOS_USER_AGENT_REGEXP then 'macos'
when LINUX_USER_AGENT_REGEXP then 'linux'
else 'other'
end
end
end

Loading…
Cancel
Save