@subiz/widget-v4 4.0.75 → 4.0.77

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 (116) hide show
  1. package/compiled_src/lib.js +6 -0
  2. package/compiled_src/store/api.js +24 -18
  3. package/compiled_src/store/api_fake.js +0 -24
  4. package/compiled_src/store/store.js +21 -5
  5. package/dist/132.js +6821 -0
  6. package/dist/178.js +406 -0
  7. package/dist/180d0eaa4dc.132.js +1 -0
  8. package/dist/180d0eaa4dc.178.js +1 -0
  9. package/dist/180d0eaa4dc.213.js +1 -0
  10. package/dist/180d0eaa4dc.335.js +1 -0
  11. package/dist/180d0eaa4dc.362.js +1 -0
  12. package/dist/180d0eaa4dc.441.js +1 -0
  13. package/dist/180d0eaa4dc.605.js +1 -0
  14. package/dist/180d0eaa4dc.678.js +1 -0
  15. package/dist/180d0eaa4dc.782.js +1 -0
  16. package/dist/180d0eaa4dc.app.js +1 -0
  17. package/dist/180d0eaa4dc.index.html +22 -0
  18. package/dist/180d0eaa4dc.library.html +22 -0
  19. package/dist/180d0eaa4dc.library.js +1 -0
  20. package/dist/180d0eaa4dc.preview.html +759 -0
  21. package/dist/180d0eaa4dc.preview.js +1 -0
  22. package/dist/180d0eaa4dc.screenshoot.js +1 -0
  23. package/dist/180efeaa053.132.js +1 -0
  24. package/dist/180efeaa053.178.js +1 -0
  25. package/dist/180efeaa053.213.js +1 -0
  26. package/dist/180efeaa053.335.js +1 -0
  27. package/dist/180efeaa053.362.js +1 -0
  28. package/dist/180efeaa053.441.js +1 -0
  29. package/dist/180efeaa053.605.js +1 -0
  30. package/dist/180efeaa053.678.js +1 -0
  31. package/dist/180efeaa053.782.js +1 -0
  32. package/dist/180efeaa053.app.js +1 -0
  33. package/dist/180efeaa053.index.html +22 -0
  34. package/dist/180efeaa053.library.html +22 -0
  35. package/dist/180efeaa053.library.js +1 -0
  36. package/dist/180efeaa053.preview.html +759 -0
  37. package/dist/180efeaa053.preview.js +1 -0
  38. package/dist/180efeaa053.screenshoot.js +1 -0
  39. package/dist/213.js +3188 -0
  40. package/dist/335.js +411 -0
  41. package/dist/362.js +107 -0
  42. package/dist/441.js +2814 -0
  43. package/dist/605.js +328 -0
  44. package/dist/678.js +107 -0
  45. package/dist/782.js +107 -0
  46. package/dist/HASH +1 -0
  47. package/dist/assets/img/Facebook.64607ec.png +0 -0
  48. package/dist/assets/img/Zalo.6845707.png +0 -0
  49. package/dist/assets/img/award1a.1a58e10.png +0 -0
  50. package/dist/assets/img/award3a.3b74423.png +0 -0
  51. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  52. package/dist/assets/img/award5.39eb7ae.png +0 -0
  53. package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
  54. package/dist/assets/img/caret.998eb8f.svg +1 -0
  55. package/dist/assets/img/convos_empty.2353007.svg +72 -0
  56. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  57. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  58. package/dist/assets/img/done_gray.d7e8203.svg +4 -0
  59. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  60. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  61. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  62. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  63. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  67. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  70. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  71. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  72. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  73. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  74. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  75. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  76. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  77. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  78. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  79. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  80. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  81. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  82. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  83. package/dist/assets/img/empty.29bed2d.svg +23 -0
  84. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  85. package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
  86. package/dist/assets/img/external-link.90577cc.svg +1 -0
  87. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  88. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  89. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  90. package/dist/assets/img/image_default.be0698b.png +0 -0
  91. package/dist/assets/img/info.ebce7ea.svg +1 -0
  92. package/dist/assets/img/loader.37000a7.svg +1 -0
  93. package/dist/assets/img/loading_static.8f403ae.svg +10 -0
  94. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  95. package/dist/assets/img/main-service2.9b99549.png +0 -0
  96. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  97. package/dist/assets/img/package.8d37d0f.svg +5 -0
  98. package/dist/assets/img/package_fade.763c001.svg +1 -0
  99. package/dist/assets/img/rating--average.1ea492c.svg +12 -0
  100. package/dist/assets/img/rating--great.e3d712e.svg +16 -0
  101. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  102. package/dist/assets/img/search.f9705ff.svg +1 -0
  103. package/dist/assets/img/send.6db52a9.svg +3 -0
  104. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  105. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  106. package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
  107. package/dist/assets/img/x.26fdfa3.svg +5 -0
  108. package/dist/malicious-app.js +13 -0
  109. package/dist/screenshoot.html +7 -0
  110. package/dist/screenshoot.js +5969 -0
  111. package/index.html +6 -2
  112. package/package.json +10 -10
  113. package/src/lib.js +5 -0
  114. package/src/store/api.js +16 -10
  115. package/src/store/api_fake.js +0 -16
  116. package/src/store/store.js +38 -4
package/index.html CHANGED
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta name="description" content="Subiz preview">
4
+ <meta name="description" content="Subiz preview" />
5
5
  <meta charset="utf-8" />
6
6
  <title>Widget v4</title>
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -27,13 +27,17 @@
27
27
  getUrlParameter('id') || getUrlParameter('acc_id') || getUrlParameter('account_id') || 'acpxkgumifuoofoosble'
28
28
  // making a queue, so we can process data asynchronous
29
29
  window._sbzaccid = accid
30
- window.subiz = function() {
30
+ window.subiz = function () {
31
31
  window.subiz.q.push(arguments)
32
32
  }
33
33
  window.subiz.q = []
34
34
  // set account it in the very first call
35
35
  window.subiz('setAccount', accid)
36
36
  window.subiz('expandWidget')
37
+
38
+ if (accid == 'acpxkgumifuoofoosble') {
39
+ window.subiz('setViewingProduct', {id: '220170', sku: 'ipx', source_id: 'IPHONE10'})
40
+ }
37
41
  </script>
38
42
  </body>
39
43
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.0.75",
3
+ "version": "4.0.77",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -14,28 +14,28 @@
14
14
  "@subiz/storage": "0.0.8",
15
15
  "@subiz/wsclient": "^3.1.7",
16
16
  "cookie_js": "1.4.2",
17
- "core-js": "^3.22.5",
17
+ "core-js": "^3.22.8",
18
18
  "css-loader": "5.2.7",
19
19
  "file-loader": "^6.2.0",
20
20
  "less": "^4.1.2",
21
- "less-loader": "^10.2.0",
22
- "marked": "^4.0.15",
23
- "preact": "^10.7.2"
21
+ "less-loader": "^11.0.0",
22
+ "marked": "^4.0.16",
23
+ "preact": "^10.7.3"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@babel/cli": "^7.17.10",
27
- "@babel/core": "^7.17.12",
27
+ "@babel/core": "^7.18.2",
28
28
  "@babel/plugin-proposal-class-properties": "^7.17.12",
29
29
  "@babel/plugin-transform-react-jsx": "^7.17.12",
30
- "@babel/preset-env": "^7.17.12",
30
+ "@babel/preset-env": "^7.18.2",
31
31
  "babel-loader": "^8.2.5",
32
32
  "babel-plugin-syntax-jsx": "^6.18.0",
33
33
  "html-webpack-plugin": "^5.5.0",
34
34
  "prettier": "^2.6.2",
35
- "puppeteer": "^14.1.0",
36
- "webpack": "^5.72.1",
35
+ "puppeteer": "^14.2.1",
36
+ "webpack": "^5.73.0",
37
37
  "webpack-bundle-analyzer": "^4.5.0",
38
38
  "webpack-cli": "^4.9.2",
39
- "webpack-dev-server": "^4.9.0"
39
+ "webpack-dev-server": "^4.9.1"
40
40
  }
41
41
  }
package/src/lib.js CHANGED
@@ -128,6 +128,11 @@ class Widget {
128
128
 
129
129
  getUser = () => sb.parseJSON(sb.stringify(this.store.matchUser()))
130
130
 
131
+ setViewingProduct = (p) => this.store.linkProduct(p)
132
+ getViewingProduct = () => this.store.getLinkedProduct()
133
+
134
+ track = () => this.store.track()
135
+
131
136
  async setLocale(locale) {
132
137
  await this.domGate.entry()
133
138
  return this.pluginMgr.setCurrentChatboxLocale(locale)
package/src/store/api.js CHANGED
@@ -47,10 +47,7 @@ export default class {
47
47
  .get('/conversations')
48
48
 
49
49
  listMessages = (cid, limit, start_id) =>
50
- this.apireq
51
- .addQuery('limit', limit)
52
- .addQuery('start_id', start_id)
53
- .get(`/conversations/${cid}/messages`)
50
+ this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/conversations/${cid}/messages`)
54
51
 
55
52
  ajax = ajax
56
53
 
@@ -73,19 +70,28 @@ export default class {
73
70
  sendEvent = (data) => this.apireq.post(`/users/${this.uid}/events`, data)
74
71
  sendTyping = (cid) => this.apireq.post(`/conversations/${cid}/typing`)
75
72
 
76
- sendPresence(device, is_focused) {
77
- return this.sendEvent({
73
+ sendPresence = (device, is_focused, productid, source_id, sku) =>
74
+ this.sendEvent({
78
75
  by: {id: this.uid, device: device},
79
76
  type: 'presence_updated',
80
- data: {presence: {pinged: sb.Date.now(), is_focused}},
77
+ data: {
78
+ presence: {
79
+ viewing_product_sku: sku,
80
+ viewing_product_source_id: source_id,
81
+ viewing_product_id: productid,
82
+ pinged: sb.Date.now(),
83
+ is_focused,
84
+ },
85
+ },
81
86
  })
82
- }
83
87
 
84
- sendContent(device, pageUrl, pageTitle) {
88
+ sendContentView(device, pageUrl, pageTitle, id, source_id, sku) {
89
+ if (!id) id = undefined // dont accept ''
90
+ if (!source_id) source_id = undefined // dont accept ''
85
91
  return this.sendEvent({
86
92
  by: {id: this.uid, device: device},
87
93
  type: 'content_viewed',
88
- data: {product: {url: pageUrl, name: pageTitle, title: pageTitle}},
94
+ data: {product: {id: id, source_id: source_id, url: pageUrl, name: pageTitle, title: pageTitle, sku: sku}},
89
95
  })
90
96
  }
91
97
 
@@ -112,22 +112,6 @@ function makeFakeConvo(accid, convoid, userid, agentid) {
112
112
  id: inteid,
113
113
  },
114
114
  actived: 1610453070259,
115
- last_event: {
116
- id: 'evqyiykaoizbwnkaecwphttwk',
117
- account_id: accid,
118
- created: 1616213311830,
119
- type: 'message_sent',
120
- by: {id: userid, client_id: 'clsubizapi', type: 'user'},
121
- data: {
122
- message: {
123
- conversation_id: convoid,
124
- text: 'ok cám ơn!',
125
- format: 'plaintext',
126
- integration_id: inteid,
127
- pongs: [{member_id: userid, type: 'seen', created: 1616213312110}],
128
- },
129
- },
130
- },
131
115
  last_message_sent: {
132
116
  id: 'evqyiykaoizbwnkaecwphttwk',
133
117
  account_id: accid,
@@ -45,7 +45,11 @@ export default class Store {
45
45
 
46
46
  window.addEventListener('blur', () => this.sendPresence())
47
47
  window.addEventListener('focus', () => this.sendPresence())
48
- setInterval(() => this.sendPresence(), 30000) // dont bother delete this
48
+
49
+ // faster send rate when has focus
50
+ setInterval(() => this.browserVisibility === 'visible' && document.hasFocus() && this.sendPresence(), 20000) // dont bother delete this
51
+ // slower send rate send when no focus
52
+ setInterval(() => (this.browserVisibility !== 'visible' || document.hasFocus()) && this.sendPresence(), 60000) // dont bother delete this
49
53
 
50
54
  onVisibilityChange((val) => {
51
55
  this.browserVisibility = val
@@ -75,6 +79,24 @@ export default class Store {
75
79
  inmem = false
76
80
  cookie = cookie
77
81
 
82
+ // inmem
83
+ _currentViewingProduct = {}
84
+ linkProduct(p) {
85
+ if (!p) {
86
+ this._currentViewingProduct = {}
87
+ return
88
+ }
89
+
90
+ if (p.id) this._currentViewingProduct.id = (p.id + '').trim()
91
+ if (p.source_id) this._currentViewingProduct.source_id = (p.source_id + '').trim()
92
+ if (p.sku) this._currentViewingProduct.sku = (p.sku + '').trim()
93
+ // call link product
94
+ }
95
+
96
+ getLinkedProduct() {
97
+ return sb.cloneDeep(this._currentViewingProduct)
98
+ }
99
+
78
100
  isInsync(key) {
79
101
  return sb.Date.now() - (this.g_sync[key] || 0) < 300000
80
102
  }
@@ -297,7 +319,13 @@ export default class Store {
297
319
  await this.readyGate.entry()
298
320
  if (!sb.get(this.kv.match('user'), 'id')) return // store not init
299
321
  if (sb.isUserBanned(this.kv.match('user'))) return
300
- return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus())
322
+ return this.api.sendPresence(
323
+ this.device,
324
+ this.browserVisibility === 'visible' && document.hasFocus(),
325
+ this._currentViewingProduct.id,
326
+ this._currentViewingProduct.source_id,
327
+ this._currentViewingProduct.sku,
328
+ )
301
329
  }, 1000)
302
330
 
303
331
  now = () => sb.Date.now() + this.timeDiff // millisecond on server
@@ -573,7 +601,14 @@ export default class Store {
573
601
  // send the content view, the first presence and record domain
574
602
  async track() {
575
603
  let user = this.kv.match('user') || {}
576
- await this.api.sendContent(this.device, location.href, document.title)
604
+ await this.api.sendContentView(
605
+ this.device,
606
+ location.href,
607
+ document.title,
608
+ this._currentViewingProduct.id,
609
+ this._currentViewingProduct.source_id,
610
+ this._currentViewingProduct.sku,
611
+ )
577
612
  this.sendPresence()
578
613
  }
579
614
 
@@ -692,7 +727,6 @@ export default class Store {
692
727
  if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {
693
728
  this.chain.put(cid, ev.id, sb.getMs(ev.created), ev)
694
729
  }
695
- convo.last_event = ev
696
730
  this._setConvo(convo)
697
731
  this.pubsub.publish('account')
698
732
  }