diff --git a/app/models/application_platform.rb b/app/models/application_platform.rb index 9b2695cd5..388c183eb 100644 --- a/app/models/application_platform.rb +++ b/app/models/application_platform.rb @@ -43,6 +43,17 @@ class ApplicationPlatform < PlatformAgent operating_system == "Windows" end + def bridge_name + case + when native? && android? then :android + when native? && ios? then :ios + end + end + + def bridge_components + extract_list_from_native_user_agent("bridge-components") + end + def type if native? && android? "native android" @@ -67,4 +78,13 @@ class ApplicationPlatform < PlatformAgent os =~ /Linux/ ? "Linux" : os end end + + private + def extract_list_from_native_user_agent(prefix) + if native? + user_agent.to_s.match(/#{prefix}: \[(.+)\]/) { |matches| matches[1] }.to_s + else + "" + end + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 475a7a79e..b83d199d2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,7 +5,10 @@
+ data-platform="<%= platform.type %>" + data-bridge-platform="<%= platform.bridge_name %>" + data-bridge-components="<%= platform.bridge_components %>" + data-bridge--title-title-value="<%= @page_title %>">