[Feature] Detect browser on conversation initiation (#208)
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -12,6 +12,7 @@ gem 'therubyracer', platforms: :ruby
|
|||||||
##-- rails helper gems --##
|
##-- rails helper gems --##
|
||||||
gem 'acts-as-taggable-on', git: 'https://github.com/mbleigh/acts-as-taggable-on'
|
gem 'acts-as-taggable-on', git: 'https://github.com/mbleigh/acts-as-taggable-on'
|
||||||
gem 'attr_extras'
|
gem 'attr_extras'
|
||||||
|
gem 'browser'
|
||||||
gem 'hashie'
|
gem 'hashie'
|
||||||
gem 'jbuilder', '~> 2.5'
|
gem 'jbuilder', '~> 2.5'
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ GEM
|
|||||||
bootsnap (1.4.5)
|
bootsnap (1.4.5)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
brakeman (4.7.0)
|
brakeman (4.7.0)
|
||||||
|
browser (2.7.0)
|
||||||
buftok (0.2.0)
|
buftok (0.2.0)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (11.0.1)
|
byebug (11.0.1)
|
||||||
@@ -454,6 +455,7 @@ DEPENDENCIES
|
|||||||
attr_extras
|
attr_extras
|
||||||
bootsnap
|
bootsnap
|
||||||
brakeman
|
brakeman
|
||||||
|
browser
|
||||||
byebug
|
byebug
|
||||||
carrierwave-aws
|
carrierwave-aws
|
||||||
chargebee (~> 2)
|
chargebee (~> 2)
|
||||||
|
|||||||
@@ -36,7 +36,20 @@ class Api::V1::Widget::MessagesController < ActionController::Base
|
|||||||
{
|
{
|
||||||
account_id: inbox.account_id,
|
account_id: inbox.account_id,
|
||||||
inbox_id: inbox.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
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddAdditionalAttributesToConversation < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :conversations, :additional_attributes, :jsonb
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
@@ -101,6 +102,7 @@ ActiveRecord::Schema.define(version: 2019_10_27_054756) do
|
|||||||
t.datetime "user_last_seen_at"
|
t.datetime "user_last_seen_at"
|
||||||
t.datetime "agent_last_seen_at"
|
t.datetime "agent_last_seen_at"
|
||||||
t.boolean "locked", default: false
|
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", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
|
||||||
t.index ["account_id"], name: "index_conversations_on_account_id"
|
t.index ["account_id"], name: "index_conversations_on_account_id"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user