@subiz/widget-v4 4.1.197 → 4.1.199
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/assets/img/default_avatar.png +0 -0
- package/assets/img/default_logo.png +0 -0
- package/assets/img/default_logo.svg +5 -0
- package/assets/less/avatar.less +2 -2
- package/assets/less/message.less +5 -0
- package/assets/less/widget.less +1 -1
- package/assets/less/widget_header.less +2 -0
- package/compiled_src/bot.js +3 -18
- package/compiled_src/chatbox/Events.js +1 -0
- package/compiled_src/chatbox/Header.js +2 -2
- package/compiled_src/chatbox/QuickReplies.js +2 -1
- package/compiled_src/chatbox/Widget.js +2 -1
- package/compiled_src/lib.js +56 -27
- package/compiled_src/store/api.js +6 -10
- package/compiled_src/store/store.js +23 -18
- package/dist/{19b9941db90.278.js → 19c2dc9a6ec.278.js} +1 -1
- package/dist/19c2dc9a6ec.app.js +1 -0
- package/dist/{19b9941db90.chat.html → 19c2dc9a6ec.chat.html} +1 -1
- package/dist/19c2dc9a6ec.chat.js +1 -0
- package/dist/{19b9941db90.form.html → 19c2dc9a6ec.form.html} +1 -1
- package/dist/19c2dc9a6ec.form.js +1 -0
- package/dist/{19b9941db90.index.html → 19c2dc9a6ec.index.html} +1 -1
- package/dist/{19b9941db90.library.html → 19c2dc9a6ec.library.html} +1 -1
- package/dist/19c2dc9a6ec.library.js +1 -0
- package/dist/{19b9941db90.preview.html → 19c2dc9a6ec.preview.html} +1 -1
- package/dist/19c2dc9a6ec.preview.js +1 -0
- package/dist/19c2dc9a6ec.webview.js +1 -0
- package/dist/DEVHASH +1 -0
- package/dist/HASH +1 -1
- package/dist/assets/img/default_avatar.e449b04.png +0 -0
- package/dist/assets/img/default_logo.dd13a2b.svg +5 -0
- package/dist/screenshoot.js +106 -71
- package/package.json +8 -8
- package/src/bot.js +4 -14
- package/src/chatbox/Events.js +1 -1
- package/src/chatbox/Header.js +2 -2
- package/src/chatbox/QuickReplies.js +10 -10
- package/src/chatbox/Widget.js +2 -2
- package/src/lib.js +45 -20
- package/src/store/api.js +6 -6
- package/src/store/store.js +20 -13
- package/dist/19b9941db90.app.js +0 -1
- package/dist/19b9941db90.chat.js +0 -1
- package/dist/19b9941db90.form.js +0 -1
- package/dist/19b9941db90.library.js +0 -1
- package/dist/19b9941db90.preview.js +0 -1
- package/dist/19b9941db90.webview.js +0 -1
- package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
- package/dist/assets/img/rating--poor.2938a25.svg +0 -12
- /package/dist/{19b9941db90.127.js → 19c2dc9a6ec.127.js} +0 -0
- /package/dist/{19b9941db90.132.js → 19c2dc9a6ec.132.js} +0 -0
- /package/dist/{19b9941db90.185.js → 19c2dc9a6ec.185.js} +0 -0
- /package/dist/{19b9941db90.27.js → 19c2dc9a6ec.27.js} +0 -0
- /package/dist/{19b9941db90.339.js → 19c2dc9a6ec.339.js} +0 -0
- /package/dist/{19b9941db90.459.js → 19c2dc9a6ec.459.js} +0 -0
- /package/dist/{19b9941db90.490.js → 19c2dc9a6ec.490.js} +0 -0
- /package/dist/{19b9941db90.74.js → 19c2dc9a6ec.74.js} +0 -0
- /package/dist/{19b9941db90.997.js → 19c2dc9a6ec.997.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.199",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@subiz/flow": "^1.1.0",
|
|
14
14
|
"@subiz/wsclient": "^4.0.34",
|
|
15
15
|
"cookie_js": "1.4.2",
|
|
16
|
-
"core-js": "^3.
|
|
16
|
+
"core-js": "^3.48.0",
|
|
17
17
|
"css-loader": "5.2.7",
|
|
18
18
|
"file-loader": "^6.2.0",
|
|
19
19
|
"less": "^4.5.1",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@babel/cli": "^7.28.6",
|
|
25
|
-
"@babel/core": "^7.
|
|
25
|
+
"@babel/core": "^7.29.0",
|
|
26
26
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
27
27
|
"@babel/plugin-transform-react-jsx": "^7.28.6",
|
|
28
|
-
"@babel/preset-env": "^7.
|
|
28
|
+
"@babel/preset-env": "^7.29.0",
|
|
29
29
|
"babel-loader": "^10.0.0",
|
|
30
30
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
31
|
-
"html-webpack-plugin": "^5.6.
|
|
32
|
-
"puppeteer": "^24.
|
|
33
|
-
"webpack": "^5.
|
|
34
|
-
"webpack-bundle-analyzer": "^5.
|
|
31
|
+
"html-webpack-plugin": "^5.6.6",
|
|
32
|
+
"puppeteer": "^24.37.0",
|
|
33
|
+
"webpack": "^5.105.0",
|
|
34
|
+
"webpack-bundle-analyzer": "^5.2.0",
|
|
35
35
|
"webpack-cli": "^6.0.1",
|
|
36
36
|
"webpack-dev-server": "^5.2.3"
|
|
37
37
|
}
|
package/src/bot.js
CHANGED
|
@@ -11,27 +11,17 @@ export default function (store) {
|
|
|
11
11
|
run = () => true // dont run twice
|
|
12
12
|
let match = sb.checkRunConditions(bot.initiative_frequency, bot.conditions, store.matchLastBotRun(bot.id), store)
|
|
13
13
|
if (!match) return
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
let welcomMessages = bot.welcome_messages
|
|
16
|
+
if (sb.size(welcomMessages)) {
|
|
16
17
|
let {error} = await store.startLightConvo(
|
|
17
18
|
bot.id,
|
|
18
|
-
bot.
|
|
19
|
+
bot.welcome_messages,
|
|
19
20
|
common.getLocale(bot, sb.detectLang()),
|
|
20
21
|
false,
|
|
21
22
|
)
|
|
22
|
-
if (error) return console.error(error)
|
|
23
23
|
store.logBotRun(bot.id)
|
|
24
|
-
return
|
|
25
24
|
}
|
|
26
|
-
// old bot, should deprecated
|
|
27
|
-
let {error} = await store.startConvo({
|
|
28
|
-
initial_by: bot.id,
|
|
29
|
-
locale: common.getLocale(bot, sb.detectLang()),
|
|
30
|
-
state: 'active',
|
|
31
|
-
members: [{type: 'bot', id: bot.id}],
|
|
32
|
-
})
|
|
33
|
-
if (error) return console.error(error)
|
|
34
|
-
store.logBotRun(bot.id)
|
|
35
25
|
}
|
|
36
26
|
|
|
37
27
|
let triggers = sb.get(bot, 'triggers') || []
|
package/src/chatbox/Events.js
CHANGED
|
@@ -206,7 +206,7 @@ export default class Events extends Com {
|
|
|
206
206
|
if (this.state.loading) $tryAgainBtn = <Spinner size='16' mode='blue' />
|
|
207
207
|
return (
|
|
208
208
|
<div class='widget-body--events-container widget-body--events-container__error'>
|
|
209
|
-
<img alt='empty' src={convoemptyimg} />
|
|
209
|
+
<img alt='empty' class='widget_body_empty_img' src={convoemptyimg} />
|
|
210
210
|
<div class='widget_body__events__error_msg'>{this.props.t('load_convo_error')}</div>
|
|
211
211
|
<div class='widget_body__events__error_retry'>{$tryAgainBtn}</div>
|
|
212
212
|
</div>
|
package/src/chatbox/Header.js
CHANGED
|
@@ -20,7 +20,7 @@ export default class Header extends Com {
|
|
|
20
20
|
height={38}
|
|
21
21
|
alt={acc.name}
|
|
22
22
|
class='avatar avatar__account'
|
|
23
|
-
src={this.props.store.replaceFileUrl(logo_url) || require('../../assets/img/
|
|
23
|
+
src={this.props.store.replaceFileUrl(logo_url) || require('../../assets/img/default_logo.svg')}
|
|
24
24
|
/>
|
|
25
25
|
)
|
|
26
26
|
}
|
|
@@ -37,7 +37,7 @@ export default class Header extends Com {
|
|
|
37
37
|
width={38}
|
|
38
38
|
height={38}
|
|
39
39
|
class='avatar avatar__account'
|
|
40
|
-
src={this.props.store.replaceFileUrl(logoUrl) || require('../../assets/img/
|
|
40
|
+
src={this.props.store.replaceFileUrl(logoUrl) || require('../../assets/img/default_logo.svg')}
|
|
41
41
|
/>
|
|
42
42
|
)
|
|
43
43
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import sb from '../util/index.js'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {Com} from '../common.js'
|
|
3
|
+
import {h} from 'preact'
|
|
4
4
|
|
|
5
5
|
// props: [ ev],
|
|
6
6
|
export default class QuickReplies extends Com {
|
|
7
|
-
constructor
|
|
7
|
+
constructor(props) {
|
|
8
8
|
super(props)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
render
|
|
11
|
+
render() {
|
|
12
12
|
if (sb.get(this.props.ev, 'by.type') === 'user') return null
|
|
13
13
|
|
|
14
14
|
let quickreplies = []
|
|
15
|
-
sb.map(sb.get(this.props.ev, 'data.message.attachments', []), att => {
|
|
15
|
+
sb.map(sb.get(this.props.ev, 'data.message.attachments', []), (att) => {
|
|
16
16
|
if (!att) return
|
|
17
17
|
if (att.type === 'quick_replies') {
|
|
18
18
|
quickreplies = sb.get(att, 'quick_replies', [])
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
quickreplies = sb.filter(quickreplies, r => r.title)
|
|
22
|
+
quickreplies = sb.filter(quickreplies, (r) => r.title)
|
|
23
23
|
|
|
24
24
|
if (quickreplies.length === 0) return null
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ export default class QuickReplies extends Com {
|
|
|
29
29
|
|
|
30
30
|
// has user msg bellow => dont show
|
|
31
31
|
let events = sb.map(this.props.store.listEvents(cid))
|
|
32
|
-
events = sb.orderBy(events, 'created', 'asc').filter(ev => ev.type === 'message_sent')
|
|
32
|
+
events = sb.orderBy(events, 'created', 'asc').filter((ev) => ev.type === 'message_sent')
|
|
33
33
|
let evindex = 0
|
|
34
34
|
for (var i = 0; i < events.length; i++) {
|
|
35
35
|
if (events[i].id === this.props.ev.id) {
|
|
@@ -42,12 +42,12 @@ export default class QuickReplies extends Com {
|
|
|
42
42
|
if (sb.get(events[i], 'by.type') === 'user') return null
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
let $replies = sb.map(quickreplies, r => (
|
|
46
|
-
<div class=
|
|
45
|
+
let $replies = sb.map(quickreplies, (r) => (
|
|
46
|
+
<div class='message_quick_reply' onClick={(e) => this.props.onSelect(r)} title={r.title}>
|
|
47
47
|
{r.title}
|
|
48
48
|
</div>
|
|
49
49
|
))
|
|
50
50
|
|
|
51
|
-
return <div class=
|
|
51
|
+
return <div class='message_quick_replies'>{$replies}</div>
|
|
52
52
|
}
|
|
53
53
|
}
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -753,7 +753,7 @@ export default class Widget extends Com {
|
|
|
753
753
|
$body = (
|
|
754
754
|
<div class='convo-list--list'>
|
|
755
755
|
<div class='empty-container'>
|
|
756
|
-
<img alt='empty' src={empty} />
|
|
756
|
+
<img class='widget_body_empty_img' alt='empty' src={empty} />
|
|
757
757
|
<div class='empty-desc'>{this.props.t('empty_convo')}</div>
|
|
758
758
|
</div>
|
|
759
759
|
</div>
|
|
@@ -855,7 +855,7 @@ export default class Widget extends Com {
|
|
|
855
855
|
locale: this.props.t.locale(),
|
|
856
856
|
message: text,
|
|
857
857
|
members: [{type: 'bot', id: botid, bot_version: oldconvo.bot_version}],
|
|
858
|
-
initial_by:
|
|
858
|
+
initial_by: botid,
|
|
859
859
|
is_testing: oldconvo.is_testing,
|
|
860
860
|
greeting_message: greeting_msg,
|
|
861
861
|
})
|
package/src/lib.js
CHANGED
|
@@ -214,34 +214,59 @@ class Widget {
|
|
|
214
214
|
|
|
215
215
|
// cpxdf, [{key:'fullname', type:'text', value: 'thanhpk@liec.om'}]
|
|
216
216
|
async submitForm(formid, values) {
|
|
217
|
-
if (!formid || !
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
217
|
+
if (!formid || !values) return
|
|
218
|
+
if (sb.startsWith(formid, 'cp')) {
|
|
219
|
+
let storeuser = sb.cloneDeep(this.store.matchUser())
|
|
220
|
+
let user = {id: storeuser.id, account_id: storeuser.account_id}
|
|
221
|
+
|
|
222
|
+
let is_lead = false
|
|
223
|
+
|
|
224
|
+
values = sb.map(values, (val) => {
|
|
225
|
+
let key = val.key
|
|
226
|
+
if (key === 'email') key = 'emails'
|
|
227
|
+
if (key === 'phone') key = 'phones'
|
|
228
|
+
is_lead = is_lead || key == 'emails' || key == 'phones'
|
|
229
|
+
sb.setUserAttr(user, {key: key, [val.type || 'text']: val.value})
|
|
230
|
+
return {key: key, type: val.type || 'text', value: sb.stringify(val.value)}
|
|
231
|
+
})
|
|
231
232
|
|
|
232
|
-
|
|
233
|
+
if (is_lead) sb.setUserAttr(user, {key: 'lead_source', text: 'plugin.' + formid})
|
|
234
|
+
|
|
235
|
+
// must update user
|
|
236
|
+
let impressiontoken = await this.viewForm(formid)
|
|
237
|
+
this.store.setUserDiff(user)
|
|
238
|
+
return this.store.sendConversion(formid, values, impressiontoken)
|
|
239
|
+
}
|
|
233
240
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
241
|
+
values = sb.filter(values, (field) => {
|
|
242
|
+
return field.key && field.value
|
|
243
|
+
})
|
|
244
|
+
let text = 'Khách điền form\n'
|
|
245
|
+
sb.map(values, (field) => {
|
|
246
|
+
text += '+ ' + field.key + ': ' + field.value + '\n'
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
return this.store.startConvo({
|
|
250
|
+
subject: 'Khách điền form',
|
|
251
|
+
touchpoint: {
|
|
252
|
+
channel: 'form',
|
|
253
|
+
source: window.location.hostname,
|
|
254
|
+
id: Date.now() + '_' + sb.randomString(),
|
|
255
|
+
},
|
|
256
|
+
form_submission: {id: formid, values: values},
|
|
257
|
+
message_sent: {
|
|
258
|
+
data: {
|
|
259
|
+
message: {format: 'plaintext', text: text},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
})
|
|
238
263
|
}
|
|
239
264
|
|
|
240
265
|
// req.bot_id != "" -> start conversation with bot id
|
|
241
266
|
startConvo(req) {
|
|
242
267
|
req = sb.cloneDeep(req) || {}
|
|
243
268
|
if (req.welcome_message) {
|
|
244
|
-
return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version)
|
|
269
|
+
return this.store.startLightConvo(req.bot_id, [req.welcome_message], req.locale, req.is_testing, req.bot_version)
|
|
245
270
|
}
|
|
246
271
|
let members = req.members || []
|
|
247
272
|
if (req.bot_id) {
|
package/src/store/api.js
CHANGED
|
@@ -246,12 +246,12 @@ export default class {
|
|
|
246
246
|
|
|
247
247
|
ajax = ajax
|
|
248
248
|
|
|
249
|
-
start = (extraData) => {
|
|
250
|
-
let data = {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
start = (extraData, tpchannel, tpsource, tpid) => {
|
|
250
|
+
let data = Object.assign({}, extraData)
|
|
251
|
+
if (!data.touchpoint) data.touchpoint = {}
|
|
252
|
+
if (!data.touchpoint.channel) data.touchpoint.channel = 'subiz'
|
|
253
|
+
if (!data.touchpoint.source) data.touchpoint.source = 'web'
|
|
254
|
+
data.source = sb.get(document, 'location.href')
|
|
255
255
|
return this.apireq.post(`/accounts/${this.accid}/conversations`, data)
|
|
256
256
|
}
|
|
257
257
|
|
package/src/store/store.js
CHANGED
|
@@ -846,7 +846,7 @@ export default class Store {
|
|
|
846
846
|
setting = sb.cloneDeep(setting) || {}
|
|
847
847
|
setting.account = Object.assign({}, setting.account, this.forceAcc)
|
|
848
848
|
if (!setting.account.logo_url) {
|
|
849
|
-
setting.account.logo_url = 'https://vcdn.subiz-cdn.com/
|
|
849
|
+
setting.account.logo_url = 'https://vcdn.subiz-cdn.com/widget-v4/public/assets/img/default_logo.dd13a2b.svg'
|
|
850
850
|
}
|
|
851
851
|
// user && session
|
|
852
852
|
if (setting.user) {
|
|
@@ -1121,28 +1121,34 @@ export default class Store {
|
|
|
1121
1121
|
this.kv.put('light_convos', this.lightConvos)
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
1124
|
-
startLightConvo(botid,
|
|
1124
|
+
startLightConvo(botid, messages, locale, is_testing, botversion) {
|
|
1125
1125
|
let convoid = 'cslight' + botid + '_' + this.now()
|
|
1126
1126
|
let user = this.cache.match('user') || {}
|
|
1127
1127
|
|
|
1128
1128
|
let old = this.lightConvos[convoid]
|
|
1129
1129
|
if (old) return {convo: old}
|
|
1130
1130
|
let now = this.now()
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1131
|
+
|
|
1132
|
+
let lastev = {}
|
|
1133
|
+
let newevs = sb.map(messages, (message, idx) => {
|
|
1134
|
+
let ev = {}
|
|
1135
|
+
ev.created = now
|
|
1136
|
+
ev.event_time = now
|
|
1137
|
+
ev.id = 'evfake' + now + idx
|
|
1138
|
+
ev.type = 'message_sent'
|
|
1139
|
+
ev.by = {id: botid, type: 'bot'}
|
|
1140
|
+
ev.data = {message: message}
|
|
1141
|
+
ev.data.message.conversation_id = convoid
|
|
1142
|
+
lastev = ev
|
|
1143
|
+
return ev
|
|
1144
|
+
})
|
|
1139
1145
|
let newconvo = {
|
|
1140
1146
|
id: convoid,
|
|
1141
1147
|
locale: locale,
|
|
1142
1148
|
initial_by: botid,
|
|
1143
1149
|
created: now,
|
|
1144
1150
|
actived: now,
|
|
1145
|
-
last_message_sent:
|
|
1151
|
+
last_message_sent: lastev,
|
|
1146
1152
|
members: [
|
|
1147
1153
|
{type: 'user', id: user.id},
|
|
1148
1154
|
{type: 'bot', id: botid, membership: 'active'},
|
|
@@ -1150,13 +1156,14 @@ export default class Store {
|
|
|
1150
1156
|
state: 'active',
|
|
1151
1157
|
touchpoint: {id: convoid, channel: 'subiz', source: 'web'},
|
|
1152
1158
|
traffic_source: 'direct',
|
|
1153
|
-
events:
|
|
1159
|
+
events: newevs,
|
|
1160
|
+
//events: [ev],
|
|
1154
1161
|
is_testing: is_testing,
|
|
1155
1162
|
bot_versio: botversion,
|
|
1156
1163
|
}
|
|
1157
1164
|
this.lightConvos[convoid] = newconvo
|
|
1158
1165
|
this.kv.put('light_convos', this.lightConvos)
|
|
1159
|
-
this.pubsub.publish('events',
|
|
1166
|
+
this.pubsub.publish('events', lastev)
|
|
1160
1167
|
return {convo: newconvo}
|
|
1161
1168
|
}
|
|
1162
1169
|
|