Files
leadchat/app/views/widget_tests/index.html.erb
Nithin David Thomas 1017903ee1 fix: Adds domain option to user cookies set by SDK [CW-352] (#7070)
* fix: Adds domain option to user cookies set by SDK

* Adds domain to init event from chatwootSettings variable

* Testing multiple domains on heroku

* Updates with sdk from staging

* Removes sdk init code

* Testing why cookie is not getting set

* Cleans up testing code

* Refactors code to fix codeclimate issues

* Update app/javascript/sdk/cookieHelpers.js

Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>

* Adds test cases for setCookieWithDomain

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
2023-06-08 14:27:49 +05:30

63 lines
1.5 KiB
Plaintext

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<%
user_id = 1
user_hash = OpenSSL::HMAC.hexdigest(
'sha256',
@web_widget.hmac_token,
user_id.to_s
)
%>
<script>
window.chatwootSettings = {
hideMessageBubble: false,
// baseDomain: '.loca.lt',
position: '<%= @widget_position %>',
locale: 'en',
useBrowserLanguage: true,
type: '<%= @widget_type %>',
showPopoutButton: true,
widgetStyle: '<%= @widget_style %>',
darkMode: '<%= @dark_mode %>',
};
(function(d,t) {
var BASE_URL = '';
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src= BASE_URL + "/packs/js/sdk.js";
g.defer = true;
g.async = true;
s.parentNode.insertBefore(g,s);
g.onload=function(){
window.chatwootSDK.run({
websiteToken: '<%= @web_widget.website_token %>',
baseUrl: BASE_URL
})
}
})(document,"script");
window.addEventListener('chatwoot:ready', function() {
console.log('chatwoot:ready', window.$chatwoot);
if (window.location.search.includes('setUser')) {
window.$chatwoot.setUser('<%= user_id %>', {
identifier_hash: '<%= user_hash %>',
email: 'jane@example.com',
name: 'Jane Doe',
phone_number: ''
});
}
})
window.addEventListener('chatwoot:error', function(e) {
console.log('chatwoot:error', e.detail)
})
window.addEventListener('chatwoot:on-message', function(e) {
console.log('chatwoot:on-message', e.detail)
})
</script>