yelda-webchat 1.1.15 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/yeldaWebchatInjector.js +1 -1
- package/dist/js/yeldaWebchatInjector.js.gz +0 -0
- package/dist/js/yeldaWebchatInjector.js.map +1 -1
- package/dist/js/yeldaWebchatInjector.min.js +1 -1
- package/dist/js/yeldaWebchatInjector.min.js.gz +0 -0
- package/dist/js/yeldaWebchatInjector.min.js.map +1 -1
- package/package.json +1 -1
- package/src/config/index.js +2 -1
- package/src/js/yeldaWebchatInjector.js +15 -6
package/package.json
CHANGED
package/src/config/index.js
CHANGED
|
@@ -5,7 +5,8 @@ module.exports = {
|
|
|
5
5
|
DEFAULT_PUBLICATION_STATUS: true,
|
|
6
6
|
ALWAYS_ALLOWED_SITES_REGEX : /^([a-z-]*.yelda.ai|localhost|0.0.0.0|127.0.0.1)$/,
|
|
7
7
|
REGEX_HOST: {
|
|
8
|
-
STAGING: /staging.yelda.ai
|
|
8
|
+
STAGING: /staging.yelda.ai/,
|
|
9
|
+
YELDA: /.yelda.ai/
|
|
9
10
|
},
|
|
10
11
|
HOST: {
|
|
11
12
|
PRODUCTION: 'app.yelda.ai',
|
|
@@ -243,7 +243,7 @@ class YeldaChat {
|
|
|
243
243
|
* @return {String} url
|
|
244
244
|
*/
|
|
245
245
|
createWebChatURL(data) {
|
|
246
|
-
let url = data.
|
|
246
|
+
let url = data.iframeURL
|
|
247
247
|
url = this.updateQueryStringParameter(url, 'assistantId', data.assistantId)
|
|
248
248
|
url = this.updateQueryStringParameter(url, 'assistantSlug', data.assistantSlug)
|
|
249
249
|
url = this.updateQueryStringParameter(url, 'locale', data.locale)
|
|
@@ -625,7 +625,7 @@ class YeldaChat {
|
|
|
625
625
|
|
|
626
626
|
/**
|
|
627
627
|
* Generate webchatURL and create webchatIframe
|
|
628
|
-
* @param {Object} data {
|
|
628
|
+
* @param {Object} data { iframeURL, assistantId, assistantSlug, shouldBeOpened, isStartBtn, canBeClosed }
|
|
629
629
|
*/
|
|
630
630
|
setUpChatIFrame(data) {
|
|
631
631
|
const webchatUrl = this.createWebChatURL(data)
|
|
@@ -653,10 +653,19 @@ class YeldaChat {
|
|
|
653
653
|
* Update data object with assistantId, assistantSlug and locale if needed
|
|
654
654
|
* @param {Object} data { data.assistantUrl, data.chatPath }
|
|
655
655
|
* @param {Object} webchatSettings webchat settings from DB
|
|
656
|
+
* @param {String} href window.location.href
|
|
656
657
|
* @param {Object} data
|
|
657
658
|
*/
|
|
658
|
-
updateAssistantData(data, webchatSettings) {
|
|
659
|
-
if
|
|
659
|
+
updateAssistantData(data, webchatSettings, href) {
|
|
660
|
+
if(!webchatSettings) {
|
|
661
|
+
return data
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// we can overwrite the iframeURL on other domain than yelda ones
|
|
665
|
+
data.iframeURL = (!config.REGEX_HOST.YELDA.test(href) && webchatSettings.iframeURL) || data.iframeURL
|
|
666
|
+
|
|
667
|
+
// if no settingId, no need to go further, because the call has been done with the assistantId & assistantSlug
|
|
668
|
+
if (!data.settingId || !webchatSettings.assistantSlug) {
|
|
660
669
|
return data
|
|
661
670
|
}
|
|
662
671
|
|
|
@@ -697,7 +706,7 @@ class YeldaChat {
|
|
|
697
706
|
*/
|
|
698
707
|
data.assistantUrl = this.setAssistantUrl(data.assistantUrl, window.location.href)
|
|
699
708
|
data.chatPath = chatPath.replace(/^\//, '')
|
|
700
|
-
data.
|
|
709
|
+
data.iframeURL = `${data.assistantUrl}/${data.chatPath}`
|
|
701
710
|
data.locale = data.locale || 'fr_FR'
|
|
702
711
|
data.isAdmin = data.isAdmin ? true : false
|
|
703
712
|
data.isStartBtn = data.isStartBtn ? true : false
|
|
@@ -937,7 +946,7 @@ class YeldaChat {
|
|
|
937
946
|
this.webchatSettings = await this.getAssistantSettings(data, { customTimeout: config.CHAT_BUBBLE_REQUEST_TIMEOUT })
|
|
938
947
|
// Webchat can be loaded thanks to a single settingId or group of data : {assistantId, assistantSlug, locale}
|
|
939
948
|
// If only settingId is provided, then we will fill {assistantId, assistantSlug, locale} thanks to the assistant settings
|
|
940
|
-
data = this.updateAssistantData(data, this.webchatSettings)
|
|
949
|
+
data = this.updateAssistantData(data, this.webchatSettings, window.location.href)
|
|
941
950
|
|
|
942
951
|
} catch (err) {
|
|
943
952
|
this.webchatSettings = null
|