2020-01-17 08:06:05 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
|
|
|
|
|
2021-01-17 17:14:03 +00:00
|
|
|
|
|
|
|
<%
|
|
|
|
user_id = 1
|
|
|
|
user_hash = OpenSSL::HMAC.hexdigest(
|
|
|
|
'sha256',
|
|
|
|
@web_widget.hmac_token,
|
|
|
|
user_id.to_s
|
|
|
|
)
|
|
|
|
|
|
|
|
%>
|
2019-11-01 07:23:01 +00:00
|
|
|
<script>
|
2020-04-03 07:34:58 +00:00
|
|
|
|
|
|
|
window.chatwootSettings = {
|
|
|
|
hideMessageBubble: false,
|
2022-02-25 10:48:18 +00:00
|
|
|
position: '<%= @widget_position %>',
|
2020-10-18 18:02:22 +00:00
|
|
|
locale: 'en',
|
2022-02-25 10:48:18 +00:00
|
|
|
type: '<%= @widget_type %>',
|
2020-08-28 12:09:46 +00:00
|
|
|
showPopoutButton: true,
|
2022-02-25 10:48:18 +00:00
|
|
|
widgetStyle: '<%= @widget_style %>',
|
2022-04-01 15:29:03 +00:00
|
|
|
darkMode: '<%= @dark_mode %>',
|
2020-04-03 07:34:58 +00:00
|
|
|
};
|
|
|
|
|
2019-11-01 07:23:01 +00:00
|
|
|
(function(d,t) {
|
|
|
|
var BASE_URL = '';
|
|
|
|
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
|
|
|
g.src= BASE_URL + "/packs/js/sdk.js";
|
2021-08-26 14:21:10 +00:00
|
|
|
g.defer = true;
|
|
|
|
g.async = true;
|
2019-11-01 07:23:01 +00:00
|
|
|
s.parentNode.insertBefore(g,s);
|
|
|
|
g.onload=function(){
|
|
|
|
window.chatwootSDK.run({
|
|
|
|
websiteToken: '<%= @web_widget.website_token %>',
|
|
|
|
baseUrl: BASE_URL
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})(document,"script");
|
2020-07-25 16:24:58 +00:00
|
|
|
|
|
|
|
window.addEventListener('chatwoot:ready', function() {
|
2022-02-21 04:10:11 +00:00
|
|
|
console.log('chatwoot:ready', window.$chatwoot);
|
2021-02-15 19:28:57 +00:00
|
|
|
if (window.location.search.includes('setUser')) {
|
|
|
|
window.$chatwoot.setUser('<%= user_id %>', {
|
2022-03-29 14:21:51 +00:00
|
|
|
identifier_hash: '<%= user_hash %>',
|
2021-02-15 19:28:57 +00:00
|
|
|
email: 'jane@example.com',
|
2021-08-13 11:56:09 +00:00
|
|
|
name: 'Jane Doe',
|
|
|
|
phone_number: ''
|
2021-02-15 19:28:57 +00:00
|
|
|
});
|
|
|
|
}
|
2020-07-25 16:24:58 +00:00
|
|
|
})
|
2022-02-21 04:10:11 +00:00
|
|
|
|
|
|
|
window.addEventListener('chatwoot:error', function(e) {
|
2022-03-29 14:21:51 +00:00
|
|
|
console.log('chatwoot:error', e.detail)
|
2022-02-21 04:10:11 +00:00
|
|
|
})
|
2019-11-01 07:23:01 +00:00
|
|
|
</script>
|