@subiz/widget-v4 4.0.63 → 4.0.67
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/assets/less/chatbox.less +6 -1
- package/babel.config.js +2 -4
- package/compiled_src/bot.js +7 -1
- package/compiled_src/call/call.js +15 -12
- package/compiled_src/chatbox/ChatButton.js +3 -1
- package/compiled_src/chatbox/DropdownSelect.js +75 -66
- package/compiled_src/chatbox/Event.js +1 -0
- package/compiled_src/chatbox/MessageInput.js +7 -4
- package/compiled_src/chatbox/Order.js +94 -90
- package/compiled_src/chatbox/ProductAttachments.js +40 -4
- package/compiled_src/chatbox/Rating.js +10 -7
- package/compiled_src/chatbox/Typing.js +3 -1
- package/compiled_src/chatbox/Widget.js +27 -23
- package/compiled_src/chatbox/main.js +2 -0
- package/compiled_src/contact/contact.js +9 -6
- package/compiled_src/lib.js +14 -9
- package/compiled_src/notif/notif.js +15 -12
- package/compiled_src/order/address_picker.js +71 -63
- package/compiled_src/order/order.js +330 -316
- package/compiled_src/popup/countdown.js +7 -4
- package/compiled_src/popup/popup.js +12 -9
- package/compiled_src/store/api.js +110 -80
- package/compiled_src/store/api_fake.js +82 -55
- package/compiled_src/store/store.js +194 -135
- package/compiled_src/util/common.js +1 -1
- package/dist/132.js +678 -591
- package/dist/178.js +174 -341
- package/dist/17ff367201e.132.js +1 -0
- package/dist/17ff367201e.178.js +1 -0
- package/dist/17ff367201e.213.js +1 -0
- package/dist/17ff367201e.335.js +1 -0
- package/dist/17ff367201e.362.js +1 -0
- package/dist/17ff367201e.441.js +1 -0
- package/dist/17ff367201e.605.js +1 -0
- package/dist/17ff367201e.678.js +1 -0
- package/dist/17ff367201e.782.js +1 -0
- package/dist/17ff367201e.app.js +1 -0
- package/dist/{17e757ccadd.index.html → 17ff367201e.index.html} +1 -1
- package/dist/{17e757ccadd.library.html → 17ff367201e.library.html} +1 -1
- package/dist/17ff367201e.library.js +1 -0
- package/dist/{17e757ccadd.preview.html → 17ff367201e.preview.html} +1 -1
- package/dist/17ff367201e.preview.js +1 -0
- package/dist/17ff367201e.screenshoot.js +1 -0
- package/dist/213.js +19 -13
- package/dist/335.js +11 -8
- package/dist/362.js +21 -71
- package/dist/441.js +2 -2
- package/dist/605.js +15 -12
- package/dist/678.js +20 -70
- package/dist/782.js +21 -118
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +453 -332
- package/package.json +14 -14
- package/src/bot.js +2 -1
- package/src/chatbox/Buttons.js +8 -8
- package/src/chatbox/ChatButton.js +2 -2
- package/src/chatbox/Event.js +1 -1
- package/src/chatbox/ProductAttachments.js +41 -5
- package/src/chatbox/Typing.js +5 -1
- package/src/chatbox/main.js +4 -1
- package/src/store/store.js +24 -11
- package/src/util/common.js +1 -1
- package/up +1 -1
- package/dist/0b82fa7e5c3b07b40a44.png +0 -1
- package/dist/0f4af006e38ee8b93633.png +0 -1
- package/dist/17e757ccadd.132.js +0 -1
- package/dist/17e757ccadd.178.js +0 -1
- package/dist/17e757ccadd.213.js +0 -1
- package/dist/17e757ccadd.335.js +0 -1
- package/dist/17e757ccadd.362.js +0 -1
- package/dist/17e757ccadd.441.js +0 -1
- package/dist/17e757ccadd.605.js +0 -1
- package/dist/17e757ccadd.678.js +0 -1
- package/dist/17e757ccadd.782.js +0 -1
- package/dist/17e757ccadd.app.js +0 -1
- package/dist/17e757ccadd.library.js +0 -1
- package/dist/17e757ccadd.preview.js +0 -1
- package/dist/17e757ccadd.screenshoot.js +0 -1
- package/dist/1ea1c6cd21d25176810c.png +0 -1
- package/dist/292d42404e1b03398f61.png +0 -1
- package/dist/312d376370831b7bea83.png +0 -1
- package/dist/313d1bfc1cf776d1aefe.png +0 -1
- package/dist/4aa58bb7a66bb44975aa.png +0 -1
- package/dist/56ce063bc6c81adb7322.png +0 -1
- package/dist/6a411166ef5cc79e0714.png +0 -1
- package/dist/6faf403782fefacc1649.png +0 -1
- package/dist/79dca33c68fab79c067f.png +0 -1
- package/dist/82da1578fa84f9debaeb.png +0 -1
- package/dist/8b8e0f0824743974b282.png +0 -1
- package/dist/8d551390d81e39130a3c.png +0 -1
- package/dist/9fc61b9479877ebdb6c7.png +0 -1
- package/dist/a165d31dcb3dc90f1057.png +0 -1
- package/dist/a98d4a5698812c4426b3.png +0 -1
- package/dist/c41606bf9d1b604e46d5.png +0 -1
- package/dist/ce1f7450ce6c1aacd330.png +0 -1
- package/dist/cf8c01e88f4770a6e3e5.png +0 -1
- package/dist/dfbcfeab1d5622a737e2.png +0 -1
- package/dist/e4893ed8c2f7b8329919.png +0 -1
- package/dist/ec2ab4eb4ef73d186186.png +0 -1
|
@@ -17,6 +17,8 @@ var _realtime_fake = _interopRequireDefault(require("./realtime_fake.js"));
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
|
|
20
22
|
var flow = require('@subiz/flow');
|
|
21
23
|
|
|
22
24
|
var Realtime = require('@subiz/wsclient/index.js');
|
|
@@ -32,6 +34,177 @@ const page_loaded = _index.default.Date.now();
|
|
|
32
34
|
|
|
33
35
|
class Store {
|
|
34
36
|
constructor(ApiURL, FileURL, RealtimeURL, inmem, fakeapi, agenttoken) {
|
|
37
|
+
_defineProperty(this, "inmem", false);
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "cookie", cookie);
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "new_visitor", true);
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "matchUser", () => {
|
|
44
|
+
this._touchAcc();
|
|
45
|
+
|
|
46
|
+
return this.kv.match('user');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "suggest_addresses", keyword => this.api.suggest_address(keyword));
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "matchSession", () => this.kv.match('session') || {});
|
|
52
|
+
|
|
53
|
+
_defineProperty(this, "matchAccount", () => this.cache.match('account'));
|
|
54
|
+
|
|
55
|
+
_defineProperty(this, "matchPaymentMethods", () => this.cache.match('payment_methods'));
|
|
56
|
+
|
|
57
|
+
_defineProperty(this, "matchUnread", () => {
|
|
58
|
+
let user = this.matchUser();
|
|
59
|
+
let allconvos = this.matchConvo('*');
|
|
60
|
+
let unreadcount = 0;
|
|
61
|
+
|
|
62
|
+
_index.default.map(allconvos, convo => {
|
|
63
|
+
if (!_index.default.isConvoSeen(convo, user.id)) unreadcount++;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return unreadcount;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
_defineProperty(this, "matchPlugin", () => {
|
|
70
|
+
if (_index.default.size(this.forcePlugins) > 0) return _index.default.cloneDeep(this.forcePlugins);
|
|
71
|
+
return _index.default.cloneDeep(this.cache.match('plugin')) || {};
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
_defineProperty(this, "device", {});
|
|
75
|
+
|
|
76
|
+
_defineProperty(this, "browserVisibility", 'visible');
|
|
77
|
+
|
|
78
|
+
_defineProperty(this, "matchAgent", id => {
|
|
79
|
+
let agentM = this.cache.match('agent') || {};
|
|
80
|
+
if (id === '*') return agentM;
|
|
81
|
+
return agentM[id];
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
_defineProperty(this, "matchConvo", id => {
|
|
85
|
+
if (!id) return;
|
|
86
|
+
|
|
87
|
+
if (id === '*') {
|
|
88
|
+
this._touchAcc();
|
|
89
|
+
|
|
90
|
+
return _index.default.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!this.isInsync(id)) this.fetchConvo(id);
|
|
94
|
+
return this.cache.match('convo_' + id);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
_defineProperty(this, "fetchConvo", async cid => {
|
|
98
|
+
await this.readyGate.entry();
|
|
99
|
+
await this.reconnectGate.entry(undefined, true);
|
|
100
|
+
if (this.isInsync(cid)) return this.reconnectGate.open();
|
|
101
|
+
this.markSync(cid);
|
|
102
|
+
let {
|
|
103
|
+
body: convo,
|
|
104
|
+
error
|
|
105
|
+
} = await this.api.getConversation(cid);
|
|
106
|
+
if (convo && !error) this._setConvo(convo);
|
|
107
|
+
return this.reconnectGate.open();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
_defineProperty(this, "list_provinces", () => this.api.list_provinces());
|
|
111
|
+
|
|
112
|
+
_defineProperty(this, "list_districts", p => this.api.list_districts(p));
|
|
113
|
+
|
|
114
|
+
_defineProperty(this, "list_wards", p => this.api.list_wards(p));
|
|
115
|
+
|
|
116
|
+
_defineProperty(this, "list_provices", void 0);
|
|
117
|
+
|
|
118
|
+
_defineProperty(this, "listEvents", id => {
|
|
119
|
+
if (!id || id === '*' || typeof id !== 'string') return;
|
|
120
|
+
|
|
121
|
+
if (!this.isInsync('events' + id)) {
|
|
122
|
+
setTimeout(async () => {
|
|
123
|
+
await this.readyGate.entry();
|
|
124
|
+
await this.reconnectGate.entry(undefined, true);
|
|
125
|
+
if (this.isInsync('events' + id)) return this.reconnectGate.open();
|
|
126
|
+
this.markSync('events' + id);
|
|
127
|
+
await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
|
|
128
|
+
this.pubsub.publish('account');
|
|
129
|
+
return this.reconnectGate.open();
|
|
130
|
+
}, 10);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return this.chain.listM(id);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
_defineProperty(this, "fetchMoreEvents", async convoid => {
|
|
137
|
+
let {
|
|
138
|
+
error
|
|
139
|
+
} = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
|
|
140
|
+
this.pubsub.publish('account');
|
|
141
|
+
return {
|
|
142
|
+
error
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
_defineProperty(this, "matchBot", () => this.cache.match('bot') || {});
|
|
147
|
+
|
|
148
|
+
_defineProperty(this, "readyGate", new _index.default.Gate());
|
|
149
|
+
|
|
150
|
+
_defineProperty(this, "convoGate", new _index.default.Gate(true));
|
|
151
|
+
|
|
152
|
+
_defineProperty(this, "reconnectGate", new _index.default.Gate(true));
|
|
153
|
+
|
|
154
|
+
_defineProperty(this, "matchLastview", () => this.kv.match('lastview') || {});
|
|
155
|
+
|
|
156
|
+
_defineProperty(this, "matchIsOpen", () => !!this.kv.match('isopen'));
|
|
157
|
+
|
|
158
|
+
_defineProperty(this, "matchHasManuallyClosed", () => !!this.kv.match('hasManuallyClosed'));
|
|
159
|
+
|
|
160
|
+
_defineProperty(this, "matchClosePreviewAt", () => this.kv.match('close_preview_at') || 0);
|
|
161
|
+
|
|
162
|
+
_defineProperty(this, "sendPresence", _index.default.throttle(async () => {
|
|
163
|
+
await this.readyGate.entry();
|
|
164
|
+
if (!_index.default.get(this.kv.match('user'), 'id')) return;
|
|
165
|
+
if (_index.default.isUserBanned(this.kv.match('user'))) return;
|
|
166
|
+
return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
|
|
167
|
+
}, 1000));
|
|
168
|
+
|
|
169
|
+
_defineProperty(this, "now", () => _index.default.Date.now() + this.timeDiff);
|
|
170
|
+
|
|
171
|
+
_defineProperty(this, "seenQueue", []);
|
|
172
|
+
|
|
173
|
+
_defineProperty(this, "_typing", _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000));
|
|
174
|
+
|
|
175
|
+
_defineProperty(this, "onConvoEvent", (o, cb) => this.pubsub.on2(o, 'events', cb));
|
|
176
|
+
|
|
177
|
+
_defineProperty(this, "seenConvo", id => {
|
|
178
|
+
if (!id || id === 'create') return;
|
|
179
|
+
this.seenQueue.push(id);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
_defineProperty(this, "onUpdate", (o, cb) => this.pubsub.on2(o, 'account', cb));
|
|
183
|
+
|
|
184
|
+
_defineProperty(this, "onResetCSS", (o, cb) => this.pubsub.on2(o, 'resetCSS', cb));
|
|
185
|
+
|
|
186
|
+
_defineProperty(this, "onHighlight", (o, cb) => this.pubsub.on2(o, 'highlight', cb));
|
|
187
|
+
|
|
188
|
+
_defineProperty(this, "setHasManuallyClosed", () => this.kv.put('hasManuallyClosed', true));
|
|
189
|
+
|
|
190
|
+
_defineProperty(this, "setIsOpen", isopen => {
|
|
191
|
+
let lastisopen = this.kv.match('isopen');
|
|
192
|
+
this.kv.put('isopen', isopen);
|
|
193
|
+
|
|
194
|
+
if (!lastisopen && isopen) {
|
|
195
|
+
sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
_defineProperty(this, "closePreview", () => this.kv.put('close_preview_at', new _index.default.Date().getTime()));
|
|
200
|
+
|
|
201
|
+
_defineProperty(this, "setLastview", (view, opts) => this.kv.put('lastview', {
|
|
202
|
+
view,
|
|
203
|
+
opts
|
|
204
|
+
}));
|
|
205
|
+
|
|
206
|
+
_defineProperty(this, "timeDiff", 0);
|
|
207
|
+
|
|
35
208
|
this.agent_token = agenttoken;
|
|
36
209
|
this.g_sync = {};
|
|
37
210
|
this.forceDevice = null;
|
|
@@ -85,9 +258,6 @@ class Store {
|
|
|
85
258
|
}, 2000);
|
|
86
259
|
}
|
|
87
260
|
|
|
88
|
-
inmem = false;
|
|
89
|
-
cookie = cookie;
|
|
90
|
-
|
|
91
261
|
isInsync(key) {
|
|
92
262
|
return _index.default.Date.now() - (this.g_sync[key] || 0) < 300000;
|
|
93
263
|
}
|
|
@@ -188,115 +358,12 @@ class Store {
|
|
|
188
358
|
this.g_sync[key] = _index.default.Date.now();
|
|
189
359
|
}
|
|
190
360
|
|
|
191
|
-
new_visitor = true;
|
|
192
|
-
|
|
193
361
|
async _touchAcc() {
|
|
194
362
|
if (this.isInsync('account')) return;
|
|
195
363
|
await this.readyGate.entry();
|
|
196
364
|
if (!this.isInsync('account')) this.reconnect();
|
|
197
365
|
}
|
|
198
366
|
|
|
199
|
-
matchUser = () => {
|
|
200
|
-
this._touchAcc();
|
|
201
|
-
|
|
202
|
-
return this.kv.match('user');
|
|
203
|
-
};
|
|
204
|
-
suggest_addresses = keyword => this.api.suggest_address(keyword);
|
|
205
|
-
matchSession = () => this.kv.match('session') || {};
|
|
206
|
-
matchAccount = () => this.cache.match('account');
|
|
207
|
-
matchPaymentMethods = () => this.cache.match('payment_methods');
|
|
208
|
-
matchUnread = () => {
|
|
209
|
-
let user = this.matchUser();
|
|
210
|
-
let allconvos = this.matchConvo('*');
|
|
211
|
-
let unreadcount = 0;
|
|
212
|
-
|
|
213
|
-
_index.default.map(allconvos, convo => {
|
|
214
|
-
if (!_index.default.isConvoSeen(convo, user.id)) unreadcount++;
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
return unreadcount;
|
|
218
|
-
};
|
|
219
|
-
matchPlugin = () => {
|
|
220
|
-
if (_index.default.size(this.forcePlugins) > 0) return _index.default.cloneDeep(this.forcePlugins);
|
|
221
|
-
return _index.default.cloneDeep(this.cache.match('plugin')) || {};
|
|
222
|
-
};
|
|
223
|
-
device = {};
|
|
224
|
-
browserVisibility = 'visible';
|
|
225
|
-
matchAgent = id => {
|
|
226
|
-
let agentM = this.cache.match('agent') || {};
|
|
227
|
-
if (id === '*') return agentM;
|
|
228
|
-
return agentM[id];
|
|
229
|
-
};
|
|
230
|
-
matchConvo = id => {
|
|
231
|
-
if (!id) return;
|
|
232
|
-
|
|
233
|
-
if (id === '*') {
|
|
234
|
-
this._touchAcc();
|
|
235
|
-
|
|
236
|
-
return _index.default.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (!this.isInsync(id)) this.fetchConvo(id);
|
|
240
|
-
return this.cache.match('convo_' + id);
|
|
241
|
-
};
|
|
242
|
-
fetchConvo = async cid => {
|
|
243
|
-
await this.readyGate.entry();
|
|
244
|
-
await this.reconnectGate.entry(undefined, true);
|
|
245
|
-
if (this.isInsync(cid)) return this.reconnectGate.open();
|
|
246
|
-
this.markSync(cid);
|
|
247
|
-
let {
|
|
248
|
-
body: convo,
|
|
249
|
-
error
|
|
250
|
-
} = await this.api.getConversation(cid);
|
|
251
|
-
if (convo && !error) this._setConvo(convo);
|
|
252
|
-
return this.reconnectGate.open();
|
|
253
|
-
};
|
|
254
|
-
list_provinces = () => this.api.list_provinces();
|
|
255
|
-
list_districts = p => this.api.list_districts(p);
|
|
256
|
-
list_wards = p => this.api.list_wards(p);
|
|
257
|
-
list_provices;
|
|
258
|
-
listEvents = id => {
|
|
259
|
-
if (!id || id === '*' || typeof id !== 'string') return;
|
|
260
|
-
|
|
261
|
-
if (!this.isInsync('events' + id)) {
|
|
262
|
-
setTimeout(async () => {
|
|
263
|
-
await this.readyGate.entry();
|
|
264
|
-
await this.reconnectGate.entry(undefined, true);
|
|
265
|
-
if (this.isInsync('events' + id)) return this.reconnectGate.open();
|
|
266
|
-
this.markSync('events' + id);
|
|
267
|
-
await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
|
|
268
|
-
this.pubsub.publish('account');
|
|
269
|
-
return this.reconnectGate.open();
|
|
270
|
-
}, 10);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return this.chain.listM(id);
|
|
274
|
-
};
|
|
275
|
-
fetchMoreEvents = async convoid => {
|
|
276
|
-
let {
|
|
277
|
-
error
|
|
278
|
-
} = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
|
|
279
|
-
this.pubsub.publish('account');
|
|
280
|
-
return {
|
|
281
|
-
error
|
|
282
|
-
};
|
|
283
|
-
};
|
|
284
|
-
matchBot = () => this.cache.match('bot') || {};
|
|
285
|
-
readyGate = new _index.default.Gate();
|
|
286
|
-
convoGate = new _index.default.Gate(true);
|
|
287
|
-
reconnectGate = new _index.default.Gate(true);
|
|
288
|
-
matchLastview = () => this.kv.match('lastview') || {};
|
|
289
|
-
matchIsOpen = () => !!this.kv.match('isopen');
|
|
290
|
-
matchHasManuallyClosed = () => !!this.kv.match('hasManuallyClosed');
|
|
291
|
-
matchClosePreviewAt = () => this.kv.match('close_preview_at') || 0;
|
|
292
|
-
sendPresence = _index.default.throttle(async () => {
|
|
293
|
-
await this.readyGate.entry();
|
|
294
|
-
if (!_index.default.get(this.kv.match('user'), 'id')) return;
|
|
295
|
-
if (_index.default.isUserBanned(this.kv.match('user'))) return;
|
|
296
|
-
return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
|
|
297
|
-
}, 1000);
|
|
298
|
-
now = () => _index.default.Date.now() + this.timeDiff;
|
|
299
|
-
|
|
300
367
|
async init(accid, mask) {
|
|
301
368
|
this.readyGate.close();
|
|
302
369
|
accid = (accid || '').trim();
|
|
@@ -355,8 +422,6 @@ class Store {
|
|
|
355
422
|
return mask;
|
|
356
423
|
}
|
|
357
424
|
|
|
358
|
-
seenQueue = [];
|
|
359
|
-
|
|
360
425
|
seenLoop() {
|
|
361
426
|
this.seenQueue = [];
|
|
362
427
|
clearInterval(this._seenInterval);
|
|
@@ -747,8 +812,6 @@ class Store {
|
|
|
747
812
|
this._typing(cid);
|
|
748
813
|
}
|
|
749
814
|
|
|
750
|
-
_typing = _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000);
|
|
751
|
-
|
|
752
815
|
async startConvo(req) {
|
|
753
816
|
await this.readyGate.entry();
|
|
754
817
|
this.convoGate.close();
|
|
@@ -844,13 +907,20 @@ class Store {
|
|
|
844
907
|
|
|
845
908
|
this.onWs(ret);
|
|
846
909
|
sendEventToThirdParty('SUBIZ Chat', 'Sent', 'User');
|
|
847
|
-
|
|
910
|
+
let lastMsgSent = this.kv.match('last_msg_sent');
|
|
911
|
+
|
|
912
|
+
if (!lastMsgSent) {
|
|
913
|
+
let dataLayer = window.dataLayer || [];
|
|
914
|
+
dataLayer.push({
|
|
915
|
+
event: 'SUBIZ Chat',
|
|
916
|
+
event_action: 'Sent',
|
|
917
|
+
event_label: 'User',
|
|
918
|
+
first_interaction: 1
|
|
919
|
+
});
|
|
920
|
+
}
|
|
848
921
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (!id || id === 'create') return;
|
|
852
|
-
this.seenQueue.push(id);
|
|
853
|
-
};
|
|
922
|
+
this.kv.put('last_msg_sent', _index.default.Date.now());
|
|
923
|
+
}
|
|
854
924
|
|
|
855
925
|
_setConvo(convo) {
|
|
856
926
|
let count = 0;
|
|
@@ -883,21 +953,6 @@ class Store {
|
|
|
883
953
|
this.cache.put('convo_' + convo.id, convo);
|
|
884
954
|
}
|
|
885
955
|
|
|
886
|
-
onUpdate = (o, cb) => this.pubsub.on2(o, 'account', cb);
|
|
887
|
-
onResetCSS = (o, cb) => this.pubsub.on2(o, 'resetCSS', cb);
|
|
888
|
-
onHighlight = (o, cb) => this.pubsub.on2(o, 'highlight', cb);
|
|
889
|
-
setHasManuallyClosed = () => this.kv.put('hasManuallyClosed', true);
|
|
890
|
-
setIsOpen = isopen => {
|
|
891
|
-
let lastisopen = this.kv.match('isopen');
|
|
892
|
-
this.kv.put('isopen', isopen);
|
|
893
|
-
if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
|
|
894
|
-
};
|
|
895
|
-
closePreview = () => this.kv.put('close_preview_at', new _index.default.Date().getTime());
|
|
896
|
-
setLastview = (view, opts) => this.kv.put('lastview', {
|
|
897
|
-
view,
|
|
898
|
-
opts
|
|
899
|
-
});
|
|
900
|
-
|
|
901
956
|
matchLastPluginRun(pluginid) {
|
|
902
957
|
let log = this.kv.match('plugin_run_logs') || {};
|
|
903
958
|
return log[pluginid];
|
|
@@ -1002,12 +1057,10 @@ class Store {
|
|
|
1002
1057
|
return [events, anchor];
|
|
1003
1058
|
}
|
|
1004
1059
|
|
|
1005
|
-
timeDiff = 0;
|
|
1006
|
-
|
|
1007
1060
|
async loopTime() {
|
|
1008
1061
|
let startms = _index.default.Date.now();
|
|
1009
1062
|
|
|
1010
|
-
if (!_index.default.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(),
|
|
1063
|
+
if (!_index.default.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 120000);
|
|
1011
1064
|
let {
|
|
1012
1065
|
body: t,
|
|
1013
1066
|
error
|
|
@@ -1019,7 +1072,7 @@ class Store {
|
|
|
1019
1072
|
var localMs = _index.default.Date.now();
|
|
1020
1073
|
|
|
1021
1074
|
this.timeDiff = Math.floor(serverMs - localMs);
|
|
1022
|
-
setTimeout(() => this.loopTime(),
|
|
1075
|
+
setTimeout(() => this.loopTime(), 120000);
|
|
1023
1076
|
}
|
|
1024
1077
|
|
|
1025
1078
|
replaceFileUrl(src) {
|
|
@@ -1177,6 +1230,12 @@ function sendEventToThirdParty(category, action, label) {
|
|
|
1177
1230
|
}));
|
|
1178
1231
|
sendToGA(category, action, label);
|
|
1179
1232
|
sendToFBPixel(category, action, label);
|
|
1233
|
+
let dataLayer = window.dataLayer || [];
|
|
1234
|
+
dataLayer.push({
|
|
1235
|
+
event: category,
|
|
1236
|
+
event_action: action,
|
|
1237
|
+
event_label: label
|
|
1238
|
+
});
|
|
1180
1239
|
}
|
|
1181
1240
|
|
|
1182
1241
|
let mobileCheck = function (a) {
|