@subiz/widget-v4 4.1.36 → 4.1.39

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 (44) hide show
  1. package/assets/less/widget.less +1 -1
  2. package/compiled_src/chatbox/Widget.js +6 -0
  3. package/compiled_src/lib.js +43 -0
  4. package/compiled_src/popup/popup.js +16 -2
  5. package/compiled_src/store/store.js +8 -0
  6. package/compiled_src/util/common.js +3 -3
  7. package/dist/178.js +1 -1
  8. package/dist/{18924eff71e.178.js → 18a02605dff.178.js} +1 -1
  9. package/dist/18a02605dff.362.js +1 -0
  10. package/dist/18a02605dff.441.js +1 -0
  11. package/dist/18a02605dff.782.js +1 -0
  12. package/dist/18a02605dff.app.js +1 -0
  13. package/dist/{18924eff71e.index.html → 18a02605dff.index.html} +1 -1
  14. package/dist/{18924eff71e.library.html → 18a02605dff.library.html} +1 -1
  15. package/dist/18a02605dff.library.js +1 -0
  16. package/dist/{18924eff71e.preview.html → 18a02605dff.preview.html} +1 -1
  17. package/dist/18a02605dff.preview.js +1 -0
  18. package/dist/18a02605dff.screenshoot.js +1 -0
  19. package/dist/18a02605dff.webview.js +1 -0
  20. package/dist/362.js +1 -1
  21. package/dist/441.js +682 -1408
  22. package/dist/782.js +1 -1
  23. package/dist/HASH +1 -1
  24. package/dist/screenshoot.html +1 -1
  25. package/dist/screenshoot.js +68 -30
  26. package/package.json +10 -10
  27. package/src/chatbox/Widget.js +9 -0
  28. package/src/lib.js +38 -0
  29. package/src/popup/popup.js +19 -3
  30. package/src/store/store.js +10 -1
  31. package/src/util/common.js +9 -3
  32. package/dist/18924eff71e.362.js +0 -1
  33. package/dist/18924eff71e.441.js +0 -1
  34. package/dist/18924eff71e.782.js +0 -1
  35. package/dist/18924eff71e.app.js +0 -1
  36. package/dist/18924eff71e.library.js +0 -1
  37. package/dist/18924eff71e.preview.js +0 -1
  38. package/dist/18924eff71e.screenshoot.js +0 -1
  39. package/dist/18924eff71e.webview.js +0 -1
  40. /package/dist/{18924eff71e.132.js → 18a02605dff.132.js} +0 -0
  41. /package/dist/{18924eff71e.213.js → 18a02605dff.213.js} +0 -0
  42. /package/dist/{18924eff71e.335.js → 18a02605dff.335.js} +0 -0
  43. /package/dist/{18924eff71e.605.js → 18a02605dff.605.js} +0 -0
  44. /package/dist/{18924eff71e.678.js → 18a02605dff.678.js} +0 -0
@@ -9,6 +9,7 @@
9
9
 
10
10
  padding-left: @spacer3;
11
11
  padding-right: @spacer3;
12
+ padding-bottom: @spacer3;
12
13
  }
13
14
 
14
15
  .convo-list--list {
@@ -243,7 +244,6 @@
243
244
  align-items: center;
244
245
  margin-left: auto;
245
246
  margin-right: auto;
246
- margin-bottom: @spacer3;
247
247
  &::after {
248
248
  display: none;
249
249
  }
@@ -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');
@@ -26,6 +26,7 @@ class Widget {
26
26
  _defineProperty(this, "setViewingProduct", p => this.store.linkProduct(p));
27
27
  _defineProperty(this, "getViewingProduct", () => this.store.getLinkedProduct());
28
28
  _defineProperty(this, "track", () => this.store.track());
29
+ this.impressionTokens = {};
29
30
  this.domGate = new _index.default.Gate();
30
31
  this.store = new _store.default(ApiURL, FileURL, RealtimeURL, inmem, fake);
31
32
  window.sbz_store = this.store;
@@ -125,6 +126,48 @@ class Widget {
125
126
  message
126
127
  });
127
128
  }
129
+ async viewForm(formid) {
130
+ if (!formid || !_index.default.startsWith(formid, 'cp')) return;
131
+ let impressiontoken = this.impressionTokens[formid];
132
+ if (impressiontoken) return impressiontoken;
133
+ let {
134
+ body: impression
135
+ } = await this.store.sendImpression(formid);
136
+ impressiontoken = _index.default.get(impression, 'impression_token') || '';
137
+ this.impressionTokens[formid] = impressiontoken;
138
+ return impressiontoken;
139
+ }
140
+ async submitForm(formid, values) {
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;
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
+ });
157
+ return {
158
+ key: key,
159
+ type: val.type || 'text',
160
+ value: _index.default.stringify(val.value)
161
+ };
162
+ });
163
+ if (is_lead) _index.default.setUserAttr(user, {
164
+ key: 'lead_source',
165
+ text: 'plugin.' + formid
166
+ });
167
+ let impressiontoken = await this.viewForm(formid);
168
+ this.store.setUserDiff(user);
169
+ return this.store.sendConversion(formid, values, impressiontoken);
170
+ }
128
171
  startConvo(req) {
129
172
  return this.store.startConvo(req);
130
173
  }
@@ -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;
@@ -259,8 +273,8 @@ class Popup extends _common.Com {
259
273
  key: 'lead_source',
260
274
  text: 'plugin.' + this.props.plugin.id
261
275
  });
262
- this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken);
263
276
  this.props.store.setUser(user);
277
+ this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken);
264
278
  }
265
279
  for (let a of actions) {
266
280
  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') || {};
@@ -724,9 +724,9 @@ function checkRunConditions(freq, conds, lastrun, store) {
724
724
  break;
725
725
  case 'user_is_a_contact':
726
726
  let attributes = op.get(store.matchUser(), 'attributes', []);
727
- let email = find(attributes, att => att.key === 'emails');
728
- let phone = find(attributes, att => att.key === 'phones');
729
- let hasContact = email || phone;
727
+ let emailAttr = find(attributes, att => att.key === 'emails' && attr.text && att.key === 'related_email' && attr.text);
728
+ let phoneAttr = find(attributes, att => att.key === 'phones' && attr.text && att.key === 'related_phone' && attr.text);
729
+ let hasContact = emailAttr || phoneAttr;
730
730
  if (cond.user_is_a_contact) {
731
731
  if (!hasContact) return false;
732
732
  }