@subiz/widget-v4 4.1.170 → 4.1.173
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/chat.js +18 -1
- package/compiled_src/chatbox/ChatButton.js +1 -0
- package/compiled_src/chatbox/main.js +13 -3
- package/compiled_src/lib.js +3 -0
- package/compiled_src/plugin.js +1 -0
- package/compiled_src/store/api.js +4 -1
- package/compiled_src/store/store.js +17 -10
- package/compiled_src/util/common.js +1 -1
- package/dist/198c50be7a7.app.js +1 -0
- package/dist/{198a92fcacc.chat.html → 198c50be7a7.chat.html} +1 -1
- package/dist/198c50be7a7.chat.js +1 -0
- package/dist/{198a92fcacc.form.html → 198c50be7a7.form.html} +1 -1
- package/dist/198c50be7a7.form.js +1 -0
- package/dist/{198a92fcacc.index.html → 198c50be7a7.index.html} +1 -1
- package/dist/{198a92fcacc.library.html → 198c50be7a7.library.html} +1 -1
- package/dist/198c50be7a7.library.js +1 -0
- package/dist/{198a92fcacc.preview.html → 198c50be7a7.preview.html} +1 -1
- package/dist/198c50be7a7.preview.js +1 -0
- package/dist/{198a92fcacc.chat.js → 198c50be7a7.webview.js} +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +46 -18
- package/package.json +2 -2
- package/src/chatbox/ChatButton.js +3 -0
- package/src/chatbox/main.js +13 -4
- package/src/lib.js +4 -0
- package/src/plugin.js +1 -0
- package/src/store/api.js +4 -1
- package/src/store/store.js +19 -13
- package/src/util/common.js +1 -1
- package/dist/198a92fcacc.app.js +0 -1
- package/dist/198a92fcacc.form.js +0 -1
- package/dist/198a92fcacc.library.js +0 -1
- package/dist/198a92fcacc.preview.js +0 -1
- package/dist/198a92fcacc.webview.js +0 -1
- /package/dist/{198a92fcacc.127.js → 198c50be7a7.127.js} +0 -0
- /package/dist/{198a92fcacc.132.js → 198c50be7a7.132.js} +0 -0
- /package/dist/{198a92fcacc.185.js → 198c50be7a7.185.js} +0 -0
- /package/dist/{198a92fcacc.27.js → 198c50be7a7.27.js} +0 -0
- /package/dist/{198a92fcacc.278.js → 198c50be7a7.278.js} +0 -0
- /package/dist/{198a92fcacc.339.js → 198c50be7a7.339.js} +0 -0
- /package/dist/{198a92fcacc.459.js → 198c50be7a7.459.js} +0 -0
- /package/dist/{198a92fcacc.490.js → 198c50be7a7.490.js} +0 -0
- /package/dist/{198a92fcacc.74.js → 198c50be7a7.74.js} +0 -0
- /package/dist/{198a92fcacc.997.js → 198c50be7a7.997.js} +0 -0
package/chat.js
CHANGED
|
@@ -27,9 +27,13 @@ function runChatbox(subiz) {
|
|
|
27
27
|
|
|
28
28
|
async function run() {
|
|
29
29
|
let accid = getUrlParameter('id') || getUrlParameter('acc_id') || getUrlParameter('account_id')
|
|
30
|
+
let botid = getUrlParameter('bot-id')
|
|
30
31
|
|
|
31
32
|
let subiz = new ApiV4(config.ApiURL, config.FileURL, config.RealtimeURL, true, false)
|
|
32
33
|
window.subiz = subiz
|
|
34
|
+
if (botid) {
|
|
35
|
+
await subiz.overrideBotId(botid)
|
|
36
|
+
}
|
|
33
37
|
subiz._overrideDeviceType('mobile')
|
|
34
38
|
if (window.innerWidth > 760) {
|
|
35
39
|
// table or wider screen
|
|
@@ -42,8 +46,21 @@ async function run() {
|
|
|
42
46
|
document.querySelector('#result_text').textContent = `ERROR: ${res.error} with account id "${accid}"`
|
|
43
47
|
return
|
|
44
48
|
}
|
|
45
|
-
setTimeout(() => {
|
|
49
|
+
setTimeout(async () => {
|
|
46
50
|
subiz.showWidget()
|
|
51
|
+
if (botid) {
|
|
52
|
+
let botM = subiz.store.matchBot() || {}
|
|
53
|
+
let bot = botM[botid] || {}
|
|
54
|
+
console.log('matchbottt', botM)
|
|
55
|
+
subiz.startConvo({
|
|
56
|
+
state: 'active',
|
|
57
|
+
locale: 'vi-VN',
|
|
58
|
+
is_testing: true,
|
|
59
|
+
bot_version: bot.version,
|
|
60
|
+
bot_id: botid,
|
|
61
|
+
welcome_message: bot.welcome_message,
|
|
62
|
+
})
|
|
63
|
+
}
|
|
47
64
|
}, 1)
|
|
48
65
|
}
|
|
49
66
|
|
|
@@ -252,6 +252,7 @@ class ChatButton extends _common.Com {
|
|
|
252
252
|
this._buttonLoaded = true;
|
|
253
253
|
}
|
|
254
254
|
renderButton() {
|
|
255
|
+
if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_button = _index.default.Date.now();
|
|
255
256
|
let accountSetting = this.props.plugin.chatbox;
|
|
256
257
|
accountSetting = this.fixMissingSetting(accountSetting);
|
|
257
258
|
let imgsrc = _index.default.get(accountSetting, 'desktop_button.background_image_url') || _index.default.get(accountSetting, 'desktop_button.background_mask_url') || defaultBubble;
|
|
@@ -68,9 +68,19 @@ class Main extends _common.Com {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
render() {
|
|
71
|
-
if (!this.state.cssready)
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (!this.state.cssready) {
|
|
72
|
+
if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_css_not_ready = _index.default.Date.now();
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
if (_index.default.isUserBanned(this.props.store.matchUser())) {
|
|
76
|
+
if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_user_is_banned = _index.default.Date.now();
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (!this.props.t) {
|
|
80
|
+
if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_no_t = _index.default.Date.now();
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_main = _index.default.Date.now();
|
|
74
84
|
return (0, _preact.h)("div", {
|
|
75
85
|
class: this.props.store.isMobile() ? 'mobile' : 'desktop'
|
|
76
86
|
}, (0, _preact.h)(_ChatButton.default, {
|
package/compiled_src/lib.js
CHANGED
package/compiled_src/plugin.js
CHANGED
|
@@ -225,6 +225,7 @@ class PluginMgr {
|
|
|
225
225
|
});
|
|
226
226
|
});
|
|
227
227
|
let pluginM = this.lib.store.matchPlugin();
|
|
228
|
+
if (typeof sbz_info != 'undefined') sbz_info['plugins'] = pluginM;
|
|
228
229
|
let foundchatbox = false;
|
|
229
230
|
_index.default.each(pluginM, conf => {
|
|
230
231
|
if (conf.type === 'chatbox') {
|
|
@@ -145,8 +145,11 @@ class _default {
|
|
|
145
145
|
_defineProperty(this, "time", _ => ajax.setBaseUrl(this.ApiURL).withCredentials(true).setParser('json').get('/time'));
|
|
146
146
|
_defineProperty(this, "updateUser", data => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}`, data));
|
|
147
147
|
_defineProperty(this, "getUser", _ => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`));
|
|
148
|
-
_defineProperty(this, "getAccountSetting",
|
|
148
|
+
_defineProperty(this, "getAccountSetting", p => {
|
|
149
149
|
let href = _index.default.get(document, 'location.href');
|
|
150
|
+
if (p && p.bot_id) {
|
|
151
|
+
return this.apireq.addQuery('url', href).addQuery('bot_id', p.bot_id).get(`/accounts/${this.accid}/settings`);
|
|
152
|
+
}
|
|
150
153
|
return this.apireq.addQuery('url', href).get(`/accounts/${this.accid}/settings`);
|
|
151
154
|
});
|
|
152
155
|
_defineProperty(this, "sendImpression", impression => this.apireq.post(`/accounts/${this.accid}/campaigns/${impression.campaign_id}/impressions`, impression));
|
|
@@ -355,6 +355,10 @@ class Store {
|
|
|
355
355
|
await this.readyGate.entry();
|
|
356
356
|
this.reconnect();
|
|
357
357
|
}
|
|
358
|
+
async overrideBotId(botid) {
|
|
359
|
+
this.forceBotId = botid;
|
|
360
|
+
await this.readyGate.entry();
|
|
361
|
+
}
|
|
358
362
|
async overrideChatbox(chatbox) {
|
|
359
363
|
this.forceChatbox = chatbox;
|
|
360
364
|
await this.readyGate.entry();
|
|
@@ -599,7 +603,9 @@ class Store {
|
|
|
599
603
|
let fetchuser = p && p.user ? Promise.resolve({
|
|
600
604
|
body: p.user
|
|
601
605
|
}) : this.api.getUser();
|
|
602
|
-
let outs = await Promise.all([fetchuser, this.api.getAccountSetting(
|
|
606
|
+
let outs = await Promise.all([fetchuser, this.api.getAccountSetting({
|
|
607
|
+
bot_id: this.forceBotId
|
|
608
|
+
})]);
|
|
603
609
|
let error = _index.default.find(outs, out => out.error);
|
|
604
610
|
if (error) return console.error(error);
|
|
605
611
|
let set = outs[1].body;
|
|
@@ -833,17 +839,17 @@ class Store {
|
|
|
833
839
|
this.chain.put(cid, oldev.id, _index.default.getMs(oldev.created), oldev);
|
|
834
840
|
this.pubsub.publish('events', oldev);
|
|
835
841
|
}
|
|
836
|
-
if (ev.type === 'message_sent') {
|
|
837
|
-
let idemkey = _index.default.get(ev, 'data.message.idempotency_key');
|
|
838
|
-
let found = _index.default.find(this.listEvents(cid), oldev => oldev.id === idemkey);
|
|
839
|
-
if (found) {
|
|
840
|
-
this.chain.del(cid, found.id);
|
|
841
|
-
ev.created = found.created;
|
|
842
|
-
}
|
|
843
|
-
convo.last_message_sent = ev;
|
|
844
|
-
}
|
|
845
842
|
if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {
|
|
846
843
|
this.chain.put(cid, ev.id, _index.default.getMs(ev.created), ev);
|
|
844
|
+
if (ev.type === 'message_sent') {
|
|
845
|
+
let idemkey = _index.default.get(ev, 'data.message.idempotency_key');
|
|
846
|
+
let found = _index.default.find(this.listEvents(cid), oldev => oldev.id === idemkey);
|
|
847
|
+
if (found) {
|
|
848
|
+
this.chain.del(cid, found.id);
|
|
849
|
+
ev.created = found.created;
|
|
850
|
+
}
|
|
851
|
+
convo.last_message_sent = ev;
|
|
852
|
+
}
|
|
847
853
|
}
|
|
848
854
|
this._setConvo(convo);
|
|
849
855
|
this.pubsub.publish('account');
|
|
@@ -1172,6 +1178,7 @@ class Store {
|
|
|
1172
1178
|
src = src.replace('http://file.subiz.com/', this.FileURL);
|
|
1173
1179
|
src = src.replace('https://file.mysubiz.com/', this.FileURL);
|
|
1174
1180
|
src = src.replace('http://file.mysubiz.com/', this.FileURL);
|
|
1181
|
+
return src;
|
|
1175
1182
|
return src.replace('vcdn.subiz-cdn.com', 'cdn.subiz.net');
|
|
1176
1183
|
}
|
|
1177
1184
|
clearBrowserData() {
|