[Feature] Detect browser on conversation initiation (#208)

This commit is contained in:
Pranav Raj S
2019-11-16 14:48:38 +05:30
committed by GitHub
parent ccd3d8dc6e
commit 88ac20efb5
5 changed files with 25 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ gem 'therubyracer', platforms: :ruby
##-- rails helper gems --##
gem 'acts-as-taggable-on', git: 'https://github.com/mbleigh/acts-as-taggable-on'
gem 'attr_extras'
gem 'browser'
gem 'hashie'
gem 'jbuilder', '~> 2.5'
gem 'kaminari'

View File

@@ -158,6 +158,7 @@ GEM
bootsnap (1.4.5)
msgpack (~> 1.0)
brakeman (4.7.0)
browser (2.7.0)
buftok (0.2.0)
builder (3.2.3)
byebug (11.0.1)
@@ -454,6 +455,7 @@ DEPENDENCIES
attr_extras
bootsnap
brakeman
browser
byebug
carrierwave-aws
chargebee (~> 2)

View File

@@ -36,7 +36,20 @@ class Api::V1::Widget::MessagesController < ActionController::Base
{
account_id: inbox.account_id,
inbox_id: inbox.id,
contact_id: cookie_params[:contact_id]
contact_id: cookie_params[:contact_id],
additional_attributes: {
browser: browser_params
}
}
end
def browser_params
{
browser_name: browser.name,
browser_version: browser.full_version,
device_name: browser.device.name,
platform_name: browser.platform.name,
platform_version: browser.platform.version
}
end

View File

@@ -0,0 +1,5 @@
class AddAdditionalAttributesToConversation < ActiveRecord::Migration[6.1]
def change
add_column :conversations, :additional_attributes, :jsonb
end
end

View File

@@ -10,7 +10,8 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_10_27_054756) do
ActiveRecord::Schema.define(version: 2019_11_16_073924) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -101,6 +102,7 @@ ActiveRecord::Schema.define(version: 2019_10_27_054756) do
t.datetime "user_last_seen_at"
t.datetime "agent_last_seen_at"
t.boolean "locked", default: false
t.jsonb "additional_attributes"
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
t.index ["account_id"], name: "index_conversations_on_account_id"
end