@subiz/widget-v4 4.1.199 → 4.1.201
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/less/message.less +1 -1
- package/assets/less/widget_header.less +0 -1
- package/compiled_src/bot.js +10 -0
- package/compiled_src/chatbox/Event.js +1 -1
- package/compiled_src/chatbox/Events.js +2 -1
- package/compiled_src/chatbox/Widget.js +5 -2
- package/compiled_src/lib.js +1 -0
- package/compiled_src/plugin.js +1 -0
- package/compiled_src/store/store.js +11 -4
- package/compiled_src/util/common.js +27 -14
- package/compiled_src/util/common.test.js +43 -133
- package/dist/132.js +21 -21
- package/dist/185.js +49 -49
- package/dist/{19c2dc9a6ec.132.js → 19d6b530a9c.132.js} +1 -1
- package/dist/19d6b530a9c.185.js +1 -0
- package/dist/{19c2dc9a6ec.27.js → 19d6b530a9c.27.js} +1 -1
- package/dist/19d6b530a9c.278.js +1 -0
- package/dist/19d6b530a9c.339.js +1 -0
- package/dist/19d6b530a9c.459.js +1 -0
- package/dist/19d6b530a9c.app.js +1 -0
- package/dist/{19c2dc9a6ec.chat.html → 19d6b530a9c.chat.html} +1 -1
- package/dist/19d6b530a9c.chat.js +1 -0
- package/dist/{19c2dc9a6ec.form.html → 19d6b530a9c.form.html} +1 -1
- package/dist/19d6b530a9c.form.js +1 -0
- package/dist/{19c2dc9a6ec.index.html → 19d6b530a9c.index.html} +1 -1
- package/dist/{19c2dc9a6ec.library.html → 19d6b530a9c.library.html} +1 -1
- package/dist/19d6b530a9c.library.js +1 -0
- package/dist/{19c2dc9a6ec.preview.html → 19d6b530a9c.preview.html} +1 -1
- package/dist/19d6b530a9c.preview.js +1 -0
- package/dist/19d6b530a9c.webview.js +1 -0
- package/dist/27.js +1 -1
- package/dist/459.js +12 -12
- package/dist/74.js +1 -0
- package/dist/HASH +1 -1
- package/dist/assets/img/rating--poor.2938a25.svg +12 -0
- package/dist/screenshoot.js +3083 -3050
- package/examples/track.js +41 -0
- package/package.json +10 -9
- package/src/bot.js +10 -0
- package/src/chatbox/Event.js +1 -1
- package/src/chatbox/Events.js +2 -1
- package/src/chatbox/Widget.js +6 -2
- package/src/lib.js +2 -0
- package/src/plugin.js +1 -0
- package/src/store/store.js +19 -11
- package/src/util/common.js +31 -16
- package/src/util/common.test.js +108 -193
- package/dist/19c2dc9a6ec.185.js +0 -1
- package/dist/19c2dc9a6ec.278.js +0 -1
- package/dist/19c2dc9a6ec.339.js +0 -1
- package/dist/19c2dc9a6ec.459.js +0 -1
- package/dist/19c2dc9a6ec.app.js +0 -1
- package/dist/19c2dc9a6ec.chat.js +0 -1
- package/dist/19c2dc9a6ec.form.js +0 -1
- package/dist/19c2dc9a6ec.library.js +0 -1
- package/dist/19c2dc9a6ec.preview.js +0 -1
- package/dist/19c2dc9a6ec.webview.js +0 -1
- package/dist/DEVHASH +0 -1
- /package/dist/{19c2dc9a6ec.127.js → 19d6b530a9c.127.js} +0 -0
- /package/dist/{19c2dc9a6ec.490.js → 19d6b530a9c.490.js} +0 -0
- /package/dist/{19c2dc9a6ec.74.js → 19d6b530a9c.74.js} +0 -0
- /package/dist/{19c2dc9a6ec.997.js → 19d6b530a9c.997.js} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// place order
|
|
2
|
+
subiz('track', {
|
|
3
|
+
type: 'order_created',
|
|
4
|
+
data: {
|
|
5
|
+
order: {
|
|
6
|
+
items: [
|
|
7
|
+
{
|
|
8
|
+
name: 'box for a cat',
|
|
9
|
+
sku: '45350835',
|
|
10
|
+
quantity: 1,
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
currency: 'VND',
|
|
14
|
+
total: 100000,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// created item
|
|
20
|
+
subiz('track', {
|
|
21
|
+
type: 'item_created',
|
|
22
|
+
custom_data: {
|
|
23
|
+
name: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
string: 'cat box',
|
|
26
|
+
},
|
|
27
|
+
url: {
|
|
28
|
+
type: 'url',
|
|
29
|
+
url: 'https://example.com',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// created item
|
|
35
|
+
subiz('track', {
|
|
36
|
+
type: 'item_created',
|
|
37
|
+
custom_data: {
|
|
38
|
+
name: 'cat box',
|
|
39
|
+
url: 'https://example.com',
|
|
40
|
+
},
|
|
41
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.201",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -13,26 +13,27 @@
|
|
|
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.49.0",
|
|
17
17
|
"css-loader": "5.2.7",
|
|
18
18
|
"file-loader": "^6.2.0",
|
|
19
|
-
"less": "^4.
|
|
20
|
-
"less-loader": "^12.3.
|
|
19
|
+
"less": "^4.6.4",
|
|
20
|
+
"less-loader": "^12.3.2",
|
|
21
21
|
"preact": "10.19.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"tape": "^5.9.0",
|
|
24
25
|
"@babel/cli": "^7.28.6",
|
|
25
26
|
"@babel/core": "^7.29.0",
|
|
26
27
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
27
28
|
"@babel/plugin-transform-react-jsx": "^7.28.6",
|
|
28
|
-
"@babel/preset-env": "^7.29.
|
|
29
|
-
"babel-loader": "^10.
|
|
29
|
+
"@babel/preset-env": "^7.29.2",
|
|
30
|
+
"babel-loader": "^10.1.1",
|
|
30
31
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
31
32
|
"html-webpack-plugin": "^5.6.6",
|
|
32
|
-
"puppeteer": "^24.
|
|
33
|
-
"webpack": "^5.105.
|
|
33
|
+
"puppeteer": "^24.40.0",
|
|
34
|
+
"webpack": "^5.105.4",
|
|
34
35
|
"webpack-bundle-analyzer": "^5.2.0",
|
|
35
|
-
"webpack-cli": "^
|
|
36
|
+
"webpack-cli": "^7.0.2",
|
|
36
37
|
"webpack-dev-server": "^5.2.3"
|
|
37
38
|
}
|
|
38
39
|
}
|
package/src/bot.js
CHANGED
|
@@ -13,6 +13,16 @@ export default function (store) {
|
|
|
13
13
|
if (!match) return
|
|
14
14
|
|
|
15
15
|
let welcomMessages = bot.welcome_messages
|
|
16
|
+
welcomMessages = sb.filter(welcomMessages, (msg) => {
|
|
17
|
+
if (!sb.size(msg.attachments)) {
|
|
18
|
+
if (msg.block || msg.format === 'block') {
|
|
19
|
+
if (sb.isBlockEmpty(msg.block)) return false
|
|
20
|
+
} else {
|
|
21
|
+
if (!(msg.text || '').trim()) return false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return true
|
|
25
|
+
})
|
|
16
26
|
if (sb.size(welcomMessages)) {
|
|
17
27
|
let {error} = await store.startLightConvo(
|
|
18
28
|
bot.id,
|
package/src/chatbox/Event.js
CHANGED
|
@@ -451,7 +451,7 @@ export default class Event extends Com {
|
|
|
451
451
|
<div class='message-event-action-btn-svg dislike' />
|
|
452
452
|
</div>
|
|
453
453
|
</div>
|
|
454
|
-
{sb.get(this.props.event, 'is_end') && (
|
|
454
|
+
{sb.get(this.props.event, 'is_end') && !this.props.isConvoEnded && (
|
|
455
455
|
<div class='message-event-actions-static'>
|
|
456
456
|
<div class={likecls} onClick={() => this.onSendReaction(hasLike ? 'remove_like' : 'like')}>
|
|
457
457
|
<div class='message-event-action-btn-svg like' />
|
package/src/chatbox/Events.js
CHANGED
|
@@ -148,7 +148,7 @@ export default class Events extends Com {
|
|
|
148
148
|
events.push(fakeev)
|
|
149
149
|
|
|
150
150
|
let $events = sb.map(events, (ev) => {
|
|
151
|
-
let isLast = ev.is_last_message_send
|
|
151
|
+
let isLast = ev.is_last_message_send && sb.get(convo, 'state') !== 'ended'
|
|
152
152
|
return (
|
|
153
153
|
<Event
|
|
154
154
|
isLast={isLast}
|
|
@@ -160,6 +160,7 @@ export default class Events extends Com {
|
|
|
160
160
|
onPostback={this.props.onPostback}
|
|
161
161
|
onFocusSourceEventFromQuote={this.onFocusSourceEventFromQuote}
|
|
162
162
|
ref={(ele) => this.setEventChildRef(ele, ev.ev.id)}
|
|
163
|
+
isConvoEnded={sb.get(convo, 'state') === 'ended'}
|
|
163
164
|
event={ev}
|
|
164
165
|
t={this.props.t}
|
|
165
166
|
key={ev.ev.id}
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -27,6 +27,8 @@ export default class Widget extends Com {
|
|
|
27
27
|
constructor(props) {
|
|
28
28
|
super(props)
|
|
29
29
|
this.userSent = {}
|
|
30
|
+
|
|
31
|
+
this.debugAgentSentEvIds = {}
|
|
30
32
|
// check user had input form
|
|
31
33
|
this.wasFormInputed = false
|
|
32
34
|
this.setState({
|
|
@@ -69,10 +71,12 @@ export default class Widget extends Com {
|
|
|
69
71
|
if (sb.get(ev, 'by.type') === 'user') return
|
|
70
72
|
|
|
71
73
|
console.log('check ev pass condition', ev)
|
|
72
|
-
if (!messageSentDict[ev.id]) {
|
|
74
|
+
if (!messageSentDict[ev.id] && !this.debugAgentSentEvIds[ev.id]) {
|
|
75
|
+
let accid = sb.get(this.props.store.matchAccount(), 'id')
|
|
73
76
|
this.props.store.sendBugReport(
|
|
74
|
-
|
|
77
|
+
`[WIDGET ${accid}] Missing agent message sent evid ${ev.id}, cid ${sb.convoOfEv(ev)}, ev_created ${ev.created}, FE timestamp ${Date.now()}, Init Debug timestamp ${started}`,
|
|
75
78
|
)
|
|
79
|
+
this.debugAgentSentEvIds[ev.id] = true
|
|
76
80
|
}
|
|
77
81
|
})
|
|
78
82
|
})
|
package/src/lib.js
CHANGED
|
@@ -84,6 +84,8 @@ class Widget {
|
|
|
84
84
|
let ref = param.ref
|
|
85
85
|
|
|
86
86
|
let user = await this.store.init(accid, undefined, ref, param)
|
|
87
|
+
|
|
88
|
+
if (this.store.isDead()) return user
|
|
87
89
|
sb.setTimeout(() => window.postMessage({type: 'widget_loaded', account_id: accid}, '*'), 0) // send to chrome extension
|
|
88
90
|
|
|
89
91
|
// add container to client site
|
package/src/plugin.js
CHANGED
|
@@ -12,6 +12,7 @@ function Plugin(plugin, store, $container, lib) {
|
|
|
12
12
|
if (!$container) throw '$div must is a valid html node'
|
|
13
13
|
var $div = document.createElement('div')
|
|
14
14
|
$div.id = plugin.id
|
|
15
|
+
if (store.isDead()) return
|
|
15
16
|
let acc = store.matchAccount()
|
|
16
17
|
$div.setAttribute('sbz-plugin-type', plugin.type)
|
|
17
18
|
$div.setAttribute('sbz-plugin-account-id', acc.id)
|
package/src/store/store.js
CHANGED
|
@@ -904,18 +904,23 @@ export default class Store {
|
|
|
904
904
|
}
|
|
905
905
|
|
|
906
906
|
// send the content view, the first presence and record domain
|
|
907
|
-
async track() {
|
|
908
|
-
|
|
909
|
-
this.
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
907
|
+
async track(e) {
|
|
908
|
+
if (!e) {
|
|
909
|
+
let out = await this.api.sendContentView(
|
|
910
|
+
this.device,
|
|
911
|
+
location.href,
|
|
912
|
+
document.title,
|
|
913
|
+
this._currentViewingProduct.id,
|
|
914
|
+
this._currentViewingProduct.source_id,
|
|
915
|
+
this._currentViewingProduct.sku,
|
|
916
|
+
)
|
|
917
|
+
|
|
918
|
+
let traffic_source = sb.get(out, 'body.by.device.source', '')
|
|
919
|
+
if (traffic_source) this.kv.put('traffic_source', traffic_source)
|
|
920
|
+
return
|
|
921
|
+
}
|
|
916
922
|
|
|
917
|
-
|
|
918
|
-
if (traffic_source) this.kv.put('traffic_source', traffic_source)
|
|
923
|
+
return this.api.sendEvent(e)
|
|
919
924
|
}
|
|
920
925
|
|
|
921
926
|
matchTrafficSource = () => this.kv.match('traffic_source')
|
|
@@ -1474,6 +1479,9 @@ export default class Store {
|
|
|
1474
1479
|
this.pubsub.publish('destroy')
|
|
1475
1480
|
}
|
|
1476
1481
|
|
|
1482
|
+
isDead() {
|
|
1483
|
+
return this._die
|
|
1484
|
+
}
|
|
1477
1485
|
destroy() {
|
|
1478
1486
|
this._die = true
|
|
1479
1487
|
this.clearBrowserData()
|
package/src/util/common.js
CHANGED
|
@@ -950,22 +950,8 @@ export function checkRunConditions(freq, conds, lastrun, store) {
|
|
|
950
950
|
var cond = conds[i]
|
|
951
951
|
switch (cond.key) {
|
|
952
952
|
case 'url':
|
|
953
|
-
|
|
954
|
-
if (
|
|
955
|
-
let found = find(exclude_urls, (url) => {
|
|
956
|
-
return norm(window.location.href).indexOf(norm(url)) > -1
|
|
957
|
-
})
|
|
958
|
-
if (found) return false
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
// ignore empty url
|
|
962
|
-
let urls = filter(cond.urls, (url) => norm(url))
|
|
963
|
-
if (size(urls) > 0) {
|
|
964
|
-
let found = find(urls, (url) => {
|
|
965
|
-
return norm(window.location.href).indexOf(norm(url)) > -1
|
|
966
|
-
})
|
|
967
|
-
if (!found) return false
|
|
968
|
-
}
|
|
953
|
+
// url = qlhd.minvoice.com.vn, exclude_urls ["minvoice.com.vn","minvoice.net","hdt.minvoice.com.vn"], urls ["qlhd.minvoice.com.vn"] => must pass
|
|
954
|
+
if (!checkUrlCondition(cond, window.location.href)) return false
|
|
969
955
|
break
|
|
970
956
|
case 'url_path':
|
|
971
957
|
let excludePaths = filter(cond.exclude_url_paths, (url) => norm(url))
|
|
@@ -1616,3 +1602,32 @@ function isEmptyAttachment(msg) {
|
|
|
1616
1602
|
) == 0
|
|
1617
1603
|
)
|
|
1618
1604
|
}
|
|
1605
|
+
export function checkUrlCondition(cond, href) {
|
|
1606
|
+
// url = qlhd.minvoice.com.vn, exclude_urls ["minvoice.com.vn","minvoice.net","hdt.minvoice.com.vn"], urls ["qlhd.minvoice.com.vn"] => must pass
|
|
1607
|
+
let exclude_urls = filter(cond.exclude_urls, (url) => norm(url))
|
|
1608
|
+
let foundExclude = false
|
|
1609
|
+
let excludeLen = 0
|
|
1610
|
+
map(exclude_urls, (url) => {
|
|
1611
|
+
if (norm(href).indexOf(url) > -1) {
|
|
1612
|
+
if (excludeLen < size(url)) excludeLen = size(url)
|
|
1613
|
+
foundExclude = true
|
|
1614
|
+
}
|
|
1615
|
+
})
|
|
1616
|
+
|
|
1617
|
+
// ignore empty url
|
|
1618
|
+
let includeLen = 0
|
|
1619
|
+
let urls = filter(cond.urls, (url) => norm(url))
|
|
1620
|
+
let foundInclude = size(urls) == 0
|
|
1621
|
+
map(urls, (url) => {
|
|
1622
|
+
if (norm(href).indexOf(url) > -1) {
|
|
1623
|
+
if (includeLen < size(url)) includeLen = size(url)
|
|
1624
|
+
foundInclude = true
|
|
1625
|
+
}
|
|
1626
|
+
})
|
|
1627
|
+
if (foundExclude) {
|
|
1628
|
+
if (excludeLen >= includeLen) return false
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
if (!foundInclude) return false
|
|
1632
|
+
return true
|
|
1633
|
+
}
|