@subiz/widget-v4 4.1.37 → 4.1.40
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/compiled_src/chatbox/Typing.js +2 -2
- package/compiled_src/chatbox/Widget.js +6 -0
- package/compiled_src/lib.js +24 -5
- package/compiled_src/popup/popup.js +20 -2
- package/compiled_src/store/store.js +8 -0
- package/compiled_src/util/campaign.js +6 -2
- package/compiled_src/util/common.js +9 -5
- package/compiled_src/util/order.js +4 -2
- package/compiled_src/util/pubsub.js +6 -3
- package/dist/132.js +524 -524
- package/dist/18a02a9c54e.132.js +1 -0
- package/dist/18a02a9c54e.213.js +1 -0
- package/dist/18a02a9c54e.335.js +1 -0
- package/dist/18a02a9c54e.441.js +1 -0
- package/dist/18a02a9c54e.605.js +1 -0
- package/dist/18a02a9c54e.app.js +1 -0
- package/dist/{189cbc6136e.index.html → 18a02a9c54e.index.html} +1 -1
- package/dist/{189cbc6136e.library.html → 18a02a9c54e.library.html} +1 -1
- package/dist/18a02a9c54e.library.js +1 -0
- package/dist/{189cbc6136e.preview.html → 18a02a9c54e.preview.html} +1 -1
- package/dist/18a02a9c54e.preview.js +1 -0
- package/dist/18a02a9c54e.screenshoot.js +1 -0
- package/dist/18a02a9c54e.webview.js +1 -0
- package/dist/213.js +98 -98
- package/dist/335.js +25 -25
- package/dist/441.js +1484 -886
- package/dist/605.js +50 -50
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +437 -394
- package/index.html +3 -3
- package/package.json +9 -9
- package/src/chatbox/Typing.js +2 -3
- package/src/chatbox/Widget.js +9 -0
- package/src/lib.js +15 -1
- package/src/popup/popup.js +23 -3
- package/src/store/store.js +10 -1
- package/src/util/common.js +9 -3
- package/dist/189cbc6136e.132.js +0 -1
- package/dist/189cbc6136e.213.js +0 -1
- package/dist/189cbc6136e.335.js +0 -1
- package/dist/189cbc6136e.441.js +0 -1
- package/dist/189cbc6136e.605.js +0 -1
- package/dist/189cbc6136e.app.js +0 -1
- package/dist/189cbc6136e.library.js +0 -1
- package/dist/189cbc6136e.preview.js +0 -1
- package/dist/189cbc6136e.screenshoot.js +0 -1
- package/dist/189cbc6136e.webview.js +0 -1
- /package/dist/{189cbc6136e.178.js → 18a02a9c54e.178.js} +0 -0
- /package/dist/{189cbc6136e.362.js → 18a02a9c54e.362.js} +0 -0
- /package/dist/{189cbc6136e.678.js → 18a02a9c54e.678.js} +0 -0
- /package/dist/{189cbc6136e.782.js → 18a02a9c54e.782.js} +0 -0
|
@@ -31,9 +31,9 @@ class Typing extends _common.Com {
|
|
|
31
31
|
});
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
let ag = this.props.store.matchAgent(ev.by.id) || {};
|
|
35
|
-
if (ag.type == 'agent') return;
|
|
36
34
|
if (_index.default.get(ev, 'type') !== 'conversation_typing') return;
|
|
35
|
+
let ag = this.props.store.matchAgent(_index.default.get(ev, 'by.id')) || {};
|
|
36
|
+
if (ag.type == 'agent') return;
|
|
37
37
|
this.setState({
|
|
38
38
|
ev: ev,
|
|
39
39
|
isShow: true
|
|
@@ -965,6 +965,12 @@ class Widget extends _common.Com {
|
|
|
965
965
|
_index.default.each(form.fields, f => {
|
|
966
966
|
var newf = Object.assign({}, f);
|
|
967
967
|
newf.value = _index.default.getUserAttr(user, f.key, f.type);
|
|
968
|
+
if (newf.key == 'emails' && !newf.value) {
|
|
969
|
+
newf.value = _index.default.getUserAttr(user, 'related_email', 'text');
|
|
970
|
+
}
|
|
971
|
+
if (newf.key == 'phones' && !newf.value) {
|
|
972
|
+
newf.value = _index.default.getUserAttr(user, 'related_phone', 'text');
|
|
973
|
+
}
|
|
968
974
|
if (f.type === 'boolean' && !newf.value) newf.value = false;
|
|
969
975
|
if (f.type === 'datetime' && newf.value) {
|
|
970
976
|
newf.value = new _index.default.Date(data.value).toLocaleDateString('en-CA');
|
package/compiled_src/lib.js
CHANGED
|
@@ -133,21 +133,40 @@ class Widget {
|
|
|
133
133
|
let {
|
|
134
134
|
body: impression
|
|
135
135
|
} = await this.store.sendImpression(formid);
|
|
136
|
-
|
|
137
|
-
this.impressionTokens[formid] =
|
|
138
|
-
return
|
|
136
|
+
impressiontoken = _index.default.get(impression, 'impression_token') || '';
|
|
137
|
+
this.impressionTokens[formid] = impressiontoken;
|
|
138
|
+
return impressiontoken;
|
|
139
139
|
}
|
|
140
140
|
async submitForm(formid, values) {
|
|
141
141
|
if (!formid || !_index.default.startsWith(formid, 'cp')) return;
|
|
142
|
+
let storeuser = _index.default.cloneDeep(this.store.matchUser());
|
|
143
|
+
let user = {
|
|
144
|
+
id: storeuser.id,
|
|
145
|
+
account_id: storeuser.account_id
|
|
146
|
+
};
|
|
147
|
+
let is_lead = false;
|
|
142
148
|
values = _index.default.map(values, val => {
|
|
149
|
+
let key = val.key;
|
|
150
|
+
if (key === 'email') key = 'emails';
|
|
151
|
+
if (key === 'phone') key = 'phones';
|
|
152
|
+
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
153
|
+
_index.default.setUserAttr(user, {
|
|
154
|
+
key: key,
|
|
155
|
+
[val.type || 'text']: val.value
|
|
156
|
+
});
|
|
143
157
|
return {
|
|
144
|
-
key:
|
|
158
|
+
key: key,
|
|
145
159
|
type: val.type || 'text',
|
|
146
160
|
value: _index.default.stringify(val.value)
|
|
147
161
|
};
|
|
148
162
|
});
|
|
163
|
+
if (is_lead) _index.default.setUserAttr(user, {
|
|
164
|
+
key: 'lead_source',
|
|
165
|
+
text: 'plugin.' + formid
|
|
166
|
+
});
|
|
149
167
|
let impressiontoken = await this.viewForm(formid);
|
|
150
|
-
|
|
168
|
+
this.store.setUserDiff(user);
|
|
169
|
+
return this.store.sendConversion(formid, values, impressiontoken);
|
|
151
170
|
}
|
|
152
171
|
startConvo(req) {
|
|
153
172
|
return this.store.startConvo(req);
|
|
@@ -113,8 +113,22 @@ class Popup extends _common.Com {
|
|
|
113
113
|
if (fieldkey === 'email') fieldkey = 'emails';
|
|
114
114
|
if (fieldkey === 'phone') fieldkey = 'phones';
|
|
115
115
|
if (fieldkey !== 'emails' || fieldkey != 'phones' || fieldkey !== 'fullname') return;
|
|
116
|
+
if (fieldkey == 'emails') {
|
|
117
|
+
let text = _index.default.getUserAttr(user, 'related_email', 'text');
|
|
118
|
+
if (!text) return;
|
|
119
|
+
var input = this._formRef.current.elements[field.key];
|
|
120
|
+
if (!input) return;
|
|
121
|
+
input.value = text;
|
|
122
|
+
}
|
|
123
|
+
if (fieldkey == 'phones') {
|
|
124
|
+
let text = _index.default.getUserAttr(user, 'related_phone', 'text');
|
|
125
|
+
if (!text) return;
|
|
126
|
+
var input = this._formRef.current.elements[field.key];
|
|
127
|
+
if (!input) return;
|
|
128
|
+
input.value = text;
|
|
129
|
+
}
|
|
116
130
|
_index.default.map(userAttributes, attr => {
|
|
117
|
-
if (fieldkey !== attr.key) return;
|
|
131
|
+
if (fieldkey !== attr.key || !attr.text) return;
|
|
118
132
|
var input = this._formRef.current.elements[field.key];
|
|
119
133
|
if (!input) return;
|
|
120
134
|
input.value = attr.text;
|
|
@@ -226,7 +240,9 @@ class Popup extends _common.Com {
|
|
|
226
240
|
let user = _index.default.cloneDeep(this.props.store.matchUser());
|
|
227
241
|
let is_lead = false;
|
|
228
242
|
let modifiedPairs = {};
|
|
243
|
+
console.log('333333333333');
|
|
229
244
|
for (var pair of formData.entries()) {
|
|
245
|
+
console.log('44444444444444444');
|
|
230
246
|
if (modifiedPairs[pair[0]]) {
|
|
231
247
|
let currentValue = _index.default.get(modifiedPairs, `${pair[0]}.1`, '');
|
|
232
248
|
currentValue += `,${pair[1]}`;
|
|
@@ -235,7 +251,9 @@ class Popup extends _common.Com {
|
|
|
235
251
|
modifiedPairs[pair[0]] = [pair[0], pair[1]];
|
|
236
252
|
}
|
|
237
253
|
}
|
|
254
|
+
console.log('1111111111111', Object.entries(modifiedPairs));
|
|
238
255
|
for (const [_, pair] of Object.entries(modifiedPairs)) {
|
|
256
|
+
console.log('2222222222222', pair);
|
|
239
257
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
240
258
|
let form = _index.default.find(page.components, com => com.type === 'form');
|
|
241
259
|
let fields = _index.default.get(form, 'form.fields', []);
|
|
@@ -259,8 +277,8 @@ class Popup extends _common.Com {
|
|
|
259
277
|
key: 'lead_source',
|
|
260
278
|
text: 'plugin.' + this.props.plugin.id
|
|
261
279
|
});
|
|
262
|
-
this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken);
|
|
263
280
|
this.props.store.setUser(user);
|
|
281
|
+
this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken);
|
|
264
282
|
}
|
|
265
283
|
for (let a of actions) {
|
|
266
284
|
if (a.action === 'open_widget') this.props.showWidget('list');
|
|
@@ -467,6 +467,14 @@ class Store {
|
|
|
467
467
|
this._setUser(user);
|
|
468
468
|
return this.api.updateUser(user);
|
|
469
469
|
}
|
|
470
|
+
async setUserDiff(user) {
|
|
471
|
+
if (!user) return;
|
|
472
|
+
await this.readyGate.entry();
|
|
473
|
+
let out = await this.api.updateUser(user);
|
|
474
|
+
if (out && out.code == 200 && out.body.id) {
|
|
475
|
+
this._setUser(out.body);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
470
478
|
_setUser(user) {
|
|
471
479
|
user = _index.default.cloneDeep(user);
|
|
472
480
|
let olduser = this.cache.match('user') || {};
|
|
@@ -37,7 +37,9 @@ function trackAreaClicked(selector, cb) {
|
|
|
37
37
|
on('click', selector, cb);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
function trackInactivity(
|
|
40
|
+
function trackInactivity() {
|
|
41
|
+
let seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
42
|
+
let cb = arguments.length > 1 ? arguments[1] : undefined;
|
|
41
43
|
let events = ['scroll', 'keyup', 'keydown', 'mousemove', 'mousewheel', 'mouseenter', 'mouseover', 'mousedown', 'touchstart', 'touchmove', 'touchenter'];
|
|
42
44
|
let inactiveSeconds = 0;
|
|
43
45
|
let resetTime = () => {
|
|
@@ -60,7 +62,9 @@ let timeOnPage = 0;
|
|
|
60
62
|
common.setInterval(() => {
|
|
61
63
|
timeOnPage += 5;
|
|
62
64
|
}, 5000);
|
|
63
|
-
function trackTimeOnPage(
|
|
65
|
+
function trackTimeOnPage() {
|
|
66
|
+
let seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
67
|
+
let cb = arguments.length > 1 ? arguments[1] : undefined;
|
|
64
68
|
if (seconds < 1) {
|
|
65
69
|
return common.setTimeout(function () {
|
|
66
70
|
cb(seconds);
|
|
@@ -159,7 +159,10 @@ function getMsgField(ev, fieldName) {
|
|
|
159
159
|
function isObject(item) {
|
|
160
160
|
return item && typeof item === 'object' && !Array.isArray(item);
|
|
161
161
|
}
|
|
162
|
-
function merge(target
|
|
162
|
+
function merge(target) {
|
|
163
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
164
|
+
sources[_key - 1] = arguments[_key];
|
|
165
|
+
}
|
|
163
166
|
if (!sources.length) return target;
|
|
164
167
|
const source = sources.shift();
|
|
165
168
|
if (isObject(target) && isObject(source)) {
|
|
@@ -724,9 +727,9 @@ function checkRunConditions(freq, conds, lastrun, store) {
|
|
|
724
727
|
break;
|
|
725
728
|
case 'user_is_a_contact':
|
|
726
729
|
let attributes = op.get(store.matchUser(), 'attributes', []);
|
|
727
|
-
let
|
|
728
|
-
let
|
|
729
|
-
let hasContact =
|
|
730
|
+
let emailAttr = find(attributes, att => att.key === 'emails' && attr.text && att.key === 'related_email' && attr.text);
|
|
731
|
+
let phoneAttr = find(attributes, att => att.key === 'phones' && attr.text && att.key === 'related_phone' && attr.text);
|
|
732
|
+
let hasContact = emailAttr || phoneAttr;
|
|
730
733
|
if (cond.user_is_a_contact) {
|
|
731
734
|
if (!hasContact) return false;
|
|
732
735
|
}
|
|
@@ -960,7 +963,8 @@ function getUrlParameter() {
|
|
|
960
963
|
}
|
|
961
964
|
var sleep = ms => new Promise(res => setTimeout(res, ms));
|
|
962
965
|
exports.sleep = sleep;
|
|
963
|
-
function formatCurrency(val
|
|
966
|
+
function formatCurrency(val) {
|
|
967
|
+
let currency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'VND';
|
|
964
968
|
let currencyObj = ALL_CURRENCIES.find(cur => cur.code === currency) || {
|
|
965
969
|
name: 'Dong',
|
|
966
970
|
code: 'VND',
|
|
@@ -14,7 +14,8 @@ op.map = common.map;
|
|
|
14
14
|
op.each = common.each;
|
|
15
15
|
op.size = common.size;
|
|
16
16
|
op.find = common.find;
|
|
17
|
-
function getProductPropName(product
|
|
17
|
+
function getProductPropName(product) {
|
|
18
|
+
let seperator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' - ';
|
|
18
19
|
let options = op.get(product, 'options', []);
|
|
19
20
|
let props = op.get(product, 'props', []);
|
|
20
21
|
let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
|
|
@@ -25,7 +26,8 @@ function getProductPropName(product, seperator = ' - ') {
|
|
|
25
26
|
});
|
|
26
27
|
return names.join(seperator);
|
|
27
28
|
}
|
|
28
|
-
function getOrderDisplayName(
|
|
29
|
+
function getOrderDisplayName() {
|
|
30
|
+
let order = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
29
31
|
return order.number || order.id || '';
|
|
30
32
|
}
|
|
31
33
|
function displayOrderShippingAddress(order, isShorten) {
|
|
@@ -14,9 +14,12 @@ class Pubsub {
|
|
|
14
14
|
}
|
|
15
15
|
publish(topic, payload, payload2, payload3) {
|
|
16
16
|
this.listeners[topic] = filter(this.listeners[topic], sub => sub.obj._isMounted);
|
|
17
|
-
map(this.listeners[topic],
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
map(this.listeners[topic], _ref => {
|
|
18
|
+
let {
|
|
19
|
+
cb
|
|
20
|
+
} = _ref;
|
|
21
|
+
return cb(payload, payload2, payload3);
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
24
|
on2(obj, topic, cb) {
|
|
22
25
|
if (!this.listeners[topic]) this.listeners[topic] = [];
|