intercom-rails 0.2.27 → 0.2.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.mdown +10 -8
- data/lib/intercom-rails/auto_include_filter.rb +5 -1
- data/lib/intercom-rails/config.rb +1 -0
- data/lib/intercom-rails/script_tag.rb +7 -2
- data/lib/intercom-rails/version.rb +1 -1
- data/lib/rails/generators/intercom/config/config_generator.rb +1 -0
- data/lib/rails/generators/intercom/config/intercom.rb.erb +16 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 141d27f9b5389539330869833167ba06547a9d47
|
4
|
+
data.tar.gz: a8dae5495febc5dda1d64187e90fd747a7039006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d844a6dca6093fdf67361f98772de2fe4e76a833c989dac1597b755f2deaeadc9def4a4d241bc8dbd2292032b041030511d2a5e3f05fbcbccc5430b8840dd2
|
7
|
+
data.tar.gz: f9d24e5b3dffdd193d63f27032a3c37a26c5385151a838208d370336f2a01323d760eacd7f69c5b091d80e8359ec4cf94201c7e577e642fc2e41367ef744bce4
|
data/README.mdown
CHANGED
@@ -39,6 +39,7 @@ If it's not working make sure:
|
|
39
39
|
* You've generated a config file with your `app_id` as detailed above.
|
40
40
|
* Your user object responds to an `id` or `email` method.
|
41
41
|
* Your current user is accessible in your controllers as `current_user` or `@user`, if not in `config/initializers/intercom.rb`:
|
42
|
+
* If you want the Intercom Messenger to be available when there is no current user, set `config.include_for_logged_out_users = true` in your config and sign up for the [Acquire](https://www.intercom.io/live-chat) package.
|
42
43
|
|
43
44
|
```ruby
|
44
45
|
config.user.current = Proc.new { current_user_object }
|
@@ -115,28 +116,29 @@ config.company.custom_data = {
|
|
115
116
|
}
|
116
117
|
```
|
117
118
|
|
118
|
-
###
|
119
|
-
|
120
|
-
|
121
|
-
To use the default link style, which requires no extra config and includes a small question mark icon in the bottom right corner of your app:
|
119
|
+
### Live Chat / Acquire
|
120
|
+
With our [Acquire package](https://www.intercom.io/live-chat), Intercom Messenger now works with logged out users and visitors to your web site. Include the Intercom snippet on every page by setting:
|
122
121
|
|
123
122
|
```ruby
|
124
|
-
config.
|
123
|
+
config.include_for_logged_out_users = true
|
125
124
|
```
|
126
125
|
|
127
|
-
|
126
|
+
### Messenger
|
127
|
+
Intercom includes an in-app messenger which allows a user to read messages and start conversations.
|
128
|
+
|
129
|
+
By default Intercom will add a button that opens the messenger to the page. If you want to customize the style of the link that opens the messenger:
|
128
130
|
|
129
131
|
```ruby
|
130
132
|
config.inbox.style = :custom
|
131
133
|
```
|
132
134
|
|
133
|
-
|
135
|
+
With this option enabled, clicks on any element with an id of `Intercom` will open the messenger. So the simplest option here would be to add something like the following to your layout:
|
134
136
|
|
135
137
|
```html
|
136
138
|
<a id="Intercom">Support</a>
|
137
139
|
```
|
138
140
|
|
139
|
-
You can read more about configuring the
|
141
|
+
You can read more about configuring the messenger in your applications settings, within Intercom.
|
140
142
|
|
141
143
|
### Environments
|
142
144
|
|
@@ -54,7 +54,11 @@ module IntercomRails
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def intercom_script_tag
|
57
|
-
@script_tag ||= ScriptTag.new(:find_current_user_details => true, :find_current_company_details => true, :controller => controller)
|
57
|
+
@script_tag ||= ScriptTag.new(:find_current_user_details => true, :find_current_company_details => true, :controller => controller, :show_everywhere => show_everywhere?)
|
58
|
+
end
|
59
|
+
|
60
|
+
def show_everywhere?
|
61
|
+
IntercomRails.config.include_for_logged_out_users
|
58
62
|
end
|
59
63
|
|
60
64
|
def enabled_for_environment?
|
@@ -84,6 +84,7 @@ module IntercomRails
|
|
84
84
|
config_accessor :api_key
|
85
85
|
config_accessor :library_url
|
86
86
|
config_accessor :enabled_environments, &ARRAY_VALIDATOR
|
87
|
+
config_accessor :include_for_logged_out_users
|
87
88
|
|
88
89
|
config_group :user do
|
89
90
|
config_accessor :current, &IS_PROC_VALIDATOR
|
@@ -10,13 +10,14 @@ module IntercomRails
|
|
10
10
|
new(*args).output
|
11
11
|
end
|
12
12
|
|
13
|
-
attr_reader :user_details, :company_details
|
13
|
+
attr_reader :user_details, :company_details, :show_everywhere
|
14
14
|
attr_accessor :secret, :widget_options, :controller
|
15
15
|
|
16
16
|
def initialize(options = {})
|
17
17
|
self.secret = options[:secret] || Config.api_secret
|
18
18
|
self.widget_options = widget_options_from_config.merge(options[:widget] || {})
|
19
19
|
self.controller = options[:controller]
|
20
|
+
@show_everywhere = options[:show_everywhere]
|
20
21
|
self.user_details = options[:find_current_user_details] ? find_current_user_details : options[:user_details]
|
21
22
|
self.company_details = if options[:find_current_company_details]
|
22
23
|
find_current_company_details
|
@@ -26,7 +27,11 @@ module IntercomRails
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def valid?
|
29
|
-
|
30
|
+
valid = user_details[:app_id].present?
|
31
|
+
unless @show_everywhere
|
32
|
+
valid = valid && (user_details[:user_id] || user_details[:email]).present?
|
33
|
+
end
|
34
|
+
valid
|
30
35
|
end
|
31
36
|
|
32
37
|
def intercom_settings
|
@@ -4,8 +4,8 @@ IntercomRails.config do |config|
|
|
4
4
|
config.app_id = ENV["INTERCOM_APP_ID"] || "<%= @app_id %>"
|
5
5
|
|
6
6
|
# == Intercom secret key
|
7
|
-
# This is required to enable secure mode, you can find it on your
|
8
|
-
# "
|
7
|
+
# This is required to enable secure mode, you can find it on your Setup
|
8
|
+
# guide in the "Secure Mode" step.
|
9
9
|
#
|
10
10
|
<%- if @api_secret -%>
|
11
11
|
config.api_secret = "<%= @api_secret %>"
|
@@ -38,6 +38,15 @@ IntercomRails.config do |config|
|
|
38
38
|
# config.user.current = Proc.new { current_user }
|
39
39
|
<%- end -%>
|
40
40
|
|
41
|
+
# == Include for logged out Users
|
42
|
+
# If set to true, include the Intercom messenger on all pages, regardless of whether
|
43
|
+
# The user model class (set below) is present. Only available for Apps on the Acquire plan.
|
44
|
+
<%- if @include_for_logged_out_users -%>
|
45
|
+
config.include_for_logged_out_users = true
|
46
|
+
<%- else -%>
|
47
|
+
# config.include_for_logged_out_users = true
|
48
|
+
<%- end -%>
|
49
|
+
|
41
50
|
# == User model class
|
42
51
|
# The class which defines your user model
|
43
52
|
#
|
@@ -95,14 +104,11 @@ IntercomRails.config do |config|
|
|
95
104
|
# config.company.monthly_spend = Proc.new { |current_company| current_company.plan.price }
|
96
105
|
# config.company.monthly_spend = Proc.new { |current_company| (current_company.plan.price - current_company.subscription.discount) }
|
97
106
|
|
98
|
-
# ==
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
# * :custom attaches the inbox open event to an anchor with an
|
104
|
-
# id of #Intercom.
|
107
|
+
# == Custom Style
|
108
|
+
# By default, Intercom will add a button that opens the messenger to
|
109
|
+
# the page. If you'd like to use your own link to open the messenger,
|
110
|
+
# uncomment this line and clicks on any element with id 'Intercom' will
|
111
|
+
# open the messenger.
|
105
112
|
#
|
106
|
-
# config.inbox.style = :default
|
107
113
|
# config.inbox.style = :custom
|
108
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intercom-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben McRedmond
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -207,3 +207,4 @@ signing_key:
|
|
207
207
|
specification_version: 4
|
208
208
|
summary: Rails helper for emitting javascript script tags for Intercom
|
209
209
|
test_files: []
|
210
|
+
has_rdoc:
|