@subiz/widget-v4 4.1.196 → 4.1.198

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.
Files changed (31) hide show
  1. package/compiled_src/chatbox/Header.js +5 -3
  2. package/compiled_src/lib.js +55 -26
  3. package/compiled_src/store/api.js +6 -10
  4. package/dist/{19b9941db90.app.js → 19bbfd5aa77.app.js} +1 -1
  5. package/dist/{19b9941db90.chat.html → 19bbfd5aa77.chat.html} +1 -1
  6. package/dist/{19b9941db90.chat.js → 19bbfd5aa77.chat.js} +1 -1
  7. package/dist/{19b9941db90.form.html → 19bbfd5aa77.form.html} +1 -1
  8. package/dist/19bbfd5aa77.form.js +1 -0
  9. package/dist/{19b9941db90.index.html → 19bbfd5aa77.index.html} +1 -1
  10. package/dist/{19b9941db90.library.html → 19bbfd5aa77.library.html} +1 -1
  11. package/dist/{19b9941db90.library.js → 19bbfd5aa77.library.js} +1 -1
  12. package/dist/{19b9941db90.preview.html → 19bbfd5aa77.preview.html} +1 -1
  13. package/dist/{19b9941db90.preview.js → 19bbfd5aa77.preview.js} +1 -1
  14. package/dist/{19b9941db90.webview.js → 19bbfd5aa77.webview.js} +1 -1
  15. package/dist/HASH +1 -1
  16. package/dist/screenshoot.js +67 -40
  17. package/package.json +8 -8
  18. package/src/chatbox/Header.js +5 -3
  19. package/src/lib.js +44 -19
  20. package/src/store/api.js +6 -6
  21. package/dist/19b9941db90.form.js +0 -1
  22. /package/dist/{19b9941db90.127.js → 19bbfd5aa77.127.js} +0 -0
  23. /package/dist/{19b9941db90.132.js → 19bbfd5aa77.132.js} +0 -0
  24. /package/dist/{19b9941db90.185.js → 19bbfd5aa77.185.js} +0 -0
  25. /package/dist/{19b9941db90.27.js → 19bbfd5aa77.27.js} +0 -0
  26. /package/dist/{19b9941db90.278.js → 19bbfd5aa77.278.js} +0 -0
  27. /package/dist/{19b9941db90.339.js → 19bbfd5aa77.339.js} +0 -0
  28. /package/dist/{19b9941db90.459.js → 19bbfd5aa77.459.js} +0 -0
  29. /package/dist/{19b9941db90.490.js → 19bbfd5aa77.490.js} +0 -0
  30. /package/dist/{19b9941db90.74.js → 19bbfd5aa77.74.js} +0 -0
  31. /package/dist/{19b9941db90.997.js → 19bbfd5aa77.997.js} +0 -0
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 19b9941db90
1
+ 19bbfd5aa77
@@ -4248,16 +4248,12 @@ let trackResponseFn = (param, done) => {
4248
4248
  _defineProperty(this, "listConversations", _ => this.apireq.addQuery('user_id', this.uid).addQuery('integration_id', `${this.accid}.subizv4.subikon`).get(`/accounts/${this.accid}/conversations`));
4249
4249
  _defineProperty(this, "listMessages", (cid, limit, start_id) => this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/accounts/${this.accid}/conversations/${cid}/messages`));
4250
4250
  _defineProperty(this, "ajax", ajax);
4251
- _defineProperty(this, "start", extraData => {
4252
- let data = {
4253
- touchpoint: {
4254
- channel: 'subiz',
4255
- source: 'web'
4256
- }
4257
- };
4258
- util/* default */.A.each(extraData, (v, k) => {
4259
- data[k] = v;
4260
- });
4251
+ _defineProperty(this, "start", (extraData, tpchannel, tpsource, tpid) => {
4252
+ let data = Object.assign({}, extraData);
4253
+ if (!data.touchpoint) data.touchpoint = {};
4254
+ if (!data.touchpoint.channel) data.touchpoint.channel = 'subiz';
4255
+ if (!data.touchpoint.source) data.touchpoint.source = 'web';
4256
+ data.source = util/* default */.A.get(document, 'location.href');
4261
4257
  return this.apireq.post(`/accounts/${this.accid}/conversations`, data);
4262
4258
  });
4263
4259
  _defineProperty(this, "sendConvoEvent", (cid, ev) => this.apireq.addQuery('x-referer', util/* default */.A.get(location, 'origin', '')).post(`/accounts/${this.accid}/conversations/${cid}/events`, ev));
@@ -5887,7 +5883,7 @@ class Store {
5887
5883
  this.lightConvos = this.kv.match('light_convos') || {};
5888
5884
  this.cache = new kv(new lsdb('sbz2023', true), 'kv');
5889
5885
  if (this.realtime) this.realtime.stop();
5890
- if (this.fake) this.realtime = new realtime_fake();else this.realtime = new Realtime(this.RealtimeURL, realtimep, xhrsend);
5886
+ if (this.fake) this.realtime = new realtime_fake();else this.realtime = new Realtime(this.RealtimeURL, realtimep, xhrsend, accid);
5891
5887
  this.realtime.onEvent(this.onWs.bind(this));
5892
5888
  this.realtime.onInterrupted(async () => {
5893
5889
  await this.reconnectWs(accid, user.id);
@@ -7500,13 +7496,15 @@ class Header extends common/* Com */.Mw {
7500
7496
  }
7501
7497
  renderAccountAvatar() {
7502
7498
  let acc = this.props.store.matchAccount() || {};
7503
- if (!acc.logo_url) return null;
7499
+ let accSetting = this.props.plugin.chatbox || {};
7500
+ let logo_url = util/* default */.A.get(accSetting, 'header.logo_url') || util/* default */.A.get(acc, 'logo_url');
7501
+ if (!logo_url) return null;
7504
7502
  return (0,preact_module.h)("img", {
7505
7503
  width: 38,
7506
7504
  height: 38,
7507
7505
  alt: acc.name,
7508
7506
  class: "avatar avatar__account",
7509
- src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(3582)
7507
+ src: this.props.store.replaceFileUrl(logo_url) || __webpack_require__(3582)
7510
7508
  });
7511
7509
  }
7512
7510
  render() {
@@ -7601,7 +7599,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
7601
7599
  }, (0,preact_module.h)("img", {
7602
7600
  alt: "logo",
7603
7601
  class: "social__account_logo",
7604
- src: this.props.store.replaceFileUrl(util/* default */.A.get(acc, 'logo_url'))
7602
+ src: this.props.store.replaceFileUrl(util/* default */.A.get(accSetting, 'header.logo_url') || util/* default */.A.get(acc, 'logo_url'))
7605
7603
  }), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
7606
7604
  class: "social__introduction"
7607
7605
  }, tags), (0,preact_module.h)("div", {
@@ -12834,35 +12832,64 @@ class lib_Widget {
12834
12832
  return impressiontoken;
12835
12833
  }
12836
12834
  async submitForm(formid, values) {
12837
- if (!formid || !util/* default */.A.startsWith(formid, 'cp')) return;
12838
- let storeuser = util/* default */.A.cloneDeep(this.store.matchUser());
12839
- let user = {
12840
- id: storeuser.id,
12841
- account_id: storeuser.account_id
12842
- };
12843
- let is_lead = false;
12844
- values = util/* default */.A.map(values, val => {
12845
- let key = val.key;
12846
- if (key === 'email') key = 'emails';
12847
- if (key === 'phone') key = 'phones';
12848
- is_lead = is_lead || key == 'emails' || key == 'phones';
12849
- util/* default */.A.setUserAttr(user, {
12850
- key: key,
12851
- [val.type || 'text']: val.value
12852
- });
12853
- return {
12854
- key: key,
12855
- type: val.type || 'text',
12856
- value: util/* default */.A.stringify(val.value)
12835
+ if (!formid || !values) return;
12836
+ if (util/* default */.A.startsWith(formid, 'cp')) {
12837
+ let storeuser = util/* default */.A.cloneDeep(this.store.matchUser());
12838
+ let user = {
12839
+ id: storeuser.id,
12840
+ account_id: storeuser.account_id
12857
12841
  };
12842
+ let is_lead = false;
12843
+ values = util/* default */.A.map(values, val => {
12844
+ let key = val.key;
12845
+ if (key === 'email') key = 'emails';
12846
+ if (key === 'phone') key = 'phones';
12847
+ is_lead = is_lead || key == 'emails' || key == 'phones';
12848
+ util/* default */.A.setUserAttr(user, {
12849
+ key: key,
12850
+ [val.type || 'text']: val.value
12851
+ });
12852
+ return {
12853
+ key: key,
12854
+ type: val.type || 'text',
12855
+ value: util/* default */.A.stringify(val.value)
12856
+ };
12857
+ });
12858
+ if (is_lead) util/* default */.A.setUserAttr(user, {
12859
+ key: 'lead_source',
12860
+ text: 'plugin.' + formid
12861
+ });
12862
+ let impressiontoken = await this.viewForm(formid);
12863
+ this.store.setUserDiff(user);
12864
+ return this.store.sendConversion(formid, values, impressiontoken);
12865
+ }
12866
+ values = util/* default */.A.filter(values, field => {
12867
+ return field.key && field.value;
12858
12868
  });
12859
- if (is_lead) util/* default */.A.setUserAttr(user, {
12860
- key: 'lead_source',
12861
- text: 'plugin.' + formid
12869
+ let text = 'Khách điền form\n';
12870
+ util/* default */.A.map(values, field => {
12871
+ text += '+ ' + field.key + ': ' + field.value + '\n';
12872
+ });
12873
+ return this.store.startConvo({
12874
+ subject: 'Khách điền form',
12875
+ touchpoint: {
12876
+ channel: 'form',
12877
+ source: window.location.hostname,
12878
+ id: Date.now() + '_' + util/* default */.A.randomString()
12879
+ },
12880
+ form_submission: {
12881
+ id: formid,
12882
+ values: values
12883
+ },
12884
+ message_sent: {
12885
+ data: {
12886
+ message: {
12887
+ format: 'plaintext',
12888
+ text: text
12889
+ }
12890
+ }
12891
+ }
12862
12892
  });
12863
- let impressiontoken = await this.viewForm(formid);
12864
- this.store.setUserDiff(user);
12865
- return this.store.sendConversion(formid, values, impressiontoken);
12866
12893
  }
12867
12894
  startConvo(req) {
12868
12895
  req = util/* default */.A.cloneDeep(req) || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.196",
3
+ "version": "4.1.198",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -21,18 +21,18 @@
21
21
  "preact": "10.19.3"
22
22
  },
23
23
  "devDependencies": {
24
- "@babel/cli": "^7.28.3",
25
- "@babel/core": "^7.28.5",
24
+ "@babel/cli": "^7.28.6",
25
+ "@babel/core": "^7.28.6",
26
26
  "@babel/plugin-proposal-class-properties": "^7.18.6",
27
- "@babel/plugin-transform-react-jsx": "^7.27.1",
28
- "@babel/preset-env": "^7.28.5",
27
+ "@babel/plugin-transform-react-jsx": "^7.28.6",
28
+ "@babel/preset-env": "^7.28.6",
29
29
  "babel-loader": "^10.0.0",
30
30
  "babel-plugin-syntax-jsx": "^6.18.0",
31
31
  "html-webpack-plugin": "^5.6.5",
32
- "puppeteer": "^24.34.0",
32
+ "puppeteer": "^24.35.0",
33
33
  "webpack": "^5.104.1",
34
- "webpack-bundle-analyzer": "^5.1.0",
34
+ "webpack-bundle-analyzer": "^5.1.1",
35
35
  "webpack-cli": "^6.0.1",
36
- "webpack-dev-server": "^5.2.2"
36
+ "webpack-dev-server": "^5.2.3"
37
37
  }
38
38
  }
@@ -11,14 +11,16 @@ export default class Header extends Com {
11
11
 
12
12
  renderAccountAvatar() {
13
13
  let acc = this.props.store.matchAccount() || {}
14
- if (!acc.logo_url) return null
14
+ let accSetting = this.props.plugin.chatbox || {}
15
+ let logo_url = sb.get(accSetting, 'header.logo_url') || sb.get(acc, 'logo_url')
16
+ if (!logo_url) return null
15
17
  return (
16
18
  <img
17
19
  width={38}
18
20
  height={38}
19
21
  alt={acc.name}
20
22
  class='avatar avatar__account'
21
- src={this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
23
+ src={this.props.store.replaceFileUrl(logo_url) || require('../../assets/img/image_default.png')}
22
24
  />
23
25
  )
24
26
  }
@@ -147,7 +149,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
147
149
  <img
148
150
  alt='logo'
149
151
  class='social__account_logo'
150
- src={this.props.store.replaceFileUrl(sb.get(acc, 'logo_url'))}
152
+ src={this.props.store.replaceFileUrl(sb.get(accSetting, 'header.logo_url') || sb.get(acc, 'logo_url'))}
151
153
  />
152
154
 
153
155
  <div>
package/src/lib.js CHANGED
@@ -214,27 +214,52 @@ class Widget {
214
214
 
215
215
  // cpxdf, [{key:'fullname', type:'text', value: 'thanhpk@liec.om'}]
216
216
  async submitForm(formid, values) {
217
- if (!formid || !sb.startsWith(formid, 'cp')) return
218
- let storeuser = sb.cloneDeep(this.store.matchUser())
219
- let user = {id: storeuser.id, account_id: storeuser.account_id}
220
-
221
- let is_lead = false
222
-
223
- values = sb.map(values, (val) => {
224
- let key = val.key
225
- if (key === 'email') key = 'emails'
226
- if (key === 'phone') key = 'phones'
227
- is_lead = is_lead || key == 'emails' || key == 'phones'
228
- sb.setUserAttr(user, {key: key, [val.type || 'text']: val.value})
229
- return {key: key, type: val.type || 'text', value: sb.stringify(val.value)}
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
- if (is_lead) sb.setUserAttr(user, {key: 'lead_source', text: 'plugin.' + formid})
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
- // must update user
235
- let impressiontoken = await this.viewForm(formid)
236
- this.store.setUserDiff(user)
237
- return this.store.sendConversion(formid, values, impressiontoken)
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
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 = {touchpoint: {channel: 'subiz', source: 'web'}}
251
- sb.each(extraData, (v, k) => {
252
- data[k] = v
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