lucid_intercom 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucid_intercom.rb +0 -1
- data/lib/lucid_intercom/render_snippet.rb +16 -23
- data/lib/lucid_intercom/snippet.html +2 -0
- data/lib/lucid_intercom/version.rb +1 -1
- metadata +3 -3
- data/lib/lucid_intercom/snippet.html.erb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5331c5e43c8500eba29e4aa59eb888b5cf36eb688e4261bb36a03e69c73668
|
4
|
+
data.tar.gz: 512c22f9afc0ca22de424e8e7cb05620c962c97902c03f0f5ca700176be7f386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 275bf250cc1623219ccc046a0209f7b3dc3424eba9b0ea7facdb293115b52c1048f7b974c01058e0c3110eee5cc0712542e116db445cc41ecff6aa4471b90552
|
7
|
+
data.tar.gz: 5b933a4d0827a816cceec0ebcee906e2d5fffafb6d2b3472f4c64da792433e64a6bf05aec32ab46fb3dd8433e2720677b65cbd2d9d0daab49bcc0631a9c9c0c2
|
data/lib/lucid_intercom.rb
CHANGED
@@ -15,7 +15,6 @@ require 'lucid_intercom/post_request.rb'
|
|
15
15
|
require 'lucid_intercom/render_snippet.rb'
|
16
16
|
require 'lucid_intercom/response.rb'
|
17
17
|
require 'lucid_intercom/send_event.rb'
|
18
|
-
require 'lucid_intercom/snippet.html.erb'
|
19
18
|
require 'lucid_intercom/uninstalled_event.rb'
|
20
19
|
require 'lucid_intercom/update_user.rb'
|
21
20
|
require 'lucid_intercom/user_attributes.rb'
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'erb'
|
4
|
-
|
5
3
|
require 'lucid_intercom/config'
|
6
4
|
|
7
5
|
module LucidIntercom
|
8
6
|
class RenderSnippet
|
9
|
-
TEMPLATE =
|
7
|
+
TEMPLATE = File.read("#{__dir__}/snippet.html").freeze
|
10
8
|
|
11
9
|
#
|
12
10
|
# @param shopify_data [Hash] shop attributes as returned by the Shopify API
|
@@ -21,30 +19,25 @@ module LucidIntercom
|
|
21
19
|
# @return [String]
|
22
20
|
#
|
23
21
|
def call(shopify_data = {}, app_data = {})
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
settings = shopify_data.empty? ? unauthenticated_settings : {
|
23
|
+
**unauthenticated_settings,
|
24
|
+
**UserAttributes.new(shopify_data).to_h(browser: true),
|
25
|
+
company: CompanyAttributes.new(shopify_data).to_h(browser: true).merge(CompanyCustomAttributes.new(shopify_data, app_data).to_h)
|
26
|
+
}
|
27
|
+
|
28
|
+
TEMPLATE % {
|
29
|
+
settings: settings.to_json,
|
30
|
+
app_id: settings[:app_id],
|
31
|
+
}
|
29
32
|
end
|
30
33
|
|
31
34
|
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# @param obj [Object]
|
35
|
-
#
|
36
|
-
# @return [Object]
|
35
|
+
# @return [Hash]
|
37
36
|
#
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
return c unless %w(" ' / < > \\).include?(c)
|
43
|
-
|
44
|
-
"\\#{c}"
|
45
|
-
end
|
46
|
-
|
47
|
-
"\"#{s}\""
|
37
|
+
private def unauthenticated_settings
|
38
|
+
{
|
39
|
+
app_id: LucidIntercom.app_id,
|
40
|
+
}
|
48
41
|
end
|
49
42
|
end
|
50
43
|
end
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<script>window.intercomSettings=%{settings};</script>
|
2
|
+
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==='function'){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/%{app_id}';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucid_intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -101,7 +101,7 @@ files:
|
|
101
101
|
- lib/lucid_intercom/render_snippet.rb
|
102
102
|
- lib/lucid_intercom/response.rb
|
103
103
|
- lib/lucid_intercom/send_event.rb
|
104
|
-
- lib/lucid_intercom/snippet.html
|
104
|
+
- lib/lucid_intercom/snippet.html
|
105
105
|
- lib/lucid_intercom/uninstalled_event.rb
|
106
106
|
- lib/lucid_intercom/update_user.rb
|
107
107
|
- lib/lucid_intercom/user_attributes.rb
|
@@ -1,2 +0,0 @@
|
|
1
|
-
<script>window.intercomSettings={app_id:'<%= LucidIntercom.app_id %>',<% if attributes %><% user.each do |k, v| %><%= k %>:<%= escape v %>,<% end %>company:{<% company.each do |k, v| %><%= k %>:<%= escape v %>,<% end %><% company_custom.each do |k, v| %><%= k %>:<%= escape v %>,<% end %>},<% end %>};</script>
|
2
|
-
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==='function'){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/<%= LucidIntercom.app_id %>';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
|