@livechat/customer-sdk 3.1.1 → 3.1.3
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/README.md +24 -10
- package/dist/customer-sdk.cjs.js +243 -673
- package/dist/customer-sdk.cjs.native.js +243 -672
- package/dist/customer-sdk.esm.js +243 -671
- package/dist/customer-sdk.js +589 -1056
- package/dist/customer-sdk.min.js +1 -1
- package/package.json +9 -9
- package/types/actions.d.ts +331 -0
- package/types/chatHistory.d.ts +19 -0
- package/types/clientDataParsers.d.ts +55 -0
- package/types/completionValues.d.ts +4 -0
- package/types/constants/clientErrorCodes.d.ts +11 -0
- package/types/constants/connectionStatuses.d.ts +6 -0
- package/types/constants/eventTypes.d.ts +8 -0
- package/types/constants/organizationIds.d.ts +2 -0
- package/types/constants/reduxActions.d.ts +23 -0
- package/types/constants/serverDisconnectionReasons.d.ts +15 -0
- package/types/constants/serverErrorCodes.d.ts +23 -0
- package/types/constants/serverPushActions.d.ts +26 -0
- package/types/constants/serverRequestActions.d.ts +30 -0
- package/types/constants/sortOrders.d.ts +3 -0
- package/types/constants/userTypes.d.ts +3 -0
- package/types/createError.d.ts +9 -0
- package/types/createStore.d.ts +12 -0
- package/types/debug.d.ts +3 -0
- package/types/graylog/index.d.ts +14 -0
- package/types/graylog/makeGrayLogRequest.d.ts +2 -0
- package/types/graylog/makeGrayLogRequest.native.d.ts +6 -0
- package/types/index.d.ts +245 -0
- package/types/reducer.d.ts +546 -0
- package/types/sendRequestAction.d.ts +4 -0
- package/types/sendTicketForm.d.ts +15 -0
- package/types/serverDataParser.d.ts +34 -0
- package/types/serverEventParser.d.ts +12 -0
- package/types/serverFrameParser.d.ts +385 -0
- package/types/sideEffects/checkGoals.d.ts +5 -0
- package/types/sideEffects/index.d.ts +13 -0
- package/types/sideStorage.d.ts +5 -0
- package/types/socketClient.d.ts +11 -0
- package/types/socketListener.d.ts +12 -0
- package/types/thunks.d.ts +4 -0
- package/types/types/actions.d.ts +157 -0
- package/types/types/clientEntities.d.ts +376 -0
- package/types/types/frames.d.ts +635 -0
- package/types/types/serverEntities.d.ts +409 -0
- package/types/types/state.d.ts +56 -0
- package/types/uploadFile.d.ts +19 -0
- package/types/validateFile/index.d.ts +3 -0
package/dist/customer-sdk.esm.js
CHANGED
|
@@ -3,12 +3,11 @@ import mitt from '@livechat/mitt';
|
|
|
3
3
|
import { hasOwn, identity, toPairs, pickOwn, isObject, generateUniqueId, noop, pick, mapValues, keyBy, values, includes, isEmpty, numericSortBy, uniqBy, flatMap, last, stringCompare } from '@livechat/data-utils';
|
|
4
4
|
import { createStore, applyMiddleware } from 'redux';
|
|
5
5
|
import createSideEffectsMiddleware from '@livechat/side-effects-middleware';
|
|
6
|
-
import
|
|
7
|
-
import promiseTry from '@livechat/promise-try';
|
|
6
|
+
import { promiseDeferred, promiseTry } from '@livechat/promise-utils';
|
|
8
7
|
import createBackoff from '@livechat/backoff';
|
|
9
8
|
import storage from '@livechat/isomorphic-storage';
|
|
10
9
|
import unfetch from 'unfetch';
|
|
11
|
-
import { buildQueryString } from '@livechat/url-utils';
|
|
10
|
+
import { buildQueryString, removeProtocol } from '@livechat/url-utils';
|
|
12
11
|
import createPlatformClient from '@livechat/platform-client';
|
|
13
12
|
import rawUploadFile from '@livechat/file-upload';
|
|
14
13
|
|
|
@@ -16,50 +15,40 @@ function _extends() {
|
|
|
16
15
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
16
|
for (var i = 1; i < arguments.length; i++) {
|
|
18
17
|
var source = arguments[i];
|
|
19
|
-
|
|
20
18
|
for (var key in source) {
|
|
21
19
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
20
|
target[key] = source[key];
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
return target;
|
|
28
25
|
};
|
|
29
26
|
return _extends.apply(this, arguments);
|
|
30
27
|
}
|
|
31
|
-
|
|
32
28
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
33
29
|
if (source == null) return {};
|
|
34
30
|
var target = {};
|
|
35
31
|
var sourceKeys = Object.keys(source);
|
|
36
32
|
var key, i;
|
|
37
|
-
|
|
38
33
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
39
34
|
key = sourceKeys[i];
|
|
40
35
|
if (excluded.indexOf(key) >= 0) continue;
|
|
41
36
|
target[key] = source[key];
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
return target;
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
function _toPrimitive(input, hint) {
|
|
48
41
|
if (typeof input !== "object" || input === null) return input;
|
|
49
42
|
var prim = input[Symbol.toPrimitive];
|
|
50
|
-
|
|
51
43
|
if (prim !== undefined) {
|
|
52
44
|
var res = prim.call(input, hint || "default");
|
|
53
45
|
if (typeof res !== "object") return res;
|
|
54
46
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
return (hint === "string" ? String : Number)(input);
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
function _toPropertyKey(arg) {
|
|
61
51
|
var key = _toPrimitive(arg, "string");
|
|
62
|
-
|
|
63
52
|
return typeof key === "symbol" ? key : String(key);
|
|
64
53
|
}
|
|
65
54
|
|
|
@@ -130,19 +119,16 @@ var createReducer = function createReducer(initialState, reducersMap) {
|
|
|
130
119
|
// eslint-disable-next-line no-console
|
|
131
120
|
console.warn(["Reducer contains an 'undefined' action type.", 'Have you misspelled a constant?'].join('\n'));
|
|
132
121
|
}
|
|
133
|
-
|
|
134
122
|
return function reducer(state, action) {
|
|
135
123
|
if (state === void 0) {
|
|
136
124
|
state = initialState;
|
|
137
125
|
}
|
|
138
|
-
|
|
139
126
|
if (hasOwn(action.type, reducersMap)) {
|
|
140
127
|
return reducersMap[action.type](state, action.payload);
|
|
141
128
|
}
|
|
142
|
-
|
|
143
129
|
return state;
|
|
144
130
|
};
|
|
145
|
-
};
|
|
131
|
+
};
|
|
146
132
|
|
|
147
133
|
var CONNECTED = 'connected';
|
|
148
134
|
var DESTROYED = 'destroyed';
|
|
@@ -153,6 +139,8 @@ var RECONNECTING = 'reconnecting';
|
|
|
153
139
|
var AGENT = 'agent';
|
|
154
140
|
var CUSTOMER = 'customer';
|
|
155
141
|
|
|
142
|
+
var LIVECHAT_ORGANIZATION_ID = 'feaf6c0e-9f43-48ff-9ad0-8e24e0350932';
|
|
143
|
+
|
|
156
144
|
var getAllRequests = function getAllRequests(state) {
|
|
157
145
|
return state.requests;
|
|
158
146
|
};
|
|
@@ -175,53 +163,48 @@ var isConnected = function isConnected(state) {
|
|
|
175
163
|
var isDestroyed = function isDestroyed(state) {
|
|
176
164
|
return getConnectionStatus(state) === DESTROYED;
|
|
177
165
|
};
|
|
178
|
-
|
|
179
166
|
var getEnvPart = function getEnvPart(_ref) {
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (licenseId === 1520) {
|
|
167
|
+
var organizationId = _ref.organizationId,
|
|
168
|
+
env = _ref.env;
|
|
169
|
+
if (organizationId === LIVECHAT_ORGANIZATION_ID) {
|
|
184
170
|
return '.staging';
|
|
185
171
|
}
|
|
186
|
-
|
|
187
172
|
if (env === 'production') {
|
|
188
173
|
return '';
|
|
189
174
|
}
|
|
190
|
-
|
|
191
175
|
return "." + env;
|
|
192
176
|
};
|
|
193
|
-
|
|
194
177
|
var getApiOrigin = function getApiOrigin(state) {
|
|
195
178
|
var region = state.region;
|
|
196
179
|
var regionPart = region ? "-" + region : '';
|
|
197
180
|
return "https://api" + regionPart + getEnvPart(state) + ".livechatinc.com";
|
|
198
181
|
};
|
|
199
182
|
var getServerUrl = function getServerUrl(state) {
|
|
200
|
-
return getApiOrigin(state) + "/v3.
|
|
183
|
+
return getApiOrigin(state) + "/v3.4/customer";
|
|
201
184
|
};
|
|
202
185
|
var createInitialState = function createInitialState(initialStateData) {
|
|
203
186
|
var _initialStateData$app = initialStateData.application,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
187
|
+
application = _initialStateData$app === void 0 ? {} : _initialStateData$app,
|
|
188
|
+
organizationId = initialStateData.organizationId,
|
|
189
|
+
_initialStateData$gro = initialStateData.groupId,
|
|
190
|
+
groupId = _initialStateData$gro === void 0 ? null : _initialStateData$gro,
|
|
191
|
+
env = initialStateData.env,
|
|
192
|
+
_initialStateData$pag = initialStateData.page,
|
|
193
|
+
page = _initialStateData$pag === void 0 ? null : _initialStateData$pag,
|
|
194
|
+
_initialStateData$reg = initialStateData.region,
|
|
195
|
+
region = _initialStateData$reg === void 0 ? null : _initialStateData$reg,
|
|
196
|
+
_initialStateData$ref = initialStateData.referrer,
|
|
197
|
+
referrer = _initialStateData$ref === void 0 ? null : _initialStateData$ref,
|
|
198
|
+
_initialStateData$uni = initialStateData.uniqueGroups,
|
|
199
|
+
uniqueGroups = _initialStateData$uni === void 0 ? false : _initialStateData$uni,
|
|
200
|
+
_initialStateData$mob = initialStateData.mobile,
|
|
201
|
+
mobile = _initialStateData$mob === void 0 ? false : _initialStateData$mob;
|
|
219
202
|
return {
|
|
220
203
|
application: _extends({}, application, {
|
|
221
204
|
name: "customer_sdk",
|
|
222
|
-
version: "3.1.
|
|
205
|
+
version: "3.1.3"
|
|
223
206
|
}),
|
|
224
|
-
|
|
207
|
+
organizationId: organizationId,
|
|
225
208
|
env: env,
|
|
226
209
|
groupId: groupId,
|
|
227
210
|
chats: {},
|
|
@@ -243,18 +226,14 @@ var createInitialState = function createInitialState(initialStateData) {
|
|
|
243
226
|
mobile: mobile
|
|
244
227
|
};
|
|
245
228
|
};
|
|
246
|
-
|
|
247
229
|
var removeStoredRequest = function removeStoredRequest(state, _ref2) {
|
|
248
230
|
var id = _ref2.id;
|
|
249
|
-
|
|
250
231
|
var _state$requests = state.requests,
|
|
251
|
-
|
|
252
|
-
|
|
232
|
+
requests = _objectWithoutPropertiesLoose(_state$requests, [id].map(_toPropertyKey));
|
|
253
233
|
return _extends({}, state, {
|
|
254
234
|
requests: requests
|
|
255
235
|
});
|
|
256
236
|
};
|
|
257
|
-
|
|
258
237
|
var setConnectionStatus = function setConnectionStatus(status, state) {
|
|
259
238
|
return _extends({}, state, {
|
|
260
239
|
connection: _extends({}, state.connection, {
|
|
@@ -262,10 +241,8 @@ var setConnectionStatus = function setConnectionStatus(status, state) {
|
|
|
262
241
|
})
|
|
263
242
|
});
|
|
264
243
|
};
|
|
265
|
-
|
|
266
244
|
var createReducer$1 = (function (state) {
|
|
267
245
|
var _createReducer;
|
|
268
|
-
|
|
269
246
|
return createReducer(state, (_createReducer = {}, _createReducer[CHANGE_REGION] = function (state, _ref3) {
|
|
270
247
|
var region = _ref3.region;
|
|
271
248
|
return _extends({}, state, {
|
|
@@ -279,12 +256,11 @@ var createReducer$1 = (function (state) {
|
|
|
279
256
|
return setConnectionStatus(PAUSED, state);
|
|
280
257
|
}, _createReducer[REQUEST_FAILED] = removeStoredRequest, _createReducer[RESPONSE_RECEIVED] = removeStoredRequest, _createReducer[PUSH_RESPONSE_RECEIVED] = removeStoredRequest, _createReducer[SEND_REQUEST] = function (state, _ref4) {
|
|
281
258
|
var _extends2;
|
|
282
|
-
|
|
283
259
|
var promise = _ref4.promise,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
260
|
+
resolve = _ref4.resolve,
|
|
261
|
+
reject = _ref4.reject,
|
|
262
|
+
id = _ref4.id,
|
|
263
|
+
request = _ref4.request;
|
|
288
264
|
return _extends({}, state, {
|
|
289
265
|
requests: _extends({}, state.requests, (_extends2 = {}, _extends2[id] = {
|
|
290
266
|
id: id,
|
|
@@ -296,9 +272,8 @@ var createReducer$1 = (function (state) {
|
|
|
296
272
|
});
|
|
297
273
|
}, _createReducer[SET_CHAT_ACTIVE] = function (state, _ref5) {
|
|
298
274
|
var _extends3;
|
|
299
|
-
|
|
300
275
|
var id = _ref5.id,
|
|
301
|
-
|
|
276
|
+
active = _ref5.active;
|
|
302
277
|
return _extends({}, state, {
|
|
303
278
|
chats: _extends({}, state.chats, (_extends3 = {}, _extends3[id] = _extends({}, state.chats[id], {
|
|
304
279
|
active: active
|
|
@@ -314,11 +289,9 @@ var createReducer$1 = (function (state) {
|
|
|
314
289
|
});
|
|
315
290
|
}, _createReducer[SOCKET_DISCONNECTED] = function (state) {
|
|
316
291
|
var previousStatus = getConnectionStatus(state);
|
|
317
|
-
|
|
318
292
|
if (process.env.NODE_ENV !== 'production' && (previousStatus === PAUSED || previousStatus === DESTROYED)) {
|
|
319
293
|
throw new Error("Got 'socket_disconnected' action when in " + previousStatus + " state. This should be an impossible state.");
|
|
320
294
|
}
|
|
321
|
-
|
|
322
295
|
var state1 = setConnectionStatus(previousStatus === DISCONNECTED ? DISCONNECTED : RECONNECTING, state);
|
|
323
296
|
return _extends({}, state1, {
|
|
324
297
|
requests: {}
|
|
@@ -342,27 +315,27 @@ function finalCreateStore(initialStateData) {
|
|
|
342
315
|
|
|
343
316
|
function createError(_ref) {
|
|
344
317
|
var message = _ref.message,
|
|
345
|
-
|
|
318
|
+
code = _ref.code;
|
|
346
319
|
var error = new Error(message);
|
|
347
320
|
error.code = code;
|
|
348
321
|
return error;
|
|
349
322
|
}
|
|
350
323
|
|
|
351
324
|
var ACCESS_TOKEN_EXPIRED = 'access_token_expired';
|
|
352
|
-
var CUSTOMER_BANNED = 'customer_banned';
|
|
353
|
-
|
|
325
|
+
var CUSTOMER_BANNED = 'customer_banned';
|
|
326
|
+
// customer tried reconnecting too many times after they received too_many_connections error
|
|
354
327
|
var CUSTOMER_TEMPORARILY_BLOCKED = 'customer_temporarily_blocked';
|
|
355
328
|
var LICENSE_EXPIRED = 'license_expired';
|
|
356
329
|
var LICENSE_NOT_FOUND = 'license_not_found';
|
|
357
330
|
var MISDIRECTED_CONNECTION$1 = 'misdirected_connection';
|
|
358
|
-
var PRODUCT_VERSION_CHANGED = 'product_version_changed';
|
|
331
|
+
var PRODUCT_VERSION_CHANGED = 'product_version_changed';
|
|
332
|
+
// the limit of connections per user host has been exceeded
|
|
359
333
|
// or rate limit for new connections has been hit
|
|
360
334
|
// (in 3.2 only the latter case, the first one is using `too_many_connections` to avoid breaking changes)
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
335
|
+
var SERVICE_TEMPORARILY_UNAVAILABLE$1 = 'service_temporarily_unavailable';
|
|
336
|
+
// the limit of those connections is per user
|
|
337
|
+
var TOO_MANY_CONNECTIONS = 'too_many_connections';
|
|
338
|
+
// the limit of unauthorized connections is per IP
|
|
366
339
|
var TOO_MANY_UNAUTHORIZED_CONNECTIONS = 'too_many_unauthorized_connections';
|
|
367
340
|
var UNSUPPORTED_VERSION = 'unsupported_version';
|
|
368
341
|
|
|
@@ -431,20 +404,17 @@ var CUSTOM = 'custom';
|
|
|
431
404
|
|
|
432
405
|
var createEventBase = function createEventBase(event) {
|
|
433
406
|
var base = {};
|
|
434
|
-
|
|
435
407
|
if (typeof event.customId === 'string') {
|
|
436
408
|
base.custom_id = event.customId;
|
|
437
409
|
}
|
|
438
|
-
|
|
439
410
|
if (isObject(event.properties)) {
|
|
440
411
|
base.properties = event.properties;
|
|
441
412
|
}
|
|
442
|
-
|
|
443
413
|
return base;
|
|
444
|
-
};
|
|
445
|
-
// but should we? maybe only in DEV mode?
|
|
446
|
-
|
|
414
|
+
};
|
|
447
415
|
|
|
416
|
+
// TODO: we could validate and throw here
|
|
417
|
+
// but should we? maybe only in DEV mode?
|
|
448
418
|
var parseEvent = function parseEvent(event) {
|
|
449
419
|
switch (event.type) {
|
|
450
420
|
case MESSAGE:
|
|
@@ -453,7 +423,6 @@ var parseEvent = function parseEvent(event) {
|
|
|
453
423
|
type: event.type,
|
|
454
424
|
text: event.text
|
|
455
425
|
});
|
|
456
|
-
|
|
457
426
|
if (event.postback) {
|
|
458
427
|
message.postback = {
|
|
459
428
|
id: event.postback.id,
|
|
@@ -463,10 +432,8 @@ var parseEvent = function parseEvent(event) {
|
|
|
463
432
|
value: event.postback.value
|
|
464
433
|
};
|
|
465
434
|
}
|
|
466
|
-
|
|
467
435
|
return message;
|
|
468
436
|
}
|
|
469
|
-
|
|
470
437
|
case FILE:
|
|
471
438
|
{
|
|
472
439
|
var file = _extends({}, createEventBase(event), {
|
|
@@ -474,10 +441,8 @@ var parseEvent = function parseEvent(event) {
|
|
|
474
441
|
url: event.url,
|
|
475
442
|
alternative_text: event.alternativeText
|
|
476
443
|
});
|
|
477
|
-
|
|
478
444
|
return file;
|
|
479
445
|
}
|
|
480
|
-
|
|
481
446
|
case FILLED_FORM:
|
|
482
447
|
{
|
|
483
448
|
var filledForm = _extends({}, createEventBase(event), {
|
|
@@ -490,27 +455,22 @@ var parseEvent = function parseEvent(event) {
|
|
|
490
455
|
if (!field.answer) {
|
|
491
456
|
return field;
|
|
492
457
|
}
|
|
493
|
-
|
|
494
458
|
var _field$answer = field.answer,
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
459
|
+
groupId = _field$answer.groupId,
|
|
460
|
+
answer = _objectWithoutPropertiesLoose(_field$answer, ["groupId"]);
|
|
498
461
|
return _extends({}, field, {
|
|
499
462
|
answer: _extends({}, answer, {
|
|
500
463
|
group_id: groupId
|
|
501
464
|
})
|
|
502
465
|
});
|
|
503
466
|
}
|
|
504
|
-
|
|
505
467
|
default:
|
|
506
468
|
return field;
|
|
507
469
|
}
|
|
508
470
|
})
|
|
509
471
|
});
|
|
510
|
-
|
|
511
472
|
return filledForm;
|
|
512
473
|
}
|
|
513
|
-
|
|
514
474
|
case SYSTEM_MESSAGE:
|
|
515
475
|
{
|
|
516
476
|
var systemMessage = _extends({}, createEventBase(event), {
|
|
@@ -518,81 +478,64 @@ var parseEvent = function parseEvent(event) {
|
|
|
518
478
|
text: event.text,
|
|
519
479
|
system_message_type: event.systemMessageType
|
|
520
480
|
});
|
|
521
|
-
|
|
522
481
|
if (event.recipients) {
|
|
523
482
|
systemMessage.recipients = event.recipients;
|
|
524
483
|
}
|
|
525
|
-
|
|
526
484
|
return systemMessage;
|
|
527
485
|
}
|
|
528
|
-
|
|
529
486
|
case CUSTOM:
|
|
530
487
|
{
|
|
531
488
|
var customEvent = _extends({}, createEventBase(event), {
|
|
532
489
|
type: event.type
|
|
533
490
|
});
|
|
534
|
-
|
|
535
491
|
if (event.content) {
|
|
536
492
|
customEvent.content = event.content;
|
|
537
493
|
}
|
|
538
|
-
|
|
539
494
|
return customEvent;
|
|
540
495
|
}
|
|
541
496
|
}
|
|
542
497
|
};
|
|
543
|
-
|
|
544
498
|
var parseThreadData = function parseThreadData(thread) {
|
|
545
499
|
var data = {};
|
|
546
500
|
var events = thread.events,
|
|
547
|
-
|
|
548
|
-
|
|
501
|
+
properties = thread.properties;
|
|
549
502
|
if (events) {
|
|
550
503
|
data.events = events.map(parseEvent);
|
|
551
504
|
}
|
|
552
|
-
|
|
553
505
|
if (properties) {
|
|
554
506
|
data.properties = properties;
|
|
555
507
|
}
|
|
556
|
-
|
|
557
508
|
return data;
|
|
558
509
|
};
|
|
559
|
-
|
|
560
510
|
var parseStartChatData = function parseStartChatData(_ref) {
|
|
561
511
|
var _ref$active = _ref.active,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
512
|
+
active = _ref$active === void 0 ? true : _ref$active,
|
|
513
|
+
chat = _ref.chat,
|
|
514
|
+
continuous = _ref.continuous;
|
|
565
515
|
var data = {
|
|
566
516
|
active: active,
|
|
567
517
|
chat: {}
|
|
568
518
|
};
|
|
569
|
-
|
|
570
519
|
if (typeof continuous === 'boolean') {
|
|
571
520
|
data.continuous = continuous;
|
|
572
521
|
}
|
|
573
|
-
|
|
574
522
|
if (!chat) {
|
|
575
523
|
return data;
|
|
576
524
|
}
|
|
577
|
-
|
|
578
525
|
var access = chat.access,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
526
|
+
thread = chat.thread,
|
|
527
|
+
properties = chat.properties;
|
|
582
528
|
if (access && access.groupIds) {
|
|
583
529
|
data.chat.access = {
|
|
584
530
|
group_ids: access.groupIds
|
|
585
531
|
};
|
|
586
532
|
}
|
|
587
|
-
|
|
588
533
|
if (properties) {
|
|
589
534
|
data.chat.properties = properties;
|
|
590
535
|
}
|
|
591
|
-
|
|
592
536
|
if (thread) {
|
|
593
537
|
data.chat.thread = parseThreadData(thread);
|
|
594
538
|
}
|
|
595
|
-
|
|
596
539
|
return data;
|
|
597
540
|
};
|
|
598
541
|
var parseResumeChatData = function parseResumeChatData(requestData) {
|
|
@@ -606,19 +549,16 @@ var parseResumeChatData = function parseResumeChatData(requestData) {
|
|
|
606
549
|
var parseCustomerSessionFields = function parseCustomerSessionFields(sessionFields) {
|
|
607
550
|
return toPairs(sessionFields).map(function (_ref2) {
|
|
608
551
|
var _ref3;
|
|
609
|
-
|
|
610
552
|
var key = _ref2[0],
|
|
611
|
-
|
|
553
|
+
value = _ref2[1];
|
|
612
554
|
return _ref3 = {}, _ref3[key] = value, _ref3;
|
|
613
555
|
});
|
|
614
556
|
};
|
|
615
557
|
var parseCustomerUpdate = function parseCustomerUpdate(update) {
|
|
616
558
|
var result = pickOwn(['avatar', 'name', 'email'], update);
|
|
617
|
-
|
|
618
559
|
if (update.sessionFields) {
|
|
619
560
|
result.session_fields = parseCustomerSessionFields(update.sessionFields);
|
|
620
561
|
}
|
|
621
|
-
|
|
622
562
|
return result;
|
|
623
563
|
};
|
|
624
564
|
|
|
@@ -648,7 +588,6 @@ var prefetchToken = function prefetchToken(fresh) {
|
|
|
648
588
|
if (fresh === void 0) {
|
|
649
589
|
fresh = false;
|
|
650
590
|
}
|
|
651
|
-
|
|
652
591
|
return {
|
|
653
592
|
type: PREFETCH_TOKEN,
|
|
654
593
|
payload: {
|
|
@@ -663,9 +602,10 @@ var reconnect = function reconnect(delay) {
|
|
|
663
602
|
delay: delay
|
|
664
603
|
}
|
|
665
604
|
};
|
|
666
|
-
};
|
|
667
|
-
// we should explore providing stricter types for this in the future
|
|
605
|
+
};
|
|
668
606
|
|
|
607
|
+
// TODO: this one was currently pretty hard to type in full
|
|
608
|
+
// we should explore providing stricter types for this in the future
|
|
669
609
|
var sendRequest = function sendRequest(action, payload, source) {
|
|
670
610
|
return {
|
|
671
611
|
type: SEND_REQUEST,
|
|
@@ -681,17 +621,15 @@ var sendRequest = function sendRequest(action, payload, source) {
|
|
|
681
621
|
};
|
|
682
622
|
var sendEvent = function sendEvent(_ref) {
|
|
683
623
|
var chatId = _ref.chatId,
|
|
684
|
-
|
|
685
|
-
|
|
624
|
+
event = _ref.event,
|
|
625
|
+
attachToLastThread = _ref.attachToLastThread;
|
|
686
626
|
var payload = {
|
|
687
627
|
chat_id: chatId,
|
|
688
628
|
event: parseEvent(event)
|
|
689
629
|
};
|
|
690
|
-
|
|
691
630
|
if (attachToLastThread) {
|
|
692
631
|
payload.attach_to_last_thread = true;
|
|
693
632
|
}
|
|
694
|
-
|
|
695
633
|
return sendRequest(SEND_EVENT, payload);
|
|
696
634
|
};
|
|
697
635
|
var setChatActive = function setChatActive(id, active) {
|
|
@@ -720,12 +658,10 @@ var socketDisconnected = function socketDisconnected() {
|
|
|
720
658
|
// TODO: this thing is not really well typed and should be improved
|
|
721
659
|
var sendRequestAction = function sendRequestAction(store, action) {
|
|
722
660
|
action.payload.id = generateUniqueId(store.getState().requests);
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
promise = _deferred.promise;
|
|
728
|
-
|
|
661
|
+
var _promiseDeferred = promiseDeferred(),
|
|
662
|
+
resolve = _promiseDeferred.resolve,
|
|
663
|
+
reject = _promiseDeferred.reject,
|
|
664
|
+
promise = _promiseDeferred.promise;
|
|
729
665
|
action.payload.promise = promise;
|
|
730
666
|
action.payload.resolve = resolve;
|
|
731
667
|
action.payload.reject = reject;
|
|
@@ -738,32 +674,44 @@ var CUSTOMER_BANNED$1 = 'CUSTOMER_BANNED';
|
|
|
738
674
|
var USERS_LIMIT_REACHED = 'USERS_LIMIT_REACHED';
|
|
739
675
|
var WRONG_PRODUCT_VERSION = 'WRONG_PRODUCT_VERSION';
|
|
740
676
|
|
|
741
|
-
var
|
|
677
|
+
var getSideStorageKeyByLicense = function getSideStorageKeyByLicense(store, licenseId) {
|
|
742
678
|
var _store$getState = store.getState(),
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
uniqueGroups = _store$getState.uniqueGroups;
|
|
746
|
-
|
|
679
|
+
groupId = _store$getState.groupId,
|
|
680
|
+
uniqueGroups = _store$getState.uniqueGroups;
|
|
747
681
|
return "side_storage_" + licenseId + (uniqueGroups ? ":" + groupId : '');
|
|
748
682
|
};
|
|
749
|
-
|
|
750
|
-
var
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
683
|
+
var getSideStorageKeyByOrganization = function getSideStorageKeyByOrganization(store) {
|
|
684
|
+
var _store$getState2 = store.getState(),
|
|
685
|
+
organizationId = _store$getState2.organizationId,
|
|
686
|
+
groupId = _store$getState2.groupId,
|
|
687
|
+
uniqueGroups = _store$getState2.uniqueGroups;
|
|
688
|
+
return "side_storage_" + organizationId + (uniqueGroups ? ":" + groupId : '');
|
|
689
|
+
};
|
|
690
|
+
var getSideStorage = function getSideStorage(store, licenseId) {
|
|
691
|
+
var sideStorageLicenseKey = getSideStorageKeyByLicense(store, licenseId);
|
|
692
|
+
var sideStorageOrganizationKey = getSideStorageKeyByOrganization(store);
|
|
693
|
+
return storage.getItem(sideStorageLicenseKey)["catch"](noop).then(function (sideStorage) {
|
|
694
|
+
if (!sideStorage) {
|
|
695
|
+
return storage.getItem(sideStorageOrganizationKey)["catch"](noop).then(function (organizationSideStorage) {
|
|
696
|
+
return JSON.parse(organizationSideStorage || '{}');
|
|
697
|
+
})["catch"](noop);
|
|
698
|
+
}
|
|
699
|
+
return storage.setItem(sideStorageOrganizationKey, sideStorage)["catch"](noop).then(function () {
|
|
700
|
+
return storage.removeItem(sideStorageLicenseKey)["catch"](noop).then(function () {
|
|
701
|
+
return JSON.parse(sideStorage);
|
|
702
|
+
})["catch"](noop);
|
|
703
|
+
});
|
|
704
|
+
})
|
|
705
|
+
// shouldnt get triggered, just a defensive measure against malformed storage entries
|
|
706
|
+
["catch"](noop);
|
|
757
707
|
};
|
|
758
708
|
var saveSideStorage = function saveSideStorage(store, sideStorage) {
|
|
759
|
-
|
|
709
|
+
storage.setItem(getSideStorageKeyByOrganization(store), JSON.stringify(sideStorage))["catch"](noop);
|
|
760
710
|
};
|
|
761
711
|
|
|
762
712
|
var taskChain = function taskChain(_ref, onSuccess, onError) {
|
|
763
713
|
var steps = _ref.slice(0);
|
|
764
|
-
|
|
765
714
|
var cancelled = false;
|
|
766
|
-
|
|
767
715
|
var next = function next(intermediateResult) {
|
|
768
716
|
var step = steps.shift();
|
|
769
717
|
promiseTry(function () {
|
|
@@ -772,22 +720,18 @@ var taskChain = function taskChain(_ref, onSuccess, onError) {
|
|
|
772
720
|
if (cancelled) {
|
|
773
721
|
return;
|
|
774
722
|
}
|
|
775
|
-
|
|
776
723
|
if (steps.length) {
|
|
777
724
|
next(result);
|
|
778
725
|
return;
|
|
779
726
|
}
|
|
780
|
-
|
|
781
727
|
onSuccess(result);
|
|
782
728
|
}, function (error) {
|
|
783
729
|
if (cancelled) {
|
|
784
730
|
return;
|
|
785
731
|
}
|
|
786
|
-
|
|
787
732
|
onError(error);
|
|
788
733
|
});
|
|
789
734
|
};
|
|
790
|
-
|
|
791
735
|
next();
|
|
792
736
|
return {
|
|
793
737
|
cancel: function cancel() {
|
|
@@ -795,18 +739,15 @@ var taskChain = function taskChain(_ref, onSuccess, onError) {
|
|
|
795
739
|
}
|
|
796
740
|
};
|
|
797
741
|
};
|
|
798
|
-
|
|
799
742
|
var sendLoginFlowRequest = function sendLoginFlowRequest(store, type, payload) {
|
|
800
743
|
return sendRequestAction(store, sendRequest(type, payload, 'login'));
|
|
801
744
|
};
|
|
802
|
-
|
|
803
745
|
var delay = function delay(ms) {
|
|
804
746
|
return new Promise(function (resolve) {
|
|
805
747
|
setTimeout(resolve, ms);
|
|
806
748
|
});
|
|
807
749
|
};
|
|
808
|
-
|
|
809
|
-
function createLoginTask(auth, customerDataProvider) {
|
|
750
|
+
function createLoginTask(auth, customerDataProvider, licenseId) {
|
|
810
751
|
var store;
|
|
811
752
|
var sentPage = null;
|
|
812
753
|
var task;
|
|
@@ -820,24 +761,19 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
820
761
|
min: 1000
|
|
821
762
|
}));
|
|
822
763
|
var currentBackoffStrategy = defaultBackoffStrategy;
|
|
823
|
-
|
|
824
764
|
var destroy$1 = function destroy$1(reason) {
|
|
825
765
|
return store.dispatch(destroy(reason));
|
|
826
766
|
};
|
|
827
|
-
|
|
828
767
|
var reconnect$1 = function reconnect$1() {
|
|
829
768
|
return store.dispatch(reconnect(currentBackoffStrategy.duration()));
|
|
830
769
|
};
|
|
831
|
-
|
|
832
770
|
var getTokenAndSideStorage = function getTokenAndSideStorage() {
|
|
833
|
-
return Promise.all([auth.getToken(), getSideStorage(store)]);
|
|
771
|
+
return Promise.all([auth.getToken(), getSideStorage(store, licenseId)]);
|
|
834
772
|
};
|
|
835
|
-
|
|
836
773
|
var dispatchSelfId = function dispatchSelfId(_ref2) {
|
|
837
774
|
var token = _ref2[0],
|
|
838
|
-
|
|
775
|
+
sideStorage = _ref2[1];
|
|
839
776
|
var selfId = getSelfId(store.getState());
|
|
840
|
-
|
|
841
777
|
if (selfId === null) {
|
|
842
778
|
store.dispatch(setSelfId(token.entityId));
|
|
843
779
|
} else if (selfId !== token.entityId) {
|
|
@@ -845,19 +781,17 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
845
781
|
err.code = IDENTITY_MISMATCH;
|
|
846
782
|
throw err;
|
|
847
783
|
}
|
|
848
|
-
|
|
849
784
|
return [token, sideStorage];
|
|
850
785
|
};
|
|
851
|
-
|
|
852
786
|
var _sendLogin = function sendLogin(_ref3) {
|
|
853
787
|
var token = _ref3[0],
|
|
854
|
-
|
|
788
|
+
sideStorage = _ref3[1];
|
|
855
789
|
var state = store.getState();
|
|
856
790
|
var application = state.application,
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
791
|
+
groupId = state.groupId,
|
|
792
|
+
page = state.page,
|
|
793
|
+
referrer = state.referrer,
|
|
794
|
+
mobile = state.mobile;
|
|
861
795
|
var payload = {
|
|
862
796
|
token: token.tokenType + " " + token.accessToken,
|
|
863
797
|
customer: typeof customerDataProvider === 'function' ? parseCustomerUpdate(customerDataProvider()) : {},
|
|
@@ -865,24 +799,19 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
865
799
|
is_mobile: mobile,
|
|
866
800
|
application: pick(['name', 'version'], application)
|
|
867
801
|
};
|
|
868
|
-
|
|
869
802
|
if (typeof groupId === 'number') {
|
|
870
803
|
payload.group_id = groupId;
|
|
871
804
|
}
|
|
872
|
-
|
|
873
805
|
if (application.channelType) {
|
|
874
806
|
payload.application.channel_type = application.channelType;
|
|
875
807
|
}
|
|
876
|
-
|
|
877
808
|
if (page !== null) {
|
|
878
809
|
sentPage = page;
|
|
879
810
|
payload.customer_page = page;
|
|
880
811
|
}
|
|
881
|
-
|
|
882
812
|
if (referrer !== null) {
|
|
883
813
|
payload.referrer = referrer;
|
|
884
814
|
}
|
|
885
|
-
|
|
886
815
|
return Promise.race([sendLoginFlowRequest(store, LOGIN, payload), delay(15 * 1000).then(function () {
|
|
887
816
|
return Promise.reject(createError({
|
|
888
817
|
message: 'Request timed out.',
|
|
@@ -890,22 +819,17 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
890
819
|
}));
|
|
891
820
|
})]);
|
|
892
821
|
};
|
|
893
|
-
|
|
894
822
|
var updateCustomerPageIfNeeded = function updateCustomerPageIfNeeded() {
|
|
895
823
|
var _store$getState = store.getState(),
|
|
896
|
-
|
|
897
|
-
|
|
824
|
+
page = _store$getState.page;
|
|
898
825
|
if (sentPage !== page) {
|
|
899
826
|
sendLoginFlowRequest(store, UPDATE_CUSTOMER_PAGE$1, page)["catch"](noop);
|
|
900
827
|
}
|
|
901
|
-
|
|
902
828
|
sentPage = null;
|
|
903
829
|
};
|
|
904
|
-
|
|
905
830
|
return {
|
|
906
831
|
sendLogin: function sendLogin(_store) {
|
|
907
832
|
var _task;
|
|
908
|
-
|
|
909
833
|
// after switching to callbags, we should be able to use smth similar to redux-observable
|
|
910
834
|
// and thus just use store given to epic
|
|
911
835
|
store = _store;
|
|
@@ -914,62 +838,52 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
914
838
|
task = null;
|
|
915
839
|
defaultBackoffStrategy.reset();
|
|
916
840
|
slowerBackoffStrategy.reset();
|
|
917
|
-
currentBackoffStrategy = defaultBackoffStrategy;
|
|
841
|
+
currentBackoffStrategy = defaultBackoffStrategy;
|
|
918
842
|
|
|
843
|
+
// TODO: rethink if this should be handled by SDK consumer
|
|
919
844
|
updateCustomerPageIfNeeded();
|
|
920
845
|
store.dispatch(loginSuccess(loginResponse));
|
|
921
846
|
}, function (error) {
|
|
922
847
|
task = null;
|
|
923
|
-
|
|
924
848
|
if (process.env.NODE_ENV !== 'production') {
|
|
925
849
|
console.error('[Customer SDK] Login flow has thrown code', error.code, 'with', error);
|
|
926
850
|
}
|
|
927
|
-
|
|
928
851
|
switch (error.code) {
|
|
929
852
|
case AUTHENTICATION:
|
|
930
853
|
auth.getFreshToken();
|
|
931
854
|
reconnect$1();
|
|
932
855
|
return;
|
|
933
|
-
|
|
934
856
|
case CONNECTION_LOST:
|
|
935
857
|
// this is connectivity problem, not a server error
|
|
936
858
|
// and is taken care of in socket module
|
|
937
859
|
// as it has its own backoff implementation
|
|
938
860
|
return;
|
|
939
|
-
|
|
940
861
|
case MISDIRECTED_CONNECTION:
|
|
941
862
|
// socket gets reinitialized on this anyway, so just ignore it here
|
|
942
863
|
return;
|
|
943
|
-
|
|
944
864
|
case SDK_DESTROYED:
|
|
945
865
|
return;
|
|
946
866
|
// those are auth errors, we should maybe export those constants from the auth package
|
|
947
|
-
|
|
948
867
|
case 'SSO_IDENTITY_EXCEPTION':
|
|
949
868
|
case 'SSO_OAUTH_EXCEPTION':
|
|
950
869
|
if (error.message === 'server_error' || error.message === 'temporarily_unavailable') {
|
|
951
870
|
reconnect$1();
|
|
952
871
|
return;
|
|
953
872
|
}
|
|
954
|
-
|
|
955
873
|
destroy$1(error.message);
|
|
956
874
|
return;
|
|
957
|
-
|
|
958
875
|
case USERS_LIMIT_REACHED:
|
|
959
876
|
store.dispatch(pauseConnection(error.code.toLowerCase()));
|
|
960
877
|
return;
|
|
961
|
-
|
|
962
878
|
case IDENTITY_MISMATCH:
|
|
963
879
|
case CUSTOMER_BANNED$1:
|
|
964
880
|
case WRONG_PRODUCT_VERSION:
|
|
965
881
|
destroy$1(error.code.toLowerCase());
|
|
966
882
|
return;
|
|
967
|
-
|
|
968
883
|
case SERVICE_TEMPORARILY_UNAVAILABLE:
|
|
969
884
|
currentBackoffStrategy = slowerBackoffStrategy;
|
|
970
885
|
reconnect$1();
|
|
971
886
|
return;
|
|
972
|
-
|
|
973
887
|
default:
|
|
974
888
|
reconnect$1();
|
|
975
889
|
return;
|
|
@@ -978,7 +892,6 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
978
892
|
},
|
|
979
893
|
cancel: function cancel() {
|
|
980
894
|
var _task2;
|
|
981
|
-
|
|
982
895
|
(_task2 = task) == null ? void 0 : _task2.cancel();
|
|
983
896
|
}
|
|
984
897
|
};
|
|
@@ -987,19 +900,15 @@ function createLoginTask(auth, customerDataProvider) {
|
|
|
987
900
|
var checkGoals = function checkGoals(store, auth, sessionFields) {
|
|
988
901
|
return auth.getToken().then(function (token) {
|
|
989
902
|
var state = store.getState();
|
|
990
|
-
|
|
991
903
|
if (getSelfId(state) === null) {
|
|
992
904
|
store.dispatch(setSelfId(token.entityId));
|
|
993
905
|
}
|
|
994
|
-
|
|
995
906
|
var page = state.page;
|
|
996
|
-
|
|
997
907
|
if (!page || !page.url) {
|
|
998
908
|
return;
|
|
999
909
|
}
|
|
1000
|
-
|
|
1001
910
|
var query = buildQueryString({
|
|
1002
|
-
|
|
911
|
+
organization_id: state.organizationId
|
|
1003
912
|
});
|
|
1004
913
|
var payload = {
|
|
1005
914
|
session_fields: parseCustomerSessionFields(sessionFields || {}),
|
|
@@ -1022,7 +931,7 @@ var checkGoals = function checkGoals(store, auth, sessionFields) {
|
|
|
1022
931
|
|
|
1023
932
|
var failAllRequests = function failAllRequests(_ref, reason) {
|
|
1024
933
|
var getState = _ref.getState,
|
|
1025
|
-
|
|
934
|
+
dispatch = _ref.dispatch;
|
|
1026
935
|
var state = getState();
|
|
1027
936
|
var requests = getAllRequests(state);
|
|
1028
937
|
dispatch({
|
|
@@ -1037,7 +946,7 @@ var failAllRequests = function failAllRequests(_ref, reason) {
|
|
|
1037
946
|
};
|
|
1038
947
|
var failRequest = function failRequest(_ref2, requestAction, error) {
|
|
1039
948
|
var getState = _ref2.getState,
|
|
1040
|
-
|
|
949
|
+
dispatch = _ref2.dispatch;
|
|
1041
950
|
var requestId = requestAction.payload.id;
|
|
1042
951
|
dispatch({
|
|
1043
952
|
type: REQUEST_FAILED,
|
|
@@ -1061,22 +970,17 @@ var parseCommonEventProps = function parseCommonEventProps(threadId, event) {
|
|
|
1061
970
|
threadId: threadId,
|
|
1062
971
|
properties: event.properties || {}
|
|
1063
972
|
};
|
|
1064
|
-
|
|
1065
973
|
if (event.custom_id !== undefined) {
|
|
1066
974
|
parsed.customId = event.custom_id;
|
|
1067
975
|
}
|
|
1068
|
-
|
|
1069
976
|
return parsed;
|
|
1070
977
|
};
|
|
1071
|
-
|
|
1072
978
|
var downsizeWithRatio = function downsizeWithRatio(max, dimensions) {
|
|
1073
979
|
var _ref;
|
|
1074
|
-
|
|
1075
980
|
var biggerProp;
|
|
1076
981
|
var smallerProp;
|
|
1077
982
|
var bigger;
|
|
1078
983
|
var smaller;
|
|
1079
|
-
|
|
1080
984
|
if (dimensions.height > dimensions.width) {
|
|
1081
985
|
biggerProp = 'height';
|
|
1082
986
|
smallerProp = 'width';
|
|
@@ -1088,11 +992,9 @@ var downsizeWithRatio = function downsizeWithRatio(max, dimensions) {
|
|
|
1088
992
|
bigger = dimensions.width;
|
|
1089
993
|
smaller = dimensions.height;
|
|
1090
994
|
}
|
|
1091
|
-
|
|
1092
995
|
var ratio = max / bigger;
|
|
1093
996
|
return _ref = {}, _ref[biggerProp] = Math.ceil(Math.min(bigger, max)), _ref[smallerProp] = Math.ceil(Math.min(ratio * smaller, smaller)), _ref;
|
|
1094
997
|
};
|
|
1095
|
-
|
|
1096
998
|
var parseImage = function parseImage(thread, image) {
|
|
1097
999
|
return _extends({}, parseCommonEventProps(thread, image), {
|
|
1098
1000
|
type: FILE,
|
|
@@ -1113,12 +1015,10 @@ var parseImage = function parseImage(thread, image) {
|
|
|
1113
1015
|
alternativeText: image.alternative_text
|
|
1114
1016
|
});
|
|
1115
1017
|
};
|
|
1116
|
-
|
|
1117
1018
|
var parseFile = function parseFile(thread, file) {
|
|
1118
1019
|
if (file.width !== undefined && file.height !== undefined) {
|
|
1119
1020
|
return parseImage(thread, file);
|
|
1120
1021
|
}
|
|
1121
|
-
|
|
1122
1022
|
return _extends({}, parseCommonEventProps(thread, file), {
|
|
1123
1023
|
type: FILE,
|
|
1124
1024
|
contentType: file.content_type,
|
|
@@ -1145,18 +1045,15 @@ var parseFilledForm = function parseFilledForm(thread, filledForm) {
|
|
|
1145
1045
|
if (!field.answer) {
|
|
1146
1046
|
return field;
|
|
1147
1047
|
}
|
|
1148
|
-
|
|
1149
1048
|
var _field$answer = field.answer,
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1049
|
+
groupId = _field$answer.group_id,
|
|
1050
|
+
answer = _objectWithoutPropertiesLoose(_field$answer, ["group_id"]);
|
|
1153
1051
|
return _extends({}, field, {
|
|
1154
1052
|
answer: _extends({}, answer, {
|
|
1155
1053
|
groupId: groupId
|
|
1156
1054
|
})
|
|
1157
1055
|
});
|
|
1158
1056
|
}
|
|
1159
|
-
|
|
1160
1057
|
default:
|
|
1161
1058
|
return field;
|
|
1162
1059
|
}
|
|
@@ -1176,18 +1073,14 @@ var parseCustomEvent = function parseCustomEvent(thread, event) {
|
|
|
1176
1073
|
content: event.content
|
|
1177
1074
|
});
|
|
1178
1075
|
};
|
|
1179
|
-
|
|
1180
1076
|
var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
1181
1077
|
var parsed = {};
|
|
1182
|
-
|
|
1183
1078
|
if (typeof element.title === 'string') {
|
|
1184
1079
|
parsed.title = element.title;
|
|
1185
1080
|
}
|
|
1186
|
-
|
|
1187
1081
|
if (typeof element.subtitle === 'string') {
|
|
1188
1082
|
parsed.subtitle = element.subtitle;
|
|
1189
1083
|
}
|
|
1190
|
-
|
|
1191
1084
|
if (element.image) {
|
|
1192
1085
|
// TODO: we should reuse parseImage here
|
|
1193
1086
|
var image = element.image;
|
|
@@ -1198,7 +1091,6 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1198
1091
|
alternativeText: image.alternative_text
|
|
1199
1092
|
});
|
|
1200
1093
|
}
|
|
1201
|
-
|
|
1202
1094
|
if (element.buttons) {
|
|
1203
1095
|
parsed.buttons = element.buttons.map(function (serverButton) {
|
|
1204
1096
|
switch (serverButton.type) {
|
|
@@ -1214,7 +1106,6 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1214
1106
|
role: serverButton.role || 'default'
|
|
1215
1107
|
};
|
|
1216
1108
|
}
|
|
1217
|
-
|
|
1218
1109
|
case 'cancel':
|
|
1219
1110
|
{
|
|
1220
1111
|
return {
|
|
@@ -1225,7 +1116,6 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1225
1116
|
role: serverButton.role || 'default'
|
|
1226
1117
|
};
|
|
1227
1118
|
}
|
|
1228
|
-
|
|
1229
1119
|
case 'url':
|
|
1230
1120
|
{
|
|
1231
1121
|
var button = {
|
|
@@ -1236,14 +1126,11 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1236
1126
|
value: serverButton.value,
|
|
1237
1127
|
role: serverButton.role || 'default'
|
|
1238
1128
|
};
|
|
1239
|
-
|
|
1240
1129
|
if (serverButton.target) {
|
|
1241
1130
|
button.target = serverButton.target;
|
|
1242
1131
|
}
|
|
1243
|
-
|
|
1244
1132
|
return button;
|
|
1245
1133
|
}
|
|
1246
|
-
|
|
1247
1134
|
case 'webview':
|
|
1248
1135
|
{
|
|
1249
1136
|
var _button = {
|
|
@@ -1254,14 +1141,11 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1254
1141
|
value: serverButton.value,
|
|
1255
1142
|
role: serverButton.role || 'default'
|
|
1256
1143
|
};
|
|
1257
|
-
|
|
1258
1144
|
if (typeof serverButton.webview_height === 'string') {
|
|
1259
1145
|
_button.webviewHeight = serverButton.webview_height;
|
|
1260
1146
|
}
|
|
1261
|
-
|
|
1262
1147
|
return _button;
|
|
1263
1148
|
}
|
|
1264
|
-
|
|
1265
1149
|
default:
|
|
1266
1150
|
{
|
|
1267
1151
|
return {
|
|
@@ -1274,10 +1158,8 @@ var parseRichMessageElement = function parseRichMessageElement(element) {
|
|
|
1274
1158
|
}
|
|
1275
1159
|
});
|
|
1276
1160
|
}
|
|
1277
|
-
|
|
1278
1161
|
return parsed;
|
|
1279
1162
|
};
|
|
1280
|
-
|
|
1281
1163
|
var parseRichMessage = function parseRichMessage(thread, richMessage) {
|
|
1282
1164
|
switch (richMessage.template_id) {
|
|
1283
1165
|
case 'cards':
|
|
@@ -1288,7 +1170,6 @@ var parseRichMessage = function parseRichMessage(thread, richMessage) {
|
|
|
1288
1170
|
template: richMessage.template_id,
|
|
1289
1171
|
elements: richMessage.elements.map(parseRichMessageElement)
|
|
1290
1172
|
});
|
|
1291
|
-
|
|
1292
1173
|
default:
|
|
1293
1174
|
return null;
|
|
1294
1175
|
}
|
|
@@ -1301,36 +1182,27 @@ var parseSystemMessage = function parseSystemMessage(thread, systemMessage) {
|
|
|
1301
1182
|
text: systemMessage.text,
|
|
1302
1183
|
systemMessageType: systemMessage.system_message_type
|
|
1303
1184
|
});
|
|
1304
|
-
|
|
1305
1185
|
if (systemMessage.text_vars) {
|
|
1306
1186
|
parsed.textVars = systemMessage.text_vars;
|
|
1307
1187
|
}
|
|
1308
|
-
|
|
1309
1188
|
return parsed;
|
|
1310
1189
|
};
|
|
1311
1190
|
var parseEvent$1 = function parseEvent(thread, event) {
|
|
1312
1191
|
switch (event.type) {
|
|
1313
1192
|
case FILE:
|
|
1314
1193
|
return parseFile(thread, event);
|
|
1315
|
-
|
|
1316
1194
|
case FORM:
|
|
1317
1195
|
return parseForm(thread, event);
|
|
1318
|
-
|
|
1319
1196
|
case FILLED_FORM:
|
|
1320
1197
|
return parseFilledForm(thread, event);
|
|
1321
|
-
|
|
1322
1198
|
case MESSAGE:
|
|
1323
1199
|
return parseMessage(thread, event);
|
|
1324
|
-
|
|
1325
1200
|
case RICH_MESSAGE:
|
|
1326
1201
|
return parseRichMessage(thread, event);
|
|
1327
|
-
|
|
1328
1202
|
case SYSTEM_MESSAGE:
|
|
1329
1203
|
return parseSystemMessage(thread, event);
|
|
1330
|
-
|
|
1331
1204
|
case CUSTOM:
|
|
1332
1205
|
return parseCustomEvent(thread, event);
|
|
1333
|
-
|
|
1334
1206
|
default:
|
|
1335
1207
|
return null;
|
|
1336
1208
|
}
|
|
@@ -1355,23 +1227,20 @@ var parseGreeting = function parseGreeting(greeting) {
|
|
|
1355
1227
|
};
|
|
1356
1228
|
};
|
|
1357
1229
|
|
|
1230
|
+
// we could use `mergeAll` for this, but we need to preserve insertion order here
|
|
1358
1231
|
// so it's better to rely on a custom implementation
|
|
1359
|
-
|
|
1360
1232
|
var parseCustomerSessionFields$1 = function parseCustomerSessionFields(sessionFields) {
|
|
1361
1233
|
return sessionFields.reduce(function (acc, field) {
|
|
1362
1234
|
var _Object$keys = Object.keys(field),
|
|
1363
|
-
|
|
1364
|
-
|
|
1235
|
+
key = _Object$keys[0];
|
|
1365
1236
|
acc[key] = field[key];
|
|
1366
1237
|
return acc;
|
|
1367
1238
|
}, {});
|
|
1368
1239
|
};
|
|
1369
|
-
|
|
1370
1240
|
var parseAccess = function parseAccess(access) {
|
|
1371
1241
|
if (access === void 0) {
|
|
1372
1242
|
access = {};
|
|
1373
1243
|
}
|
|
1374
|
-
|
|
1375
1244
|
return access.group_ids ? {
|
|
1376
1245
|
groupIds: access.group_ids
|
|
1377
1246
|
} : {};
|
|
@@ -1423,14 +1292,11 @@ var parseChatAgent = function parseChatAgent(agent) {
|
|
|
1423
1292
|
};
|
|
1424
1293
|
var parseCustomerOptionalProps = function parseCustomerOptionalProps(customerProps) {
|
|
1425
1294
|
var optionalProps = pickOwn(['avatar', 'email', 'name'], customerProps);
|
|
1426
|
-
|
|
1427
1295
|
if (customerProps.session_fields) {
|
|
1428
1296
|
optionalProps.sessionFields = parseCustomerSessionFields$1(customerProps.session_fields);
|
|
1429
1297
|
}
|
|
1430
|
-
|
|
1431
1298
|
return optionalProps;
|
|
1432
1299
|
};
|
|
1433
|
-
|
|
1434
1300
|
var parseCustomerCommonProps = function parseCustomerCommonProps(customer) {
|
|
1435
1301
|
var optionalProps = parseCustomerOptionalProps(customer);
|
|
1436
1302
|
return _extends({
|
|
@@ -1440,7 +1306,6 @@ var parseCustomerCommonProps = function parseCustomerCommonProps(customer) {
|
|
|
1440
1306
|
sessionFields: optionalProps.sessionFields || {}
|
|
1441
1307
|
});
|
|
1442
1308
|
};
|
|
1443
|
-
|
|
1444
1309
|
var parseChatCustomer = function parseChatCustomer(customer) {
|
|
1445
1310
|
return _extends({}, parseCustomerCommonProps(customer), {
|
|
1446
1311
|
present: customer.present
|
|
@@ -1461,7 +1326,7 @@ var parseCustomer = function parseCustomer(customer) {
|
|
|
1461
1326
|
};
|
|
1462
1327
|
var parsePredictedAgent = function parsePredictedAgent(payload) {
|
|
1463
1328
|
var agent = payload.agent,
|
|
1464
|
-
|
|
1329
|
+
queue = payload.queue;
|
|
1465
1330
|
return {
|
|
1466
1331
|
agent: {
|
|
1467
1332
|
id: agent.id,
|
|
@@ -1494,12 +1359,11 @@ var parseGroupStatus = function parseGroupStatus(status) {
|
|
|
1494
1359
|
|
|
1495
1360
|
var _FAIL_ALL_REQUESTS_ME;
|
|
1496
1361
|
|
|
1362
|
+
// TODO: rethink how we handle reconnects
|
|
1497
1363
|
var SMALL_RECONNECT_DELAY = 100;
|
|
1498
1364
|
var FAIL_ALL_REQUESTS_MESSAGES = (_FAIL_ALL_REQUESTS_ME = {}, _FAIL_ALL_REQUESTS_ME[CONNECTION_LOST] = 'Connection lost.', _FAIL_ALL_REQUESTS_ME[MISDIRECTED_CONNECTION] = 'Connected to wrong region.', _FAIL_ALL_REQUESTS_ME);
|
|
1499
|
-
|
|
1500
1365
|
var updateStateIfNeeded = function updateStateIfNeeded(store, action) {
|
|
1501
1366
|
var state = store.getState();
|
|
1502
|
-
|
|
1503
1367
|
switch (action.type) {
|
|
1504
1368
|
case PUSH_RESPONSE_RECEIVED:
|
|
1505
1369
|
case PUSH_RECEIVED:
|
|
@@ -1507,56 +1371,49 @@ var updateStateIfNeeded = function updateStateIfNeeded(store, action) {
|
|
|
1507
1371
|
case CHAT_DEACTIVATED:
|
|
1508
1372
|
store.dispatch(setChatActive(action.payload.payload.chatId, false));
|
|
1509
1373
|
return;
|
|
1510
|
-
|
|
1511
1374
|
case INCOMING_CHAT:
|
|
1512
1375
|
store.dispatch(setChatActive(action.payload.payload.chat.id, true));
|
|
1513
1376
|
return;
|
|
1514
|
-
|
|
1515
1377
|
default:
|
|
1516
1378
|
return;
|
|
1517
1379
|
}
|
|
1518
|
-
|
|
1519
1380
|
case RESPONSE_RECEIVED:
|
|
1520
1381
|
switch (action.payload.action) {
|
|
1521
1382
|
case LIST_CHATS:
|
|
1522
1383
|
action.payload.payload.chatsSummary.filter(function (_ref) {
|
|
1523
1384
|
var id = _ref.id,
|
|
1524
|
-
|
|
1385
|
+
active = _ref.active;
|
|
1525
1386
|
return isChatActive(state, id) !== active;
|
|
1526
1387
|
}).forEach(function (_ref2) {
|
|
1527
1388
|
var id = _ref2.id,
|
|
1528
|
-
|
|
1389
|
+
active = _ref2.active;
|
|
1529
1390
|
store.dispatch(setChatActive(id, active));
|
|
1530
1391
|
});
|
|
1531
1392
|
return;
|
|
1532
|
-
|
|
1533
1393
|
default:
|
|
1534
1394
|
return;
|
|
1535
1395
|
}
|
|
1536
|
-
|
|
1537
1396
|
}
|
|
1538
1397
|
};
|
|
1539
|
-
|
|
1540
1398
|
var sendRequest$1 = function sendRequest(socket, _ref3) {
|
|
1541
1399
|
var _ref3$payload = _ref3.payload,
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1400
|
+
id = _ref3$payload.id,
|
|
1401
|
+
request = _ref3$payload.request;
|
|
1545
1402
|
var frame = _extends({
|
|
1546
1403
|
request_id: id
|
|
1547
1404
|
}, request);
|
|
1548
|
-
|
|
1549
1405
|
switch (frame.action) {
|
|
1550
1406
|
case LOGIN:
|
|
1551
1407
|
{
|
|
1552
1408
|
var upgradedPushes = [];
|
|
1553
1409
|
socket.emit(_extends({}, frame, {
|
|
1554
|
-
version: '3.
|
|
1410
|
+
version: '3.4',
|
|
1555
1411
|
payload: _extends({}, frame.payload, {
|
|
1556
1412
|
pushes: {
|
|
1557
|
-
// '3.
|
|
1558
|
-
'3.
|
|
1559
|
-
return (
|
|
1413
|
+
// '3.5': upgradedPushes,
|
|
1414
|
+
'3.4': values(serverPushActions).filter(function (pushAction) {
|
|
1415
|
+
return (
|
|
1416
|
+
// `customer_disconnected` can be sent immediately after opening the connection, before it even received login request
|
|
1560
1417
|
// therefore it's not possible to subscribe for a particular version of this push - the "connection version" is always used
|
|
1561
1418
|
pushAction !== CUSTOMER_DISCONNECTED && !includes(pushAction, upgradedPushes)
|
|
1562
1419
|
);
|
|
@@ -1566,56 +1423,45 @@ var sendRequest$1 = function sendRequest(socket, _ref3) {
|
|
|
1566
1423
|
}));
|
|
1567
1424
|
return;
|
|
1568
1425
|
}
|
|
1569
|
-
|
|
1570
1426
|
default:
|
|
1571
1427
|
socket.emit(frame);
|
|
1572
1428
|
return;
|
|
1573
1429
|
}
|
|
1574
1430
|
};
|
|
1575
|
-
|
|
1576
1431
|
var emitUsers = function emitUsers(emit, users) {
|
|
1577
1432
|
users.forEach(function (user) {
|
|
1578
1433
|
if ('present' in user) {
|
|
1579
1434
|
var rest = _objectWithoutPropertiesLoose(user, ["present"]);
|
|
1580
|
-
|
|
1581
1435
|
emit('user_data', rest);
|
|
1582
1436
|
return;
|
|
1583
1437
|
}
|
|
1584
|
-
|
|
1585
1438
|
if (user.type === CUSTOMER) {
|
|
1586
1439
|
var _rest = _objectWithoutPropertiesLoose(user, ["statistics"]);
|
|
1587
|
-
|
|
1588
1440
|
emit('user_data', _rest);
|
|
1589
1441
|
return;
|
|
1590
1442
|
}
|
|
1591
|
-
|
|
1592
1443
|
emit('user_data', user);
|
|
1593
1444
|
});
|
|
1594
1445
|
};
|
|
1595
|
-
|
|
1596
1446
|
var handleMulticast = function handleMulticast(emit, _ref4) {
|
|
1597
1447
|
var type = _ref4.type,
|
|
1598
|
-
|
|
1599
|
-
|
|
1448
|
+
content = _ref4.content;
|
|
1600
1449
|
if (type !== 'lc2') {
|
|
1601
1450
|
return;
|
|
1602
1451
|
}
|
|
1603
|
-
|
|
1604
1452
|
if (content.name === 'groups_update' && 'groups' in content && !isEmpty(content.groups)) {
|
|
1605
1453
|
var _content$groups = content.groups,
|
|
1606
|
-
|
|
1454
|
+
group = _content$groups[0];
|
|
1607
1455
|
var availability = parseGroupStatus(group.status);
|
|
1608
1456
|
emit('availability_updated', {
|
|
1609
1457
|
availability: availability
|
|
1610
1458
|
});
|
|
1611
1459
|
}
|
|
1612
1460
|
};
|
|
1613
|
-
|
|
1614
1461
|
var handlePush = function handlePush(_ref5, _ref6) {
|
|
1615
1462
|
var emit = _ref5.emit,
|
|
1616
|
-
|
|
1463
|
+
store = _ref5.store;
|
|
1617
1464
|
var payload = _ref6.payload;
|
|
1618
|
-
|
|
1619
1465
|
switch (payload.action) {
|
|
1620
1466
|
case THREAD_PROPERTIES_UPDATED:
|
|
1621
1467
|
if (payload.payload.properties.lc2 && 'queue_pos' in payload.payload.properties.lc2) {
|
|
@@ -1628,14 +1474,11 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1628
1474
|
}
|
|
1629
1475
|
});
|
|
1630
1476
|
}
|
|
1631
|
-
|
|
1632
1477
|
emit('thread_properties_updated', payload.payload);
|
|
1633
1478
|
return;
|
|
1634
|
-
|
|
1635
1479
|
case CUSTOMER_SIDE_STORAGE_UPDATED:
|
|
1636
1480
|
saveSideStorage(store, payload.payload.customer_side_storage);
|
|
1637
1481
|
return;
|
|
1638
|
-
|
|
1639
1482
|
case CUSTOMER_DISCONNECTED:
|
|
1640
1483
|
// each of those should currently lead to either reconnect or destroy call
|
|
1641
1484
|
// after receiving this push server closes the connection with us
|
|
@@ -1652,7 +1495,6 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1652
1495
|
store.dispatch(reconnect(SMALL_RECONNECT_DELAY));
|
|
1653
1496
|
emit('disconnected', payload.payload);
|
|
1654
1497
|
break;
|
|
1655
|
-
|
|
1656
1498
|
case CUSTOMER_BANNED:
|
|
1657
1499
|
case CUSTOMER_TEMPORARILY_BLOCKED:
|
|
1658
1500
|
case LICENSE_NOT_FOUND:
|
|
@@ -1662,7 +1504,6 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1662
1504
|
// this also emits `disconnected` event - but it's handled in response to this action by destroy handler
|
|
1663
1505
|
store.dispatch(destroy(payload.payload.reason));
|
|
1664
1506
|
break;
|
|
1665
|
-
|
|
1666
1507
|
case MISDIRECTED_CONNECTION$1:
|
|
1667
1508
|
failAllRequests(store, MISDIRECTED_CONNECTION);
|
|
1668
1509
|
store.dispatch({
|
|
@@ -1670,119 +1511,99 @@ var handlePush = function handlePush(_ref5, _ref6) {
|
|
|
1670
1511
|
payload: payload.payload.data
|
|
1671
1512
|
});
|
|
1672
1513
|
break;
|
|
1673
|
-
|
|
1674
1514
|
case SERVICE_TEMPORARILY_UNAVAILABLE$1:
|
|
1675
1515
|
case TOO_MANY_UNAUTHORIZED_CONNECTIONS:
|
|
1676
1516
|
// this should only really fail a `login` request - as it's the only one sent before authorization
|
|
1677
1517
|
// and login should reconnect on its own right now
|
|
1678
1518
|
failAllRequests(store, payload.payload.reason.toUpperCase());
|
|
1679
1519
|
break;
|
|
1680
|
-
|
|
1681
1520
|
default:
|
|
1682
1521
|
store.dispatch(reconnect(SMALL_RECONNECT_DELAY));
|
|
1683
1522
|
emit('disconnected', payload.payload);
|
|
1684
1523
|
break;
|
|
1685
1524
|
}
|
|
1686
|
-
|
|
1687
1525
|
return;
|
|
1688
|
-
|
|
1689
1526
|
case INCOMING_CHAT:
|
|
1690
1527
|
emitUsers(emit, payload.payload.chat.users);
|
|
1691
1528
|
emit(payload.action, payload.payload);
|
|
1692
1529
|
return;
|
|
1693
|
-
|
|
1694
1530
|
case INCOMING_EVENT:
|
|
1695
1531
|
if (payload.payload.event === null) {
|
|
1696
1532
|
return;
|
|
1697
1533
|
}
|
|
1698
|
-
|
|
1699
1534
|
emit(payload.action, payload.payload);
|
|
1700
1535
|
return;
|
|
1701
|
-
|
|
1702
1536
|
case INCOMING_TYPING_INDICATOR:
|
|
1703
1537
|
emit(payload.action, payload.payload);
|
|
1704
1538
|
return;
|
|
1705
|
-
|
|
1706
1539
|
case INCOMING_MULTICAST:
|
|
1707
|
-
handleMulticast(emit, payload.payload);
|
|
1708
|
-
|
|
1540
|
+
handleMulticast(emit, payload.payload);
|
|
1541
|
+
// we passthrough this action even if it was already handled above
|
|
1709
1542
|
emit(payload.action, payload.payload);
|
|
1710
1543
|
return;
|
|
1711
|
-
|
|
1712
1544
|
case USER_ADDED_TO_CHAT:
|
|
1713
1545
|
emitUsers(emit, [payload.payload.user]);
|
|
1714
1546
|
emit(payload.action, payload.payload);
|
|
1715
1547
|
return;
|
|
1716
|
-
|
|
1717
1548
|
default:
|
|
1718
1549
|
emit(payload.action, payload.payload);
|
|
1719
1550
|
return;
|
|
1720
1551
|
}
|
|
1721
1552
|
};
|
|
1722
|
-
|
|
1723
1553
|
var handleResponse = function handleResponse(_ref7, _ref8) {
|
|
1724
1554
|
var emit = _ref7.emit;
|
|
1725
1555
|
var payload = _ref8.payload;
|
|
1726
|
-
|
|
1727
1556
|
switch (payload.action) {
|
|
1728
1557
|
case CHAT_DEACTIVATED:
|
|
1729
1558
|
payload.resolve(SUCCESS);
|
|
1730
1559
|
return;
|
|
1731
|
-
|
|
1732
1560
|
case GET_CHAT:
|
|
1733
1561
|
emitUsers(emit, payload.payload.users);
|
|
1734
1562
|
payload.resolve(payload.payload);
|
|
1735
1563
|
return;
|
|
1736
|
-
|
|
1737
1564
|
case INCOMING_CHAT:
|
|
1738
1565
|
emitUsers(emit, payload.payload.chat.users);
|
|
1739
1566
|
payload.resolve(payload.payload);
|
|
1740
1567
|
return;
|
|
1741
|
-
|
|
1742
1568
|
case INCOMING_EVENT:
|
|
1743
1569
|
payload.resolve(payload.payload.event);
|
|
1744
1570
|
return;
|
|
1745
|
-
|
|
1746
1571
|
case LIST_CHATS:
|
|
1747
1572
|
emitUsers(emit, payload.payload.users);
|
|
1748
1573
|
payload.resolve(payload.payload);
|
|
1749
1574
|
return;
|
|
1750
|
-
|
|
1751
1575
|
default:
|
|
1752
1576
|
payload.resolve(payload.payload);
|
|
1753
1577
|
return;
|
|
1754
1578
|
}
|
|
1755
1579
|
};
|
|
1756
|
-
|
|
1757
1580
|
var createSideEffectsHandler = (function (_ref9) {
|
|
1758
1581
|
var auth = _ref9.auth,
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1582
|
+
customerDataProvider = _ref9.customerDataProvider,
|
|
1583
|
+
emitter = _ref9.emitter,
|
|
1584
|
+
socket = _ref9.socket,
|
|
1585
|
+
licenseId = _ref9.licenseId;
|
|
1762
1586
|
var emit = emitter.emit;
|
|
1763
|
-
var loginTask = createLoginTask(auth, customerDataProvider);
|
|
1587
|
+
var loginTask = createLoginTask(auth, customerDataProvider, licenseId);
|
|
1764
1588
|
|
|
1589
|
+
// TODO: using Store type here is a lie, middleware only provides MiddlewareAPI here
|
|
1765
1590
|
return function (action, store) {
|
|
1766
1591
|
switch (action.type) {
|
|
1767
1592
|
case CHANGE_REGION:
|
|
1768
1593
|
socket.reinitialize();
|
|
1769
1594
|
return;
|
|
1770
|
-
|
|
1771
1595
|
case CHECK_GOALS:
|
|
1772
1596
|
checkGoals(store, auth, action.payload.sessionFields)["catch"](noop);
|
|
1773
1597
|
return;
|
|
1774
|
-
|
|
1775
1598
|
case DESTROY:
|
|
1776
1599
|
{
|
|
1777
1600
|
var payload = action.payload;
|
|
1778
1601
|
loginTask.cancel();
|
|
1779
1602
|
socket.destroy();
|
|
1780
|
-
|
|
1781
1603
|
switch (payload.reason) {
|
|
1782
1604
|
case 'manual':
|
|
1783
1605
|
failAllRequests(store, SDK_DESTROYED);
|
|
1784
1606
|
break;
|
|
1785
|
-
|
|
1786
1607
|
case CUSTOMER_BANNED:
|
|
1787
1608
|
case LICENSE_EXPIRED:
|
|
1788
1609
|
case PRODUCT_VERSION_CHANGED:
|
|
@@ -1790,7 +1611,6 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1790
1611
|
failAllRequests(store, CONNECTION_LOST);
|
|
1791
1612
|
emit('disconnected', payload);
|
|
1792
1613
|
break;
|
|
1793
|
-
|
|
1794
1614
|
default:
|
|
1795
1615
|
// in general those deestroys should only come either from login errors
|
|
1796
1616
|
// or from customer_disconnected pushes that are sent immediately after connection
|
|
@@ -1799,16 +1619,14 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1799
1619
|
emit('disconnected', payload);
|
|
1800
1620
|
break;
|
|
1801
1621
|
}
|
|
1802
|
-
|
|
1803
1622
|
emitter.off();
|
|
1804
1623
|
return;
|
|
1805
1624
|
}
|
|
1806
|
-
|
|
1807
1625
|
case FAIL_ALL_REQUESTS:
|
|
1808
1626
|
{
|
|
1809
1627
|
var _action$payload = action.payload,
|
|
1810
|
-
|
|
1811
|
-
|
|
1628
|
+
reason = _action$payload.reason,
|
|
1629
|
+
rejects = _action$payload.rejects;
|
|
1812
1630
|
var error = {
|
|
1813
1631
|
message: FAIL_ALL_REQUESTS_MESSAGES[reason],
|
|
1814
1632
|
code: reason
|
|
@@ -1818,23 +1636,20 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1818
1636
|
});
|
|
1819
1637
|
return;
|
|
1820
1638
|
}
|
|
1821
|
-
|
|
1822
1639
|
case LOGIN_SUCCESS:
|
|
1823
1640
|
{
|
|
1824
1641
|
var _action$payload2 = action.payload,
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1642
|
+
dynamicConfig = _action$payload2.dynamicConfig,
|
|
1643
|
+
customer = _action$payload2.customer,
|
|
1644
|
+
chats = _action$payload2.chats,
|
|
1645
|
+
greeting = _action$payload2.greeting,
|
|
1646
|
+
availability = _action$payload2.availability;
|
|
1831
1647
|
var eventData = _extends({
|
|
1832
1648
|
customer: customer,
|
|
1833
1649
|
availability: availability
|
|
1834
1650
|
}, greeting && {
|
|
1835
1651
|
greeting: greeting
|
|
1836
1652
|
});
|
|
1837
|
-
|
|
1838
1653
|
Object.defineProperty(eventData, '__unsafeDynamicConfig', {
|
|
1839
1654
|
value: dynamicConfig
|
|
1840
1655
|
});
|
|
@@ -1844,45 +1659,37 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1844
1659
|
emit('connected', eventData);
|
|
1845
1660
|
return;
|
|
1846
1661
|
}
|
|
1847
|
-
|
|
1848
1662
|
case PAUSE_CONNECTION:
|
|
1849
1663
|
{
|
|
1850
1664
|
var _payload = action.payload;
|
|
1851
1665
|
socket.disconnect();
|
|
1852
|
-
|
|
1853
1666
|
if (_payload.reason !== 'manual') {
|
|
1854
1667
|
emit('disconnected', _payload);
|
|
1855
1668
|
}
|
|
1856
|
-
|
|
1857
1669
|
return;
|
|
1858
1670
|
}
|
|
1859
|
-
|
|
1860
1671
|
case PREFETCH_TOKEN:
|
|
1861
1672
|
if (action.payload.fresh) {
|
|
1862
1673
|
auth.getFreshToken()["catch"](noop);
|
|
1863
1674
|
return;
|
|
1864
1675
|
}
|
|
1865
|
-
|
|
1866
1676
|
auth.hasToken().then(function (hasToken) {
|
|
1867
1677
|
if (!hasToken) {
|
|
1868
1678
|
return auth.getToken();
|
|
1869
1679
|
}
|
|
1870
|
-
|
|
1871
1680
|
return auth.getToken().then(function (_ref10) {
|
|
1872
1681
|
var creationDate = _ref10.creationDate,
|
|
1873
|
-
|
|
1874
|
-
var ONE_HOUR = 60 * 60 * 1000;
|
|
1682
|
+
expiresIn = _ref10.expiresIn;
|
|
1683
|
+
var ONE_HOUR = 60 * 60 * 1000;
|
|
1684
|
+
// check if the token is worth reusing
|
|
1875
1685
|
// we don't want to get disconnected in a moment because of expired token
|
|
1876
|
-
|
|
1877
1686
|
if (creationDate + expiresIn - Date.now() > ONE_HOUR) {
|
|
1878
1687
|
return;
|
|
1879
1688
|
}
|
|
1880
|
-
|
|
1881
1689
|
return auth.invalidate().then(auth.getFreshToken);
|
|
1882
1690
|
});
|
|
1883
1691
|
})["catch"](noop);
|
|
1884
1692
|
return;
|
|
1885
|
-
|
|
1886
1693
|
case PUSH_RECEIVED:
|
|
1887
1694
|
// TODO: this if doesn't seem to make much sense
|
|
1888
1695
|
// I'm too afraid to remove it right now though
|
|
@@ -1893,46 +1700,39 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1893
1700
|
}, action);
|
|
1894
1701
|
return;
|
|
1895
1702
|
}
|
|
1896
|
-
|
|
1897
1703
|
updateStateIfNeeded(store, action);
|
|
1898
1704
|
handlePush({
|
|
1899
1705
|
emit: emit,
|
|
1900
1706
|
store: store
|
|
1901
1707
|
}, action);
|
|
1902
1708
|
return;
|
|
1903
|
-
|
|
1904
1709
|
case PUSH_RESPONSE_RECEIVED:
|
|
1905
1710
|
updateStateIfNeeded(store, action);
|
|
1906
1711
|
handleResponse({
|
|
1907
1712
|
emit: emit
|
|
1908
1713
|
}, action);
|
|
1909
1714
|
return;
|
|
1910
|
-
|
|
1911
1715
|
case RECONNECT:
|
|
1912
1716
|
failAllRequests(store, CONNECTION_LOST);
|
|
1913
1717
|
socket.reconnect(action.payload.delay);
|
|
1914
1718
|
return;
|
|
1915
|
-
|
|
1916
1719
|
case REQUEST_FAILED:
|
|
1917
1720
|
{
|
|
1918
1721
|
var _action$payload3 = action.payload,
|
|
1919
|
-
|
|
1920
|
-
|
|
1722
|
+
reject = _action$payload3.reject,
|
|
1723
|
+
_error = _action$payload3.error;
|
|
1921
1724
|
reject(createError(_error));
|
|
1922
1725
|
return;
|
|
1923
1726
|
}
|
|
1924
|
-
|
|
1925
1727
|
case RESPONSE_RECEIVED:
|
|
1926
1728
|
updateStateIfNeeded(store, action);
|
|
1927
1729
|
handleResponse({
|
|
1928
1730
|
emit: emit
|
|
1929
1731
|
}, action);
|
|
1930
1732
|
return;
|
|
1931
|
-
|
|
1932
1733
|
case SEND_REQUEST:
|
|
1933
1734
|
{
|
|
1934
1735
|
var state = store.getState();
|
|
1935
|
-
|
|
1936
1736
|
if (isDestroyed(state)) {
|
|
1937
1737
|
failRequest(store, action, {
|
|
1938
1738
|
code: SDK_DESTROYED,
|
|
@@ -1940,7 +1740,6 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1940
1740
|
});
|
|
1941
1741
|
return;
|
|
1942
1742
|
}
|
|
1943
|
-
|
|
1944
1743
|
if (!isConnected(state) && action.payload.source !== 'login') {
|
|
1945
1744
|
failRequest(store, action, {
|
|
1946
1745
|
code: NO_CONNECTION,
|
|
@@ -1948,56 +1747,44 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
1948
1747
|
});
|
|
1949
1748
|
return;
|
|
1950
1749
|
}
|
|
1951
|
-
|
|
1952
1750
|
sendRequest$1(socket, action);
|
|
1953
1751
|
}
|
|
1954
1752
|
return;
|
|
1955
|
-
|
|
1956
1753
|
case SET_SELF_ID:
|
|
1957
1754
|
emit('customer_id', action.payload.id);
|
|
1958
1755
|
return;
|
|
1959
|
-
|
|
1960
1756
|
case SOCKET_DISCONNECTED:
|
|
1961
1757
|
emit('disconnected', {
|
|
1962
1758
|
reason: 'connection_lost'
|
|
1963
1759
|
});
|
|
1964
1760
|
return;
|
|
1965
|
-
|
|
1966
1761
|
case SOCKET_CONNECTED:
|
|
1967
1762
|
loginTask.sendLogin(store);
|
|
1968
1763
|
return;
|
|
1969
|
-
|
|
1970
1764
|
case SOCKET_RECOVERED:
|
|
1971
1765
|
// don't emit if from consumer's perspective we haven't been connected
|
|
1972
1766
|
if (!isConnected(store.getState())) {
|
|
1973
1767
|
return;
|
|
1974
1768
|
}
|
|
1975
|
-
|
|
1976
1769
|
emit('connection_recovered');
|
|
1977
1770
|
return;
|
|
1978
|
-
|
|
1979
1771
|
case SOCKET_UNSTABLE:
|
|
1980
1772
|
// don't emit if from consumer's perspective we haven't been connected
|
|
1981
1773
|
if (!isConnected(store.getState())) {
|
|
1982
1774
|
return;
|
|
1983
1775
|
}
|
|
1984
|
-
|
|
1985
1776
|
emit('connection_unstable');
|
|
1986
1777
|
return;
|
|
1987
|
-
|
|
1988
1778
|
case START_CONNECTION:
|
|
1989
1779
|
socket.connect();
|
|
1990
1780
|
store.dispatch(prefetchToken());
|
|
1991
1781
|
return;
|
|
1992
|
-
|
|
1993
1782
|
case UPDATE_CUSTOMER_PAGE:
|
|
1994
1783
|
if (!isConnected(store.getState())) {
|
|
1995
1784
|
return;
|
|
1996
1785
|
}
|
|
1997
|
-
|
|
1998
1786
|
sendRequestAction(store, sendRequest(UPDATE_CUSTOMER_PAGE$1, action.payload))["catch"](noop);
|
|
1999
1787
|
return;
|
|
2000
|
-
|
|
2001
1788
|
default:
|
|
2002
1789
|
return;
|
|
2003
1790
|
}
|
|
@@ -2005,7 +1792,6 @@ var createSideEffectsHandler = (function (_ref9) {
|
|
|
2005
1792
|
});
|
|
2006
1793
|
|
|
2007
1794
|
var HISTORY_EVENT_COUNT_TARGET = 25;
|
|
2008
|
-
|
|
2009
1795
|
var createState = function createState() {
|
|
2010
1796
|
return {
|
|
2011
1797
|
status: 'idle',
|
|
@@ -2013,10 +1799,8 @@ var createState = function createState() {
|
|
|
2013
1799
|
nextPageId: null
|
|
2014
1800
|
};
|
|
2015
1801
|
};
|
|
2016
|
-
|
|
2017
1802
|
var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId) {
|
|
2018
1803
|
var historyState = createState();
|
|
2019
|
-
|
|
2020
1804
|
var next = function next(resolve, reject) {
|
|
2021
1805
|
switch (historyState.status) {
|
|
2022
1806
|
case 'idle':
|
|
@@ -2029,9 +1813,8 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2029
1813
|
minEventsCount: HISTORY_EVENT_COUNT_TARGET
|
|
2030
1814
|
}).then(function (_ref) {
|
|
2031
1815
|
var threads = _ref.threads,
|
|
2032
|
-
|
|
1816
|
+
nextPageId = _ref.nextPageId;
|
|
2033
1817
|
historyState.nextPageId = nextPageId;
|
|
2034
|
-
|
|
2035
1818
|
if (!historyState.nextPageId) {
|
|
2036
1819
|
historyState.status = 'done';
|
|
2037
1820
|
resolve({
|
|
@@ -2049,13 +1832,10 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2049
1832
|
done: false
|
|
2050
1833
|
});
|
|
2051
1834
|
}
|
|
2052
|
-
|
|
2053
1835
|
var queuedTask = historyState.queuedTasks.shift();
|
|
2054
|
-
|
|
2055
1836
|
if (!queuedTask) {
|
|
2056
1837
|
return;
|
|
2057
1838
|
}
|
|
2058
|
-
|
|
2059
1839
|
next(queuedTask.resolve, queuedTask.reject);
|
|
2060
1840
|
}, function (err) {
|
|
2061
1841
|
var queuedTasks = historyState.queuedTasks;
|
|
@@ -2067,14 +1847,12 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2067
1847
|
});
|
|
2068
1848
|
});
|
|
2069
1849
|
return;
|
|
2070
|
-
|
|
2071
1850
|
case 'fetching':
|
|
2072
1851
|
historyState.queuedTasks.push({
|
|
2073
1852
|
resolve: resolve,
|
|
2074
1853
|
reject: reject
|
|
2075
1854
|
});
|
|
2076
1855
|
return;
|
|
2077
|
-
|
|
2078
1856
|
case 'done':
|
|
2079
1857
|
resolve({
|
|
2080
1858
|
value: undefined,
|
|
@@ -2083,17 +1861,14 @@ var createChatHistoryIterator = function createChatHistoryIterator(sdk, chatId)
|
|
|
2083
1861
|
return;
|
|
2084
1862
|
}
|
|
2085
1863
|
};
|
|
2086
|
-
|
|
2087
1864
|
return {
|
|
2088
1865
|
next: function (_next) {
|
|
2089
1866
|
function next() {
|
|
2090
1867
|
return _next.apply(this, arguments);
|
|
2091
1868
|
}
|
|
2092
|
-
|
|
2093
1869
|
next.toString = function () {
|
|
2094
1870
|
return _next.toString();
|
|
2095
1871
|
};
|
|
2096
|
-
|
|
2097
1872
|
return next;
|
|
2098
1873
|
}(function () {
|
|
2099
1874
|
return new Promise(next);
|
|
@@ -2106,22 +1881,19 @@ var initialize = function initialize(store, emitter) {
|
|
|
2106
1881
|
var url = (getServerUrl(state) + "/rtm/ws").replace(/^https/, 'wss');
|
|
2107
1882
|
return createPlatformClient(url, {
|
|
2108
1883
|
query: {
|
|
2109
|
-
|
|
1884
|
+
organization_id: state.organizationId
|
|
2110
1885
|
},
|
|
2111
1886
|
emitter: emitter
|
|
2112
1887
|
});
|
|
2113
1888
|
};
|
|
2114
|
-
|
|
2115
1889
|
var createSocketClient = function createSocketClient(store) {
|
|
2116
1890
|
var emitter = mitt();
|
|
2117
1891
|
var client = initialize(store, emitter);
|
|
2118
1892
|
return _extends({}, Object.keys(client).reduce(function (proxy, method) {
|
|
2119
1893
|
proxy[method] = function () {
|
|
2120
1894
|
var _client;
|
|
2121
|
-
|
|
2122
1895
|
return (_client = client)[method].apply(_client, arguments);
|
|
2123
1896
|
};
|
|
2124
|
-
|
|
2125
1897
|
return proxy;
|
|
2126
1898
|
}, {}), {
|
|
2127
1899
|
reinitialize: function reinitialize() {
|
|
@@ -2138,14 +1910,12 @@ var parseChatPropertiesDeletedPush = function parseChatPropertiesDeletedPush(pay
|
|
|
2138
1910
|
properties: payload.properties
|
|
2139
1911
|
};
|
|
2140
1912
|
};
|
|
2141
|
-
|
|
2142
1913
|
var parseChatPropertiesUpdatedPush = function parseChatPropertiesUpdatedPush(payload) {
|
|
2143
1914
|
return {
|
|
2144
1915
|
chatId: payload.chat_id,
|
|
2145
1916
|
properties: payload.properties
|
|
2146
1917
|
};
|
|
2147
1918
|
};
|
|
2148
|
-
|
|
2149
1919
|
var parseChatTransferredPush = function parseChatTransferredPush(payload) {
|
|
2150
1920
|
var basePayload = {
|
|
2151
1921
|
chatId: payload.chat_id,
|
|
@@ -2157,19 +1927,16 @@ var parseChatTransferredPush = function parseChatTransferredPush(payload) {
|
|
|
2157
1927
|
}),
|
|
2158
1928
|
queue: payload.queue ? parseQueue(payload.queue) : null
|
|
2159
1929
|
};
|
|
2160
|
-
|
|
2161
1930
|
if (payload.reason === 'manual') {
|
|
2162
1931
|
return _extends({}, basePayload, {
|
|
2163
1932
|
reason: payload.reason,
|
|
2164
1933
|
requesterId: payload.requester_id
|
|
2165
1934
|
});
|
|
2166
1935
|
}
|
|
2167
|
-
|
|
2168
1936
|
return _extends({}, basePayload, {
|
|
2169
1937
|
reason: payload.reason
|
|
2170
1938
|
});
|
|
2171
1939
|
};
|
|
2172
|
-
|
|
2173
1940
|
var parseCustomerPageUpdatedPush = function parseCustomerPageUpdatedPush(payload) {
|
|
2174
1941
|
return {
|
|
2175
1942
|
url: payload.url,
|
|
@@ -2177,13 +1944,11 @@ var parseCustomerPageUpdatedPush = function parseCustomerPageUpdatedPush(payload
|
|
|
2177
1944
|
openedAt: payload.opened_at
|
|
2178
1945
|
};
|
|
2179
1946
|
};
|
|
2180
|
-
|
|
2181
1947
|
var parseCustomerUpdatedPush = function parseCustomerUpdatedPush(payload) {
|
|
2182
1948
|
return _extends({
|
|
2183
1949
|
id: payload.id
|
|
2184
1950
|
}, parseCustomerOptionalProps(payload));
|
|
2185
1951
|
};
|
|
2186
|
-
|
|
2187
1952
|
var parseEventPropertiesDeletedPush = function parseEventPropertiesDeletedPush(payload) {
|
|
2188
1953
|
return {
|
|
2189
1954
|
chatId: payload.chat_id,
|
|
@@ -2192,7 +1957,6 @@ var parseEventPropertiesDeletedPush = function parseEventPropertiesDeletedPush(p
|
|
|
2192
1957
|
properties: payload.properties
|
|
2193
1958
|
};
|
|
2194
1959
|
};
|
|
2195
|
-
|
|
2196
1960
|
var parseEventPropertiesUpdatedPush = function parseEventPropertiesUpdatedPush(payload) {
|
|
2197
1961
|
return {
|
|
2198
1962
|
chatId: payload.chat_id,
|
|
@@ -2201,7 +1965,6 @@ var parseEventPropertiesUpdatedPush = function parseEventPropertiesUpdatedPush(p
|
|
|
2201
1965
|
properties: payload.properties
|
|
2202
1966
|
};
|
|
2203
1967
|
};
|
|
2204
|
-
|
|
2205
1968
|
var parseEventUpdatedPush = function parseEventUpdatedPush(payload) {
|
|
2206
1969
|
var threadId = payload.thread_id;
|
|
2207
1970
|
return {
|
|
@@ -2210,7 +1973,6 @@ var parseEventUpdatedPush = function parseEventUpdatedPush(payload) {
|
|
|
2210
1973
|
event: parseEvent$1(threadId, payload.event)
|
|
2211
1974
|
};
|
|
2212
1975
|
};
|
|
2213
|
-
|
|
2214
1976
|
var parseEventsMarkedAsSeenPush = function parseEventsMarkedAsSeenPush(payload) {
|
|
2215
1977
|
return {
|
|
2216
1978
|
chatId: payload.chat_id,
|
|
@@ -2218,19 +1980,16 @@ var parseEventsMarkedAsSeenPush = function parseEventsMarkedAsSeenPush(payload)
|
|
|
2218
1980
|
seenUpTo: payload.seen_up_to
|
|
2219
1981
|
};
|
|
2220
1982
|
};
|
|
2221
|
-
|
|
2222
1983
|
var parseGreetingAcceptedPush = function parseGreetingAcceptedPush(payload) {
|
|
2223
1984
|
return {
|
|
2224
1985
|
uniqueId: payload.unique_id
|
|
2225
1986
|
};
|
|
2226
1987
|
};
|
|
2227
|
-
|
|
2228
1988
|
var parseGetChatResponse = function parseGetChatResponse(payload) {
|
|
2229
1989
|
return _extends({}, parseChatCommon(payload), {
|
|
2230
1990
|
thread: payload.thread ? parseThread(payload.id, payload.thread) : null
|
|
2231
1991
|
});
|
|
2232
1992
|
};
|
|
2233
|
-
|
|
2234
1993
|
var parseIncomingChatPush = function parseIncomingChatPush(payload) {
|
|
2235
1994
|
var chat = payload.chat;
|
|
2236
1995
|
return {
|
|
@@ -2239,18 +1998,15 @@ var parseIncomingChatPush = function parseIncomingChatPush(payload) {
|
|
|
2239
1998
|
})
|
|
2240
1999
|
};
|
|
2241
2000
|
};
|
|
2242
|
-
|
|
2243
2001
|
var parseIncomingEventPush = function parseIncomingEventPush(payload) {
|
|
2244
2002
|
return {
|
|
2245
2003
|
chatId: payload.chat_id,
|
|
2246
2004
|
event: parseEvent$1(payload.thread_id, payload.event)
|
|
2247
2005
|
};
|
|
2248
2006
|
};
|
|
2249
|
-
|
|
2250
2007
|
var parseIncomingGreetingPush = function parseIncomingGreetingPush(payload) {
|
|
2251
2008
|
return parseGreeting(payload);
|
|
2252
2009
|
};
|
|
2253
|
-
|
|
2254
2010
|
var parseIncomingRichMessagePostbackPush = function parseIncomingRichMessagePostbackPush(payload) {
|
|
2255
2011
|
return {
|
|
2256
2012
|
userId: payload.user_id,
|
|
@@ -2260,10 +2016,9 @@ var parseIncomingRichMessagePostbackPush = function parseIncomingRichMessagePost
|
|
|
2260
2016
|
postback: payload.postback
|
|
2261
2017
|
};
|
|
2262
2018
|
};
|
|
2263
|
-
|
|
2264
2019
|
var parseIncomingTypingIndicatorPush = function parseIncomingTypingIndicatorPush(payload) {
|
|
2265
2020
|
var chatId = payload.chat_id,
|
|
2266
|
-
|
|
2021
|
+
typingIndicator = payload.typing_indicator;
|
|
2267
2022
|
return {
|
|
2268
2023
|
chatId: chatId,
|
|
2269
2024
|
typingIndicator: {
|
|
@@ -2272,7 +2027,6 @@ var parseIncomingTypingIndicatorPush = function parseIncomingTypingIndicatorPush
|
|
|
2272
2027
|
}
|
|
2273
2028
|
};
|
|
2274
2029
|
};
|
|
2275
|
-
|
|
2276
2030
|
var parseQueuePositionUpdatedPush = function parseQueuePositionUpdatedPush(payload) {
|
|
2277
2031
|
return {
|
|
2278
2032
|
chatId: payload.chat_id,
|
|
@@ -2280,7 +2034,6 @@ var parseQueuePositionUpdatedPush = function parseQueuePositionUpdatedPush(paylo
|
|
|
2280
2034
|
queue: parseQueueUpdate(payload.queue)
|
|
2281
2035
|
};
|
|
2282
2036
|
};
|
|
2283
|
-
|
|
2284
2037
|
var parseThreadPropertiesDeletedPush = function parseThreadPropertiesDeletedPush(payload) {
|
|
2285
2038
|
return {
|
|
2286
2039
|
chatId: payload.chat_id,
|
|
@@ -2288,7 +2041,6 @@ var parseThreadPropertiesDeletedPush = function parseThreadPropertiesDeletedPush
|
|
|
2288
2041
|
properties: payload.properties
|
|
2289
2042
|
};
|
|
2290
2043
|
};
|
|
2291
|
-
|
|
2292
2044
|
var parseThreadPropertiesUpdatedPush = function parseThreadPropertiesUpdatedPush(payload) {
|
|
2293
2045
|
return {
|
|
2294
2046
|
chatId: payload.chat_id,
|
|
@@ -2296,7 +2048,6 @@ var parseThreadPropertiesUpdatedPush = function parseThreadPropertiesUpdatedPush
|
|
|
2296
2048
|
properties: payload.properties
|
|
2297
2049
|
};
|
|
2298
2050
|
};
|
|
2299
|
-
|
|
2300
2051
|
var parseUserAddedToChatPush = function parseUserAddedToChatPush(payload) {
|
|
2301
2052
|
return {
|
|
2302
2053
|
chatId: payload.chat_id,
|
|
@@ -2304,14 +2055,12 @@ var parseUserAddedToChatPush = function parseUserAddedToChatPush(payload) {
|
|
|
2304
2055
|
present: payload.user.present
|
|
2305
2056
|
};
|
|
2306
2057
|
};
|
|
2307
|
-
|
|
2308
2058
|
var parseUserRemovedFromChatPush = function parseUserRemovedFromChatPush(payload) {
|
|
2309
2059
|
return {
|
|
2310
2060
|
chatId: payload.chat_id,
|
|
2311
2061
|
userId: payload.user_id
|
|
2312
2062
|
};
|
|
2313
2063
|
};
|
|
2314
|
-
|
|
2315
2064
|
var parseFields = function parseFields(fields) {
|
|
2316
2065
|
return fields.map(function (field) {
|
|
2317
2066
|
switch (field.type) {
|
|
@@ -2319,30 +2068,25 @@ var parseFields = function parseFields(fields) {
|
|
|
2319
2068
|
return _extends({}, field, {
|
|
2320
2069
|
options: field.options.map(function (_ref) {
|
|
2321
2070
|
var groupId = _ref.group_id,
|
|
2322
|
-
|
|
2323
|
-
|
|
2071
|
+
option = _objectWithoutPropertiesLoose(_ref, ["group_id"]);
|
|
2324
2072
|
return _extends({}, option, {
|
|
2325
2073
|
groupId: groupId
|
|
2326
2074
|
});
|
|
2327
2075
|
})
|
|
2328
2076
|
});
|
|
2329
|
-
|
|
2330
2077
|
case 'rating':
|
|
2331
2078
|
{
|
|
2332
2079
|
var commentLabel = field.comment_label,
|
|
2333
|
-
|
|
2334
|
-
|
|
2080
|
+
parsed = _objectWithoutPropertiesLoose(field, ["comment_label"]);
|
|
2335
2081
|
return _extends({}, parsed, {
|
|
2336
2082
|
commentLabel: commentLabel
|
|
2337
2083
|
});
|
|
2338
2084
|
}
|
|
2339
|
-
|
|
2340
2085
|
default:
|
|
2341
2086
|
return field;
|
|
2342
2087
|
}
|
|
2343
2088
|
});
|
|
2344
2089
|
};
|
|
2345
|
-
|
|
2346
2090
|
var parseTicketFormFields = function parseTicketFormFields(fields) {
|
|
2347
2091
|
var withFakeIds = fields.map(function (field, index) {
|
|
2348
2092
|
return _extends({}, field, {
|
|
@@ -2351,7 +2095,6 @@ var parseTicketFormFields = function parseTicketFormFields(fields) {
|
|
|
2351
2095
|
});
|
|
2352
2096
|
return parseFields(withFakeIds);
|
|
2353
2097
|
};
|
|
2354
|
-
|
|
2355
2098
|
var parseForm$1 = function parseForm(form) {
|
|
2356
2099
|
var isTicketForm = !('id' in form.fields[0]);
|
|
2357
2100
|
return {
|
|
@@ -2359,66 +2102,54 @@ var parseForm$1 = function parseForm(form) {
|
|
|
2359
2102
|
fields: isTicketForm ? parseTicketFormFields(form.fields) : parseFields(form.fields)
|
|
2360
2103
|
};
|
|
2361
2104
|
};
|
|
2362
|
-
|
|
2363
2105
|
var parseGetFormResponse = function parseGetFormResponse(payload) {
|
|
2364
2106
|
if (!payload.enabled) {
|
|
2365
2107
|
return payload;
|
|
2366
2108
|
}
|
|
2367
|
-
|
|
2368
2109
|
return _extends({}, payload, {
|
|
2369
2110
|
form: parseForm$1(payload.form)
|
|
2370
2111
|
});
|
|
2371
2112
|
};
|
|
2372
|
-
|
|
2373
2113
|
var parseGetUrlInfoResponse = function parseGetUrlInfoResponse(payload) {
|
|
2374
2114
|
var urlInfo = {
|
|
2375
2115
|
url: payload.url
|
|
2376
2116
|
};
|
|
2377
|
-
|
|
2378
2117
|
if (payload.title) {
|
|
2379
2118
|
urlInfo.title = payload.title;
|
|
2380
2119
|
}
|
|
2381
|
-
|
|
2382
2120
|
if (payload.description) {
|
|
2383
2121
|
urlInfo.description = payload.description;
|
|
2384
2122
|
}
|
|
2385
|
-
|
|
2386
2123
|
if (payload.image_url) {
|
|
2387
|
-
urlInfo.imageUrl = "https://" + payload.image_url;
|
|
2388
|
-
|
|
2124
|
+
urlInfo.imageUrl = "https://" + removeProtocol(payload.image_url);
|
|
2389
2125
|
if (payload.image_width && payload.image_height) {
|
|
2390
2126
|
urlInfo.imageWidth = payload.image_width;
|
|
2391
2127
|
urlInfo.imageHeight = payload.image_height;
|
|
2392
2128
|
}
|
|
2393
2129
|
}
|
|
2394
|
-
|
|
2395
2130
|
return urlInfo;
|
|
2396
2131
|
};
|
|
2397
|
-
|
|
2398
2132
|
var getAvailabilityBasedOnDynamicConfig = function getAvailabilityBasedOnDynamicConfig(_ref2) {
|
|
2399
2133
|
var onlineGroups = _ref2.online_groups_ids,
|
|
2400
|
-
|
|
2401
|
-
|
|
2134
|
+
customerGroups = _ref2.customer_groups;
|
|
2402
2135
|
// this might be missing if all groups are offline
|
|
2403
2136
|
if (!onlineGroups) {
|
|
2404
2137
|
return 'offline';
|
|
2405
2138
|
}
|
|
2406
|
-
|
|
2407
2139
|
var monitoringGroupId = customerGroups.monitoring.id;
|
|
2408
2140
|
return includes(monitoringGroupId, onlineGroups) ? 'online' : 'offline';
|
|
2409
2141
|
};
|
|
2410
|
-
|
|
2411
2142
|
var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
2412
2143
|
var chatsSummary = payload.chats_summary.map(function (_ref3) {
|
|
2413
2144
|
var id = _ref3.id,
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2145
|
+
active = _ref3.active,
|
|
2146
|
+
access = _ref3.access,
|
|
2147
|
+
lastThreadCreatedAt = _ref3.last_thread_created_at,
|
|
2148
|
+
lastThreadId = _ref3.last_thread_id,
|
|
2149
|
+
lastEventsPerType = _ref3.last_event_per_type,
|
|
2150
|
+
_ref3$properties = _ref3.properties,
|
|
2151
|
+
properties = _ref3$properties === void 0 ? {} : _ref3$properties,
|
|
2152
|
+
users = _ref3.users;
|
|
2422
2153
|
var chatSummary = {
|
|
2423
2154
|
id: id,
|
|
2424
2155
|
active: active,
|
|
@@ -2429,11 +2160,9 @@ var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
|
2429
2160
|
lastThreadCreatedAt: lastThreadCreatedAt || null,
|
|
2430
2161
|
eventsSeenUpToMap: getEventsSeenUpToMap(users)
|
|
2431
2162
|
};
|
|
2432
|
-
|
|
2433
2163
|
if (!lastEventsPerType) {
|
|
2434
2164
|
return chatSummary;
|
|
2435
2165
|
}
|
|
2436
|
-
|
|
2437
2166
|
chatSummary.lastEventsPerType = mapValues(function (lastEventPerType) {
|
|
2438
2167
|
return parseEvent$1(lastEventPerType.thread_id, lastEventPerType.event);
|
|
2439
2168
|
}, lastEventsPerType);
|
|
@@ -2444,18 +2173,17 @@ var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
|
2444
2173
|
var lastEventSummary = last(lastEventSummariesArray.sort(function (eventSummaryA, eventSummaryB) {
|
|
2445
2174
|
return eventSummaryA.thread_id === eventSummaryB.thread_id ? stringCompare(eventSummaryA.event.created_at, eventSummaryB.event.created_at) : stringCompare(eventSummaryA.thread_created_at, eventSummaryB.thread_created_at);
|
|
2446
2175
|
}));
|
|
2447
|
-
|
|
2448
|
-
if (lastEventSummary) {
|
|
2176
|
+
if (lastEventSummary && chatSummary.lastEventsPerType) {
|
|
2449
2177
|
chatSummary.lastEvent = chatSummary.lastEventsPerType[lastEventSummary.event.type];
|
|
2450
2178
|
}
|
|
2451
|
-
|
|
2452
2179
|
return chatSummary;
|
|
2453
2180
|
});
|
|
2454
2181
|
return {
|
|
2455
2182
|
chatsSummary: numericSortBy(function (_ref4) {
|
|
2183
|
+
var _ref5;
|
|
2456
2184
|
var lastEvent = _ref4.lastEvent,
|
|
2457
|
-
|
|
2458
|
-
return -1 * (lastEvent !== undefined ? lastEvent.timestamp : order);
|
|
2185
|
+
order = _ref4.order;
|
|
2186
|
+
return -1 * ((_ref5 = lastEvent !== undefined ? lastEvent.timestamp : order) != null ? _ref5 : 0);
|
|
2459
2187
|
}, chatsSummary),
|
|
2460
2188
|
totalChats: payload.total_chats,
|
|
2461
2189
|
users: uniqBy(function (user) {
|
|
@@ -2467,11 +2195,9 @@ var parseListChatsResponse = function parseListChatsResponse(payload) {
|
|
|
2467
2195
|
nextPageId: payload.next_page_id || null
|
|
2468
2196
|
};
|
|
2469
2197
|
};
|
|
2470
|
-
|
|
2471
2198
|
var parseListGroupStatusesResponse = function parseListGroupStatusesResponse(payload) {
|
|
2472
2199
|
return payload.groups_status;
|
|
2473
2200
|
};
|
|
2474
|
-
|
|
2475
2201
|
var parseListThreadsResponse = function parseListThreadsResponse(request, payload) {
|
|
2476
2202
|
return {
|
|
2477
2203
|
threads: payload.threads.map(function (thread) {
|
|
@@ -2481,11 +2207,10 @@ var parseListThreadsResponse = function parseListThreadsResponse(request, payloa
|
|
|
2481
2207
|
nextPageId: payload.next_page_id || null
|
|
2482
2208
|
};
|
|
2483
2209
|
};
|
|
2484
|
-
|
|
2485
2210
|
var parseLoginResponse = function parseLoginResponse(payload) {
|
|
2486
2211
|
var dynamicConfig = payload.__priv_dynamic_config,
|
|
2487
|
-
|
|
2488
|
-
|
|
2212
|
+
chats = payload.chats,
|
|
2213
|
+
greeting = payload.greeting;
|
|
2489
2214
|
return _extends({
|
|
2490
2215
|
dynamicConfig: dynamicConfig,
|
|
2491
2216
|
customer: parseCustomer(payload.customer),
|
|
@@ -2493,7 +2218,8 @@ var parseLoginResponse = function parseLoginResponse(payload) {
|
|
|
2493
2218
|
chats: chats.map(function (chat) {
|
|
2494
2219
|
return {
|
|
2495
2220
|
id: chat.chat_id,
|
|
2496
|
-
active: 'has_active_thread' in chat ? chat.has_active_thread :
|
|
2221
|
+
active: 'has_active_thread' in chat ? chat.has_active_thread :
|
|
2222
|
+
// temporary fallback, waiting for API to move this flag into `chats` array
|
|
2497
2223
|
payload.has_active_thread,
|
|
2498
2224
|
hasUnreadEvents: chat.has_unread_events
|
|
2499
2225
|
};
|
|
@@ -2502,7 +2228,6 @@ var parseLoginResponse = function parseLoginResponse(payload) {
|
|
|
2502
2228
|
greeting: parseGreeting(greeting)
|
|
2503
2229
|
});
|
|
2504
2230
|
};
|
|
2505
|
-
|
|
2506
2231
|
var parsePush = function parsePush(push) {
|
|
2507
2232
|
switch (push.action) {
|
|
2508
2233
|
case CHAT_DEACTIVATED:
|
|
@@ -2512,146 +2237,122 @@ var parsePush = function parsePush(push) {
|
|
|
2512
2237
|
chatId: push.payload.chat_id
|
|
2513
2238
|
}
|
|
2514
2239
|
};
|
|
2515
|
-
|
|
2516
2240
|
case CHAT_PROPERTIES_DELETED:
|
|
2517
2241
|
return {
|
|
2518
2242
|
action: push.action,
|
|
2519
2243
|
payload: parseChatPropertiesDeletedPush(push.payload)
|
|
2520
2244
|
};
|
|
2521
|
-
|
|
2522
2245
|
case CHAT_PROPERTIES_UPDATED:
|
|
2523
2246
|
return {
|
|
2524
2247
|
action: push.action,
|
|
2525
2248
|
payload: parseChatPropertiesUpdatedPush(push.payload)
|
|
2526
2249
|
};
|
|
2527
|
-
|
|
2528
2250
|
case CHAT_TRANSFERRED:
|
|
2529
2251
|
return {
|
|
2530
2252
|
action: push.action,
|
|
2531
2253
|
payload: parseChatTransferredPush(push.payload)
|
|
2532
2254
|
};
|
|
2533
|
-
|
|
2534
2255
|
case CUSTOMER_SIDE_STORAGE_UPDATED:
|
|
2535
2256
|
return {
|
|
2536
2257
|
action: push.action,
|
|
2537
2258
|
payload: push.payload
|
|
2538
2259
|
};
|
|
2539
|
-
|
|
2540
2260
|
case CUSTOMER_DISCONNECTED:
|
|
2541
2261
|
return {
|
|
2542
2262
|
action: push.action,
|
|
2543
2263
|
payload: push.payload
|
|
2544
2264
|
};
|
|
2545
|
-
|
|
2546
2265
|
case CUSTOMER_PAGE_UPDATED:
|
|
2547
2266
|
return {
|
|
2548
2267
|
action: push.action,
|
|
2549
2268
|
payload: parseCustomerPageUpdatedPush(push.payload)
|
|
2550
2269
|
};
|
|
2551
|
-
|
|
2552
2270
|
case CUSTOMER_UPDATED:
|
|
2553
2271
|
return {
|
|
2554
2272
|
action: push.action,
|
|
2555
2273
|
payload: parseCustomerUpdatedPush(push.payload)
|
|
2556
2274
|
};
|
|
2557
|
-
|
|
2558
2275
|
case EVENT_PROPERTIES_DELETED:
|
|
2559
2276
|
return {
|
|
2560
2277
|
action: push.action,
|
|
2561
2278
|
payload: parseEventPropertiesDeletedPush(push.payload)
|
|
2562
2279
|
};
|
|
2563
|
-
|
|
2564
2280
|
case EVENT_PROPERTIES_UPDATED:
|
|
2565
2281
|
return {
|
|
2566
2282
|
action: push.action,
|
|
2567
2283
|
payload: parseEventPropertiesUpdatedPush(push.payload)
|
|
2568
2284
|
};
|
|
2569
|
-
|
|
2570
2285
|
case EVENT_UPDATED:
|
|
2571
2286
|
return {
|
|
2572
2287
|
action: push.action,
|
|
2573
2288
|
payload: parseEventUpdatedPush(push.payload)
|
|
2574
2289
|
};
|
|
2575
|
-
|
|
2576
2290
|
case EVENTS_MARKED_AS_SEEN:
|
|
2577
2291
|
return {
|
|
2578
2292
|
action: push.action,
|
|
2579
2293
|
payload: parseEventsMarkedAsSeenPush(push.payload)
|
|
2580
2294
|
};
|
|
2581
|
-
|
|
2582
2295
|
case GREETING_ACCEPTED:
|
|
2583
2296
|
return {
|
|
2584
2297
|
action: push.action,
|
|
2585
2298
|
payload: parseGreetingAcceptedPush(push.payload)
|
|
2586
2299
|
};
|
|
2587
|
-
|
|
2588
2300
|
case GREETING_CANCELED:
|
|
2589
2301
|
return {
|
|
2590
2302
|
action: push.action,
|
|
2591
2303
|
// 'greeting_canceled' has the same payload as `greeting_accepted`
|
|
2592
2304
|
payload: parseGreetingAcceptedPush(push.payload)
|
|
2593
2305
|
};
|
|
2594
|
-
|
|
2595
2306
|
case INCOMING_CHAT:
|
|
2596
2307
|
return {
|
|
2597
2308
|
action: push.action,
|
|
2598
2309
|
payload: parseIncomingChatPush(push.payload)
|
|
2599
2310
|
};
|
|
2600
|
-
|
|
2601
2311
|
case INCOMING_EVENT:
|
|
2602
2312
|
return {
|
|
2603
2313
|
action: push.action,
|
|
2604
2314
|
payload: parseIncomingEventPush(push.payload)
|
|
2605
2315
|
};
|
|
2606
|
-
|
|
2607
2316
|
case INCOMING_GREETING:
|
|
2608
2317
|
return {
|
|
2609
2318
|
action: push.action,
|
|
2610
2319
|
payload: parseIncomingGreetingPush(push.payload)
|
|
2611
2320
|
};
|
|
2612
|
-
|
|
2613
2321
|
case INCOMING_MULTICAST:
|
|
2614
2322
|
return {
|
|
2615
2323
|
action: push.action,
|
|
2616
2324
|
payload: push.payload
|
|
2617
2325
|
};
|
|
2618
|
-
|
|
2619
2326
|
case INCOMING_RICH_MESSAGE_POSTBACK:
|
|
2620
2327
|
return {
|
|
2621
2328
|
action: push.action,
|
|
2622
2329
|
payload: parseIncomingRichMessagePostbackPush(push.payload)
|
|
2623
2330
|
};
|
|
2624
|
-
|
|
2625
2331
|
case INCOMING_TYPING_INDICATOR:
|
|
2626
2332
|
return {
|
|
2627
2333
|
action: push.action,
|
|
2628
2334
|
payload: parseIncomingTypingIndicatorPush(push.payload)
|
|
2629
2335
|
};
|
|
2630
|
-
|
|
2631
2336
|
case QUEUE_POSITION_UPDATED:
|
|
2632
2337
|
return {
|
|
2633
2338
|
action: push.action,
|
|
2634
2339
|
payload: parseQueuePositionUpdatedPush(push.payload)
|
|
2635
2340
|
};
|
|
2636
|
-
|
|
2637
2341
|
case THREAD_PROPERTIES_DELETED:
|
|
2638
2342
|
return {
|
|
2639
2343
|
action: push.action,
|
|
2640
2344
|
payload: parseThreadPropertiesDeletedPush(push.payload)
|
|
2641
2345
|
};
|
|
2642
|
-
|
|
2643
2346
|
case THREAD_PROPERTIES_UPDATED:
|
|
2644
2347
|
return {
|
|
2645
2348
|
action: push.action,
|
|
2646
2349
|
payload: parseThreadPropertiesUpdatedPush(push.payload)
|
|
2647
2350
|
};
|
|
2648
|
-
|
|
2649
2351
|
case USER_ADDED_TO_CHAT:
|
|
2650
2352
|
return {
|
|
2651
2353
|
action: push.action,
|
|
2652
2354
|
payload: parseUserAddedToChatPush(push.payload)
|
|
2653
2355
|
};
|
|
2654
|
-
|
|
2655
2356
|
case USER_REMOVED_FROM_CHAT:
|
|
2656
2357
|
return {
|
|
2657
2358
|
action: push.action,
|
|
@@ -2659,143 +2360,120 @@ var parsePush = function parsePush(push) {
|
|
|
2659
2360
|
};
|
|
2660
2361
|
}
|
|
2661
2362
|
};
|
|
2662
|
-
var parseResponse = function parseResponse(
|
|
2663
|
-
var request =
|
|
2664
|
-
|
|
2665
|
-
|
|
2363
|
+
var parseResponse = function parseResponse(_ref6) {
|
|
2364
|
+
var request = _ref6.request,
|
|
2365
|
+
response = _ref6.response;
|
|
2666
2366
|
switch (response.action) {
|
|
2667
2367
|
case ACCEPT_GREETING:
|
|
2668
2368
|
return {
|
|
2669
2369
|
action: response.action,
|
|
2670
2370
|
payload: SUCCESS
|
|
2671
2371
|
};
|
|
2672
|
-
|
|
2673
2372
|
case CANCEL_GREETING:
|
|
2674
2373
|
return {
|
|
2675
2374
|
action: response.action,
|
|
2676
2375
|
payload: SUCCESS
|
|
2677
2376
|
};
|
|
2678
|
-
|
|
2679
2377
|
case DELETE_CHAT_PROPERTIES:
|
|
2680
2378
|
return {
|
|
2681
2379
|
action: response.action,
|
|
2682
2380
|
payload: SUCCESS
|
|
2683
2381
|
};
|
|
2684
|
-
|
|
2685
2382
|
case DELETE_EVENT_PROPERTIES:
|
|
2686
2383
|
return {
|
|
2687
2384
|
action: response.action,
|
|
2688
2385
|
payload: SUCCESS
|
|
2689
2386
|
};
|
|
2690
|
-
|
|
2691
2387
|
case DELETE_THREAD_PROPERTIES:
|
|
2692
2388
|
return {
|
|
2693
2389
|
action: response.action,
|
|
2694
2390
|
payload: SUCCESS
|
|
2695
2391
|
};
|
|
2696
|
-
|
|
2697
2392
|
case GET_CHAT:
|
|
2698
2393
|
return {
|
|
2699
2394
|
action: response.action,
|
|
2700
2395
|
payload: parseGetChatResponse(response.payload)
|
|
2701
2396
|
};
|
|
2702
|
-
|
|
2703
2397
|
case GET_CUSTOMER:
|
|
2704
2398
|
return {
|
|
2705
2399
|
action: response.action,
|
|
2706
2400
|
payload: parseCustomer(response.payload)
|
|
2707
2401
|
};
|
|
2708
|
-
|
|
2709
2402
|
case GET_FORM:
|
|
2710
2403
|
return {
|
|
2711
2404
|
action: response.action,
|
|
2712
2405
|
payload: parseGetFormResponse(response.payload)
|
|
2713
2406
|
};
|
|
2714
|
-
|
|
2715
2407
|
case GET_PREDICTED_AGENT:
|
|
2716
2408
|
return {
|
|
2717
2409
|
action: response.action,
|
|
2718
2410
|
payload: parsePredictedAgent(response.payload)
|
|
2719
2411
|
};
|
|
2720
|
-
|
|
2721
2412
|
case GET_URL_INFO:
|
|
2722
2413
|
return {
|
|
2723
2414
|
action: response.action,
|
|
2724
2415
|
payload: parseGetUrlInfoResponse(response.payload)
|
|
2725
2416
|
};
|
|
2726
|
-
|
|
2727
2417
|
case LIST_CHATS:
|
|
2728
2418
|
return {
|
|
2729
2419
|
action: response.action,
|
|
2730
2420
|
payload: parseListChatsResponse(response.payload)
|
|
2731
2421
|
};
|
|
2732
|
-
|
|
2733
2422
|
case LIST_GROUP_STATUSES:
|
|
2734
2423
|
return {
|
|
2735
2424
|
action: response.action,
|
|
2736
2425
|
payload: parseListGroupStatusesResponse(response.payload)
|
|
2737
2426
|
};
|
|
2738
|
-
|
|
2739
2427
|
case LIST_THREADS:
|
|
2740
2428
|
return {
|
|
2741
2429
|
action: response.action,
|
|
2742
2430
|
payload: parseListThreadsResponse(request, response.payload)
|
|
2743
2431
|
};
|
|
2744
|
-
|
|
2745
2432
|
case LOGIN:
|
|
2746
2433
|
return {
|
|
2747
2434
|
action: response.action,
|
|
2748
2435
|
payload: parseLoginResponse(response.payload)
|
|
2749
2436
|
};
|
|
2750
|
-
|
|
2751
2437
|
case MARK_EVENTS_AS_SEEN:
|
|
2752
2438
|
return {
|
|
2753
2439
|
action: response.action,
|
|
2754
2440
|
payload: SUCCESS
|
|
2755
2441
|
};
|
|
2756
|
-
|
|
2757
2442
|
case SEND_SNEAK_PEEK:
|
|
2758
2443
|
return {
|
|
2759
2444
|
action: response.action,
|
|
2760
2445
|
payload: SUCCESS
|
|
2761
2446
|
};
|
|
2762
|
-
|
|
2763
2447
|
case SET_CUSTOMER_SESSION_FIELDS:
|
|
2764
2448
|
return {
|
|
2765
2449
|
action: response.action,
|
|
2766
2450
|
payload: SUCCESS
|
|
2767
2451
|
};
|
|
2768
|
-
|
|
2769
2452
|
case SEND_RICH_MESSAGE_POSTBACK:
|
|
2770
2453
|
return {
|
|
2771
2454
|
action: response.action,
|
|
2772
2455
|
payload: SUCCESS
|
|
2773
2456
|
};
|
|
2774
|
-
|
|
2775
2457
|
case UPDATE_CHAT_PROPERTIES:
|
|
2776
2458
|
return {
|
|
2777
2459
|
action: response.action,
|
|
2778
2460
|
payload: SUCCESS
|
|
2779
2461
|
};
|
|
2780
|
-
|
|
2781
2462
|
case UPDATE_CUSTOMER:
|
|
2782
2463
|
return {
|
|
2783
2464
|
action: response.action,
|
|
2784
2465
|
payload: SUCCESS
|
|
2785
2466
|
};
|
|
2786
|
-
|
|
2787
2467
|
case UPDATE_CUSTOMER_PAGE$1:
|
|
2788
2468
|
return {
|
|
2789
2469
|
action: response.action,
|
|
2790
2470
|
payload: SUCCESS
|
|
2791
2471
|
};
|
|
2792
|
-
|
|
2793
2472
|
case UPDATE_EVENT_PROPERTIES:
|
|
2794
2473
|
return {
|
|
2795
2474
|
action: response.action,
|
|
2796
2475
|
payload: SUCCESS
|
|
2797
2476
|
};
|
|
2798
|
-
|
|
2799
2477
|
case UPDATE_THREAD_PROPERTIES:
|
|
2800
2478
|
return {
|
|
2801
2479
|
action: response.action,
|
|
@@ -2812,13 +2490,11 @@ var parseServerError = function parseServerError(error) {
|
|
|
2812
2490
|
|
|
2813
2491
|
var handleResponseError = function handleResponseError(_ref, response) {
|
|
2814
2492
|
var dispatch = _ref.dispatch,
|
|
2815
|
-
|
|
2493
|
+
getState = _ref.getState;
|
|
2816
2494
|
var requestId = response.request_id,
|
|
2817
|
-
|
|
2818
|
-
|
|
2495
|
+
payload = response.payload;
|
|
2819
2496
|
var _getRequest = getRequest(getState(), requestId),
|
|
2820
|
-
|
|
2821
|
-
|
|
2497
|
+
reject = _getRequest.reject;
|
|
2822
2498
|
dispatch({
|
|
2823
2499
|
type: REQUEST_FAILED,
|
|
2824
2500
|
payload: {
|
|
@@ -2828,17 +2504,14 @@ var handleResponseError = function handleResponseError(_ref, response) {
|
|
|
2828
2504
|
}
|
|
2829
2505
|
});
|
|
2830
2506
|
};
|
|
2831
|
-
|
|
2832
2507
|
var handleResponse$1 = function handleResponse(_ref2, response) {
|
|
2833
2508
|
var dispatch = _ref2.dispatch,
|
|
2834
|
-
|
|
2509
|
+
getState = _ref2.getState;
|
|
2835
2510
|
var requestId = response.request_id;
|
|
2836
|
-
|
|
2837
2511
|
var _getRequest2 = getRequest(getState(), requestId),
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2512
|
+
promise = _getRequest2.promise,
|
|
2513
|
+
resolve = _getRequest2.resolve,
|
|
2514
|
+
request = _getRequest2.request;
|
|
2842
2515
|
var parsedResponse = parseResponse({
|
|
2843
2516
|
request: request,
|
|
2844
2517
|
response: response
|
|
@@ -2852,16 +2525,13 @@ var handleResponse$1 = function handleResponse(_ref2, response) {
|
|
|
2852
2525
|
}, parsedResponse)
|
|
2853
2526
|
});
|
|
2854
2527
|
};
|
|
2855
|
-
|
|
2856
2528
|
var handlePushResponse = function handlePushResponse(_ref3, response) {
|
|
2857
2529
|
var dispatch = _ref3.dispatch,
|
|
2858
|
-
|
|
2530
|
+
getState = _ref3.getState;
|
|
2859
2531
|
var requestId = response.request_id;
|
|
2860
|
-
|
|
2861
2532
|
var _getRequest3 = getRequest(getState(), requestId),
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2533
|
+
promise = _getRequest3.promise,
|
|
2534
|
+
resolve = _getRequest3.resolve;
|
|
2865
2535
|
var parsedPush = parsePush(response);
|
|
2866
2536
|
dispatch({
|
|
2867
2537
|
type: PUSH_RESPONSE_RECEIVED,
|
|
@@ -2872,21 +2542,17 @@ var handlePushResponse = function handlePushResponse(_ref3, response) {
|
|
|
2872
2542
|
}, parsedPush)
|
|
2873
2543
|
});
|
|
2874
2544
|
};
|
|
2875
|
-
|
|
2876
2545
|
var handlePush$1 = function handlePush(store, push) {
|
|
2877
2546
|
var parsedPush = parsePush(push);
|
|
2878
|
-
|
|
2879
2547
|
if (!parsedPush) {
|
|
2880
2548
|
// defensive measure against receiving unknown push
|
|
2881
2549
|
return;
|
|
2882
2550
|
}
|
|
2883
|
-
|
|
2884
2551
|
store.dispatch({
|
|
2885
2552
|
type: PUSH_RECEIVED,
|
|
2886
2553
|
payload: parsedPush
|
|
2887
2554
|
});
|
|
2888
2555
|
};
|
|
2889
|
-
|
|
2890
2556
|
var socketListener = (function (store, socket) {
|
|
2891
2557
|
var dispatch = store.dispatch;
|
|
2892
2558
|
socket.on('connect', function () {
|
|
@@ -2900,20 +2566,17 @@ var socketListener = (function (store, socket) {
|
|
|
2900
2566
|
handleResponseError(store, message);
|
|
2901
2567
|
return;
|
|
2902
2568
|
}
|
|
2903
|
-
|
|
2904
2569
|
switch (message.action) {
|
|
2905
2570
|
case RESUME_CHAT:
|
|
2906
2571
|
case SEND_EVENT:
|
|
2907
2572
|
case START_CHAT:
|
|
2908
2573
|
// those are requests with indirect responses
|
|
2909
2574
|
return;
|
|
2910
|
-
|
|
2911
2575
|
default:
|
|
2912
2576
|
handleResponse$1(store, message);
|
|
2913
2577
|
return;
|
|
2914
2578
|
}
|
|
2915
2579
|
}
|
|
2916
|
-
|
|
2917
2580
|
if ('request_id' in message) {
|
|
2918
2581
|
switch (message.action) {
|
|
2919
2582
|
case INCOMING_CHAT:
|
|
@@ -2923,12 +2586,10 @@ var socketListener = (function (store, socket) {
|
|
|
2923
2586
|
return;
|
|
2924
2587
|
}
|
|
2925
2588
|
}
|
|
2926
|
-
|
|
2927
2589
|
handlePush$1(store, message);
|
|
2928
2590
|
});
|
|
2929
2591
|
socket.on('disconnect', function () {
|
|
2930
2592
|
failAllRequests(store, CONNECTION_LOST);
|
|
2931
|
-
|
|
2932
2593
|
if (getConnectionStatus(store.getState()) === CONNECTED) {
|
|
2933
2594
|
store.dispatch(socketDisconnected());
|
|
2934
2595
|
}
|
|
@@ -2947,20 +2608,18 @@ var socketListener = (function (store, socket) {
|
|
|
2947
2608
|
});
|
|
2948
2609
|
|
|
2949
2610
|
var INCORRECT_REQUESTER_STRUCTURE = 'incorrect requester structure';
|
|
2950
|
-
|
|
2951
2611
|
var appendString = function appendString(input, str) {
|
|
2952
2612
|
return input.length ? input + "\n" + str : str;
|
|
2953
2613
|
};
|
|
2954
|
-
|
|
2955
2614
|
var createTicketBody = function createTicketBody(state, _ref) {
|
|
2956
2615
|
var fields = _ref.fields,
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2616
|
+
customerId = _ref.customerId,
|
|
2617
|
+
_ref$groupId = _ref.groupId,
|
|
2618
|
+
groupId = _ref$groupId === void 0 ? state.groupId : _ref$groupId,
|
|
2619
|
+
licenseId = _ref.licenseId,
|
|
2620
|
+
timeZone = _ref.timeZone;
|
|
2962
2621
|
var ticketBody = _extends({
|
|
2963
|
-
licence_id:
|
|
2622
|
+
licence_id: licenseId,
|
|
2964
2623
|
ticket_message: '',
|
|
2965
2624
|
offline_message: '',
|
|
2966
2625
|
visitor_id: customerId,
|
|
@@ -2974,106 +2633,85 @@ var createTicketBody = function createTicketBody(state, _ref) {
|
|
|
2974
2633
|
}, timeZone && {
|
|
2975
2634
|
timezone: timeZone
|
|
2976
2635
|
});
|
|
2977
|
-
|
|
2978
2636
|
return fields.reduce(function (body, field) {
|
|
2979
2637
|
switch (field.type) {
|
|
2980
2638
|
case 'subject':
|
|
2981
2639
|
{
|
|
2982
2640
|
var value = field.answer;
|
|
2983
2641
|
var text = value ? field.label + " " + value : field.label;
|
|
2984
|
-
|
|
2985
2642
|
if (value) {
|
|
2986
2643
|
body.subject = value;
|
|
2987
2644
|
}
|
|
2988
|
-
|
|
2989
2645
|
body.offline_message = appendString(body.offline_message, text);
|
|
2990
2646
|
return body;
|
|
2991
2647
|
}
|
|
2992
|
-
|
|
2993
2648
|
case 'name':
|
|
2994
2649
|
{
|
|
2995
2650
|
var _value = field.answer;
|
|
2996
|
-
|
|
2997
2651
|
var _text = _value ? field.label + " " + _value : field.label;
|
|
2998
|
-
|
|
2999
2652
|
if (_value) {
|
|
3000
2653
|
body.requester.name = _value;
|
|
3001
2654
|
}
|
|
3002
|
-
|
|
3003
2655
|
body.offline_message = appendString(body.offline_message, _text);
|
|
3004
2656
|
return body;
|
|
3005
2657
|
}
|
|
3006
|
-
|
|
3007
2658
|
case 'email':
|
|
3008
2659
|
{
|
|
3009
2660
|
var _value2 = field.answer;
|
|
3010
|
-
|
|
3011
2661
|
var _text2 = _value2 ? field.label + " " + _value2 : field.label;
|
|
3012
|
-
|
|
3013
2662
|
body.requester.mail = _value2;
|
|
3014
2663
|
body.offline_message = appendString(body.offline_message, _text2);
|
|
3015
2664
|
return body;
|
|
3016
2665
|
}
|
|
3017
|
-
|
|
3018
2666
|
case 'question':
|
|
3019
2667
|
case 'textarea':
|
|
3020
2668
|
{
|
|
3021
2669
|
var _value3 = field.answer;
|
|
3022
|
-
|
|
3023
2670
|
var _text3 = _value3 ? field.label + " " + _value3 : field.label;
|
|
3024
|
-
|
|
3025
2671
|
body.offline_message = appendString(body.offline_message, _text3);
|
|
3026
2672
|
body.ticket_message = appendString(body.ticket_message, _text3);
|
|
3027
2673
|
return body;
|
|
3028
2674
|
}
|
|
3029
|
-
|
|
3030
2675
|
case 'radio':
|
|
3031
2676
|
case 'select':
|
|
3032
2677
|
{
|
|
3033
2678
|
var _value4 = field.answer && field.answer.label;
|
|
3034
|
-
|
|
3035
2679
|
var _text4 = _value4 ? field.label + " " + _value4 : field.label;
|
|
3036
|
-
|
|
3037
2680
|
body.offline_message = appendString(body.offline_message, _text4);
|
|
3038
2681
|
body.ticket_message = appendString(body.ticket_message, _text4);
|
|
3039
2682
|
return body;
|
|
3040
2683
|
}
|
|
3041
|
-
|
|
3042
2684
|
case 'checkbox':
|
|
3043
2685
|
{
|
|
3044
2686
|
var _value5 = field.answers && field.answers.map(function (answer) {
|
|
3045
2687
|
return answer.label;
|
|
3046
2688
|
}).join(', ');
|
|
3047
|
-
|
|
3048
2689
|
var _text5 = _value5 ? field.label + " " + _value5 : field.label;
|
|
3049
|
-
|
|
3050
2690
|
body.offline_message = appendString(body.offline_message, _text5);
|
|
3051
2691
|
body.ticket_message = appendString(body.ticket_message, _text5);
|
|
3052
2692
|
return body;
|
|
3053
2693
|
}
|
|
3054
|
-
|
|
3055
2694
|
default:
|
|
3056
2695
|
return body;
|
|
3057
2696
|
}
|
|
3058
2697
|
}, ticketBody);
|
|
3059
2698
|
};
|
|
3060
|
-
|
|
3061
2699
|
var sendTicketForm = function sendTicketForm(store, auth, _ref2) {
|
|
3062
2700
|
var filledForm = _ref2.filledForm,
|
|
3063
|
-
|
|
3064
|
-
|
|
2701
|
+
groupId = _ref2.groupId,
|
|
2702
|
+
licenseId = _ref2.licenseId,
|
|
2703
|
+
timeZone = _ref2.timeZone;
|
|
3065
2704
|
return auth.getToken().then(function (token) {
|
|
3066
2705
|
var state = store.getState();
|
|
3067
|
-
|
|
3068
2706
|
if (getSelfId(state) === null) {
|
|
3069
2707
|
store.dispatch(setSelfId(token.entityId));
|
|
3070
2708
|
}
|
|
3071
|
-
|
|
3072
2709
|
var url = getApiOrigin(state) + "/v2/tickets/new";
|
|
3073
2710
|
var body = createTicketBody(state, {
|
|
3074
2711
|
fields: filledForm.fields,
|
|
3075
2712
|
customerId: token.entityId,
|
|
3076
2713
|
groupId: groupId,
|
|
2714
|
+
licenseId: licenseId,
|
|
3077
2715
|
timeZone: timeZone
|
|
3078
2716
|
});
|
|
3079
2717
|
return unfetch(url, {
|
|
@@ -3089,33 +2727,28 @@ var sendTicketForm = function sendTicketForm(store, auth, _ref2) {
|
|
|
3089
2727
|
text: body.ticket_message
|
|
3090
2728
|
});
|
|
3091
2729
|
});
|
|
3092
|
-
}
|
|
3093
|
-
|
|
2730
|
+
}
|
|
3094
2731
|
|
|
2732
|
+
// we actually should normalize this somehow
|
|
3095
2733
|
if (response.status === 400 || response.status === 422) {
|
|
3096
2734
|
var errHandler = function errHandler(error) {
|
|
3097
2735
|
if (!error || !error.errors) {
|
|
3098
2736
|
// TODO: I honestly don't know if this can even be reached and even if it is - What error should be thrown here
|
|
3099
2737
|
throw new Error();
|
|
3100
|
-
}
|
|
3101
|
-
|
|
3102
|
-
|
|
2738
|
+
}
|
|
2739
|
+
// we receive some hardcore aggregate error here 😱
|
|
3103
2740
|
var firstError = error.errors[0];
|
|
3104
2741
|
var type = Object.keys(firstError)[0];
|
|
3105
|
-
|
|
3106
2742
|
if (type === INCORRECT_REQUESTER_STRUCTURE) {
|
|
3107
2743
|
throw createError({
|
|
3108
2744
|
message: firstError[INCORRECT_REQUESTER_STRUCTURE][0],
|
|
3109
2745
|
code: 'VALIDATION'
|
|
3110
2746
|
});
|
|
3111
2747
|
}
|
|
3112
|
-
|
|
3113
2748
|
throw new Error();
|
|
3114
2749
|
};
|
|
3115
|
-
|
|
3116
2750
|
return response.json().then(errHandler, errHandler);
|
|
3117
2751
|
}
|
|
3118
|
-
|
|
3119
2752
|
throw new Error();
|
|
3120
2753
|
});
|
|
3121
2754
|
});
|
|
@@ -3125,32 +2758,24 @@ var KILOBYTE = 1024;
|
|
|
3125
2758
|
var MEGABYTE = 1024 * KILOBYTE;
|
|
3126
2759
|
var GIGABYTE = 1024 * MEGABYTE;
|
|
3127
2760
|
var SIZE_LIMIT = 10 * MEGABYTE;
|
|
3128
|
-
|
|
3129
2761
|
var formatBytes = function formatBytes(bytes, precision) {
|
|
3130
2762
|
if (precision === void 0) {
|
|
3131
2763
|
precision = 2;
|
|
3132
2764
|
}
|
|
3133
|
-
|
|
3134
2765
|
if (bytes < KILOBYTE) {
|
|
3135
2766
|
return bytes + " b";
|
|
3136
2767
|
}
|
|
3137
|
-
|
|
3138
2768
|
var kilobytes = bytes / 1024;
|
|
3139
|
-
|
|
3140
2769
|
if (bytes < MEGABYTE) {
|
|
3141
2770
|
return kilobytes.toFixed(precision) + " kb";
|
|
3142
2771
|
}
|
|
3143
|
-
|
|
3144
2772
|
var megabytes = kilobytes / 1024;
|
|
3145
|
-
|
|
3146
2773
|
if (bytes < GIGABYTE) {
|
|
3147
2774
|
return megabytes.toFixed(precision) + " MB";
|
|
3148
2775
|
}
|
|
3149
|
-
|
|
3150
2776
|
var gigabytes = megabytes / 1024;
|
|
3151
2777
|
return gigabytes.toFixed(precision) + " GB";
|
|
3152
2778
|
};
|
|
3153
|
-
|
|
3154
2779
|
var validateFile = function validateFile(file) {
|
|
3155
2780
|
if (file.size > SIZE_LIMIT) {
|
|
3156
2781
|
throw createError({
|
|
@@ -3162,16 +2787,16 @@ var validateFile = function validateFile(file) {
|
|
|
3162
2787
|
|
|
3163
2788
|
var uploadFile = function uploadFile(_ref, _ref2) {
|
|
3164
2789
|
var auth = _ref.auth,
|
|
3165
|
-
|
|
2790
|
+
store = _ref.store;
|
|
3166
2791
|
var file = _ref2.file,
|
|
3167
|
-
|
|
2792
|
+
onProgress = _ref2.onProgress;
|
|
3168
2793
|
var upload;
|
|
3169
2794
|
var cancelled = false;
|
|
3170
2795
|
var send = new Promise(function (resolve, reject) {
|
|
3171
2796
|
validateFile(file);
|
|
3172
2797
|
var state = store.getState();
|
|
3173
2798
|
var query = buildQueryString({
|
|
3174
|
-
|
|
2799
|
+
organization_id: state.organizationId
|
|
3175
2800
|
});
|
|
3176
2801
|
var url = getServerUrl(state) + "/action/" + UPLOAD_FILE + "?" + query;
|
|
3177
2802
|
var payload = {
|
|
@@ -3182,7 +2807,6 @@ var uploadFile = function uploadFile(_ref, _ref2) {
|
|
|
3182
2807
|
reject(new Error('Upload cancelled.'));
|
|
3183
2808
|
return;
|
|
3184
2809
|
}
|
|
3185
|
-
|
|
3186
2810
|
upload = rawUploadFile(url, payload, {
|
|
3187
2811
|
headers: {
|
|
3188
2812
|
Authorization: token.tokenType + " " + token.accessToken
|
|
@@ -3195,10 +2819,9 @@ var uploadFile = function uploadFile(_ref, _ref2) {
|
|
|
3195
2819
|
reject(uploadError);
|
|
3196
2820
|
return;
|
|
3197
2821
|
}
|
|
3198
|
-
|
|
3199
2822
|
var _uploadError$response = uploadError.response.error,
|
|
3200
|
-
|
|
3201
|
-
|
|
2823
|
+
type = _uploadError$response.type,
|
|
2824
|
+
message = _uploadError$response.message;
|
|
3202
2825
|
reject(createError({
|
|
3203
2826
|
message: message,
|
|
3204
2827
|
code: type.toUpperCase()
|
|
@@ -3212,9 +2835,7 @@ var uploadFile = function uploadFile(_ref, _ref2) {
|
|
|
3212
2835
|
if (cancelled) {
|
|
3213
2836
|
return;
|
|
3214
2837
|
}
|
|
3215
|
-
|
|
3216
2838
|
cancelled = true;
|
|
3217
|
-
|
|
3218
2839
|
if (upload) {
|
|
3219
2840
|
upload.cancel();
|
|
3220
2841
|
}
|
|
@@ -3227,7 +2848,6 @@ var makeGraylogRequest = function makeGraylogRequest(url, body) {
|
|
|
3227
2848
|
var img = new Image();
|
|
3228
2849
|
img.src = url + "?" + body;
|
|
3229
2850
|
img.onerror = noop;
|
|
3230
|
-
|
|
3231
2851
|
img.onload = function () {
|
|
3232
2852
|
return resolve();
|
|
3233
2853
|
};
|
|
@@ -3242,20 +2862,18 @@ var makeGraylogRequest = function makeGraylogRequest(url, body) {
|
|
|
3242
2862
|
*/
|
|
3243
2863
|
var log = function log(_ref) {
|
|
3244
2864
|
var env = _ref.env,
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
2865
|
+
organizationId = _ref.organizationId,
|
|
2866
|
+
eventName = _ref.eventName;
|
|
3248
2867
|
if (env !== 'production' || "customer_sdk" !== 'customer_sdk') {
|
|
3249
2868
|
return Promise.resolve();
|
|
3250
2869
|
}
|
|
3251
|
-
|
|
3252
2870
|
var message = {
|
|
3253
2871
|
event_name: eventName,
|
|
3254
2872
|
severity: 'Informational',
|
|
3255
|
-
sdkVersion: "3.1.
|
|
2873
|
+
sdkVersion: "3.1.3"
|
|
3256
2874
|
};
|
|
3257
2875
|
var body = {
|
|
3258
|
-
|
|
2876
|
+
organizationId: organizationId,
|
|
3259
2877
|
event_id: 'chat_widget_customer_sdk',
|
|
3260
2878
|
message: JSON.stringify(message)
|
|
3261
2879
|
};
|
|
@@ -3264,26 +2882,20 @@ var log = function log(_ref) {
|
|
|
3264
2882
|
|
|
3265
2883
|
var LISTENER_IDENTITY = 'LISTENER_IDENTITY';
|
|
3266
2884
|
var listenersMap = {};
|
|
3267
|
-
|
|
3268
2885
|
var createDebuggedMethods = function createDebuggedMethods(methods, prefix) {
|
|
3269
2886
|
if (prefix === void 0) {
|
|
3270
2887
|
prefix = '';
|
|
3271
2888
|
}
|
|
3272
|
-
|
|
3273
2889
|
var methodNames = Object.keys(methods);
|
|
3274
2890
|
return methodNames.map(function (methodName) {
|
|
3275
2891
|
var method = methods[methodName];
|
|
3276
2892
|
return function () {
|
|
3277
2893
|
var _console;
|
|
3278
|
-
|
|
3279
2894
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3280
2895
|
args[_key] = arguments[_key];
|
|
3281
2896
|
}
|
|
3282
|
-
|
|
3283
2897
|
(_console = console).info.apply(_console, [prefix + "." + methodName + "() ===>"].concat(args));
|
|
3284
|
-
|
|
3285
2898
|
var result = method.apply(void 0, args);
|
|
3286
|
-
|
|
3287
2899
|
if (typeof (result == null ? void 0 : result.then) === 'function') {
|
|
3288
2900
|
return result.then(function (data) {
|
|
3289
2901
|
console.info(prefix + "." + methodName + "() <===", data);
|
|
@@ -3293,7 +2905,6 @@ var createDebuggedMethods = function createDebuggedMethods(methods, prefix) {
|
|
|
3293
2905
|
throw err;
|
|
3294
2906
|
});
|
|
3295
2907
|
}
|
|
3296
|
-
|
|
3297
2908
|
return result;
|
|
3298
2909
|
};
|
|
3299
2910
|
}).reduce(function (acc, method, index) {
|
|
@@ -3301,78 +2912,61 @@ var createDebuggedMethods = function createDebuggedMethods(methods, prefix) {
|
|
|
3301
2912
|
return acc;
|
|
3302
2913
|
}, {});
|
|
3303
2914
|
};
|
|
3304
|
-
|
|
3305
2915
|
var createEnhancedListener = function createEnhancedListener(label, event, listener) {
|
|
3306
2916
|
if (listener[LISTENER_IDENTITY] === undefined) {
|
|
3307
2917
|
Object.defineProperty(listener, LISTENER_IDENTITY, {
|
|
3308
2918
|
value: {}
|
|
3309
2919
|
});
|
|
3310
2920
|
}
|
|
3311
|
-
|
|
3312
2921
|
if (listener[LISTENER_IDENTITY][event]) {
|
|
3313
2922
|
var enhancedListenerId = listener[LISTENER_IDENTITY][event];
|
|
3314
2923
|
return listenersMap[enhancedListenerId];
|
|
3315
2924
|
}
|
|
3316
|
-
|
|
3317
2925
|
var enhancedListener = function enhancedListener(data) {
|
|
3318
2926
|
console.info("." + label + "(\"" + event + "\") <===", data);
|
|
3319
2927
|
listener(data);
|
|
3320
2928
|
};
|
|
3321
|
-
|
|
3322
2929
|
var uniqueId = generateUniqueId(listenersMap);
|
|
3323
2930
|
listener[LISTENER_IDENTITY][event] = uniqueId;
|
|
3324
2931
|
listenersMap[uniqueId] = enhancedListener;
|
|
3325
2932
|
return enhancedListener;
|
|
3326
|
-
};
|
|
3327
|
-
|
|
2933
|
+
};
|
|
3328
2934
|
|
|
2935
|
+
// TODO: this really should just accept & return CustomerSdk type
|
|
3329
2936
|
var debug = (function (_sdk) {
|
|
3330
2937
|
var sdk = _sdk;
|
|
3331
|
-
|
|
3332
2938
|
if (process.env.NODE_ENV === 'production') {
|
|
3333
2939
|
console.warn('You probably do not want to use debug(customerSDK) in your production environment.');
|
|
3334
2940
|
}
|
|
3335
|
-
|
|
3336
2941
|
var _on = sdk.on,
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
2942
|
+
_once = sdk.once,
|
|
2943
|
+
_off = sdk.off,
|
|
2944
|
+
_getChatHistory = sdk.getChatHistory,
|
|
2945
|
+
auth = sdk.auth,
|
|
2946
|
+
rest = _objectWithoutPropertiesLoose(sdk, ["on", "once", "off", "getChatHistory", "auth"]);
|
|
3343
2947
|
var methods = createDebuggedMethods(rest);
|
|
3344
2948
|
return Object.freeze(_extends({
|
|
3345
2949
|
auth: Object.freeze(createDebuggedMethods(auth, '.auth'))
|
|
3346
2950
|
}, methods, {
|
|
3347
2951
|
getChatHistory: function getChatHistory() {
|
|
3348
2952
|
var _console2;
|
|
3349
|
-
|
|
3350
2953
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
3351
2954
|
args[_key2] = arguments[_key2];
|
|
3352
2955
|
}
|
|
3353
|
-
|
|
3354
2956
|
(_console2 = console).info.apply(_console2, [".getChatHistory()"].concat(args));
|
|
3355
|
-
|
|
3356
2957
|
var history = _getChatHistory.apply(void 0, args);
|
|
3357
|
-
|
|
3358
2958
|
var logLabel = 'history.next()';
|
|
3359
2959
|
return {
|
|
3360
2960
|
next: function next() {
|
|
3361
2961
|
var _console3;
|
|
3362
|
-
|
|
3363
2962
|
(_console3 = console).info.apply(_console3, [logLabel + " ===>"].concat(args));
|
|
3364
|
-
|
|
3365
2963
|
return history.next().then(function (data) {
|
|
3366
2964
|
var _console4;
|
|
3367
|
-
|
|
3368
2965
|
(_console4 = console).info.apply(_console4, [logLabel + " <==="].concat(args, [data]));
|
|
3369
|
-
|
|
3370
2966
|
return data;
|
|
3371
2967
|
}, function (err) {
|
|
3372
2968
|
var _console5;
|
|
3373
|
-
|
|
3374
2969
|
(_console5 = console).error.apply(_console5, [logLabel + " <==="].concat(args, [err]));
|
|
3375
|
-
|
|
3376
2970
|
throw err;
|
|
3377
2971
|
});
|
|
3378
2972
|
}
|
|
@@ -3381,12 +2975,10 @@ var debug = (function (_sdk) {
|
|
|
3381
2975
|
off: function off(event, listener) {
|
|
3382
2976
|
console.info(".off(\"" + event + "\", " + (listener.name || 'anonymous') + ")");
|
|
3383
2977
|
var enhancedListener = listener;
|
|
3384
|
-
|
|
3385
2978
|
if (listener[LISTENER_IDENTITY] !== undefined) {
|
|
3386
2979
|
var enhancedListenerId = listener[LISTENER_IDENTITY][event];
|
|
3387
2980
|
enhancedListener = listenersMap[enhancedListenerId];
|
|
3388
2981
|
}
|
|
3389
|
-
|
|
3390
2982
|
_off(event, enhancedListener);
|
|
3391
2983
|
},
|
|
3392
2984
|
on: function on(event, listener) {
|
|
@@ -3399,45 +2991,40 @@ var debug = (function (_sdk) {
|
|
|
3399
2991
|
});
|
|
3400
2992
|
|
|
3401
2993
|
var CHATS_PAGINATION_MAX_LIMIT = 25;
|
|
3402
|
-
var init = function init(config, env) {
|
|
2994
|
+
var init = function init(config, env, licenseId) {
|
|
3403
2995
|
if (env === void 0) {
|
|
3404
2996
|
env = 'production';
|
|
3405
2997
|
}
|
|
3406
|
-
|
|
3407
2998
|
validateConfig(config);
|
|
3408
|
-
|
|
3409
2999
|
var _config$autoConnect = config.autoConnect,
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3000
|
+
autoConnect = _config$autoConnect === void 0 ? true : _config$autoConnect,
|
|
3001
|
+
customerDataProvider = config.customerDataProvider,
|
|
3002
|
+
identityProvider = config.identityProvider,
|
|
3003
|
+
instanceConfig = _objectWithoutPropertiesLoose(config, ["autoConnect", "customerDataProvider", "identityProvider"]);
|
|
3415
3004
|
var store = finalCreateStore(_extends({}, instanceConfig, {
|
|
3416
3005
|
env: env
|
|
3417
3006
|
}));
|
|
3418
3007
|
var emitter = mitt();
|
|
3419
3008
|
var socket = createSocketClient(store);
|
|
3420
|
-
var auth = typeof identityProvider === 'function' ? identityProvider() : createAuth(instanceConfig, env);
|
|
3009
|
+
var auth = typeof identityProvider === 'function' ? identityProvider() : createAuth(instanceConfig, licenseId, env);
|
|
3421
3010
|
store.addSideEffectsHandler(createSideEffectsHandler({
|
|
3422
3011
|
emitter: emitter,
|
|
3423
3012
|
socket: socket,
|
|
3424
3013
|
auth: auth,
|
|
3425
|
-
customerDataProvider: customerDataProvider
|
|
3014
|
+
customerDataProvider: customerDataProvider,
|
|
3015
|
+
licenseId: licenseId
|
|
3426
3016
|
}));
|
|
3427
3017
|
socketListener(store, socket);
|
|
3428
|
-
|
|
3429
3018
|
var sendRequestAction$1 = sendRequestAction.bind(null, store);
|
|
3430
|
-
|
|
3431
3019
|
var startConnection = function startConnection() {
|
|
3432
3020
|
store.dispatch({
|
|
3433
3021
|
type: START_CONNECTION
|
|
3434
3022
|
});
|
|
3435
3023
|
};
|
|
3436
|
-
|
|
3437
3024
|
var api = Object.freeze({
|
|
3438
3025
|
acceptGreeting: function acceptGreeting(_ref) {
|
|
3439
3026
|
var greetingId = _ref.greetingId,
|
|
3440
|
-
|
|
3027
|
+
uniqueId = _ref.uniqueId;
|
|
3441
3028
|
return sendRequestAction$1(sendRequest(ACCEPT_GREETING, {
|
|
3442
3029
|
greeting_id: greetingId,
|
|
3443
3030
|
unique_id: uniqueId
|
|
@@ -3452,20 +3039,18 @@ var init = function init(config, env) {
|
|
|
3452
3039
|
},
|
|
3453
3040
|
cancelRate: function cancelRate(params) {
|
|
3454
3041
|
var chatId = params.chatId,
|
|
3455
|
-
|
|
3456
|
-
|
|
3042
|
+
_params$properties = params.properties,
|
|
3043
|
+
properties = _params$properties === void 0 ? ['score'] : _params$properties;
|
|
3457
3044
|
return api.listThreads({
|
|
3458
3045
|
chatId: chatId
|
|
3459
3046
|
}).then(function (_ref3) {
|
|
3460
3047
|
var threads = _ref3.threads;
|
|
3461
|
-
|
|
3462
3048
|
if (!threads.length) {
|
|
3463
3049
|
throw createError({
|
|
3464
3050
|
message: "There is no thread in \"" + chatId + "\".",
|
|
3465
3051
|
code: MISSING_CHAT_THREAD
|
|
3466
3052
|
});
|
|
3467
3053
|
}
|
|
3468
|
-
|
|
3469
3054
|
return api.deleteThreadProperties({
|
|
3470
3055
|
chatId: chatId,
|
|
3471
3056
|
threadId: threads[0].id,
|
|
@@ -3484,7 +3069,7 @@ var init = function init(config, env) {
|
|
|
3484
3069
|
},
|
|
3485
3070
|
deleteChatProperties: function deleteChatProperties(_ref5) {
|
|
3486
3071
|
var id = _ref5.id,
|
|
3487
|
-
|
|
3072
|
+
properties = _ref5.properties;
|
|
3488
3073
|
return sendRequestAction$1(sendRequest(DELETE_CHAT_PROPERTIES, {
|
|
3489
3074
|
id: id,
|
|
3490
3075
|
properties: properties
|
|
@@ -3492,9 +3077,9 @@ var init = function init(config, env) {
|
|
|
3492
3077
|
},
|
|
3493
3078
|
deleteEventProperties: function deleteEventProperties(_ref6) {
|
|
3494
3079
|
var chatId = _ref6.chatId,
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3080
|
+
threadId = _ref6.threadId,
|
|
3081
|
+
eventId = _ref6.eventId,
|
|
3082
|
+
properties = _ref6.properties;
|
|
3498
3083
|
return sendRequestAction$1(sendRequest(DELETE_EVENT_PROPERTIES, {
|
|
3499
3084
|
chat_id: chatId,
|
|
3500
3085
|
thread_id: threadId,
|
|
@@ -3504,8 +3089,8 @@ var init = function init(config, env) {
|
|
|
3504
3089
|
},
|
|
3505
3090
|
deleteThreadProperties: function deleteThreadProperties(_ref7) {
|
|
3506
3091
|
var chatId = _ref7.chatId,
|
|
3507
|
-
|
|
3508
|
-
|
|
3092
|
+
threadId = _ref7.threadId,
|
|
3093
|
+
properties = _ref7.properties;
|
|
3509
3094
|
return sendRequestAction$1(sendRequest(DELETE_THREAD_PROPERTIES, {
|
|
3510
3095
|
chat_id: chatId,
|
|
3511
3096
|
thread_id: threadId,
|
|
@@ -3520,7 +3105,7 @@ var init = function init(config, env) {
|
|
|
3520
3105
|
},
|
|
3521
3106
|
getChat: function getChat(_ref8) {
|
|
3522
3107
|
var chatId = _ref8.chatId,
|
|
3523
|
-
|
|
3108
|
+
threadId = _ref8.threadId;
|
|
3524
3109
|
return sendRequestAction$1(sendRequest(GET_CHAT, {
|
|
3525
3110
|
chat_id: chatId,
|
|
3526
3111
|
thread_id: threadId
|
|
@@ -3535,7 +3120,7 @@ var init = function init(config, env) {
|
|
|
3535
3120
|
},
|
|
3536
3121
|
getForm: function getForm(_ref10) {
|
|
3537
3122
|
var groupId = _ref10.groupId,
|
|
3538
|
-
|
|
3123
|
+
type = _ref10.type;
|
|
3539
3124
|
return sendRequestAction$1(sendRequest(GET_FORM, {
|
|
3540
3125
|
group_id: groupId,
|
|
3541
3126
|
type: type
|
|
@@ -3545,9 +3130,8 @@ var init = function init(config, env) {
|
|
|
3545
3130
|
if (params === void 0) {
|
|
3546
3131
|
params = {};
|
|
3547
3132
|
}
|
|
3548
|
-
|
|
3549
3133
|
var _params = params,
|
|
3550
|
-
|
|
3134
|
+
groupId = _params.groupId;
|
|
3551
3135
|
return sendRequestAction$1(sendRequest(GET_PREDICTED_AGENT, typeof groupId === 'number' ? {
|
|
3552
3136
|
group_id: groupId
|
|
3553
3137
|
} : {}));
|
|
@@ -3562,11 +3146,9 @@ var init = function init(config, env) {
|
|
|
3562
3146
|
if (params === void 0) {
|
|
3563
3147
|
params = {};
|
|
3564
3148
|
}
|
|
3565
|
-
|
|
3566
3149
|
if ('limit' in params && typeof params.limit === 'number' && params.limit > CHATS_PAGINATION_MAX_LIMIT) {
|
|
3567
3150
|
return Promise.reject(new Error("Specified limit is too high (max " + CHATS_PAGINATION_MAX_LIMIT + ")."));
|
|
3568
3151
|
}
|
|
3569
|
-
|
|
3570
3152
|
return sendRequestAction$1(sendRequest(LIST_CHATS, params.pageId === undefined ? {
|
|
3571
3153
|
limit: params.limit || 10
|
|
3572
3154
|
} : {
|
|
@@ -3575,8 +3157,7 @@ var init = function init(config, env) {
|
|
|
3575
3157
|
},
|
|
3576
3158
|
listGroupStatuses: function listGroupStatuses(_temp) {
|
|
3577
3159
|
var _ref12 = _temp === void 0 ? {} : _temp,
|
|
3578
|
-
|
|
3579
|
-
|
|
3160
|
+
groupIds = _ref12.groupIds;
|
|
3580
3161
|
return sendRequestAction$1(sendRequest(LIST_GROUP_STATUSES, groupIds ? {
|
|
3581
3162
|
group_ids: groupIds
|
|
3582
3163
|
} : {
|
|
@@ -3596,7 +3177,7 @@ var init = function init(config, env) {
|
|
|
3596
3177
|
},
|
|
3597
3178
|
markEventsAsSeen: function markEventsAsSeen(_ref13) {
|
|
3598
3179
|
var chatId = _ref13.chatId,
|
|
3599
|
-
|
|
3180
|
+
seenUpTo = _ref13.seenUpTo;
|
|
3600
3181
|
return sendRequestAction$1(sendRequest(MARK_EVENTS_AS_SEEN, {
|
|
3601
3182
|
chat_id: chatId,
|
|
3602
3183
|
seen_up_to: seenUpTo
|
|
@@ -3607,19 +3188,17 @@ var init = function init(config, env) {
|
|
|
3607
3188
|
off: emitter.off,
|
|
3608
3189
|
rateChat: function rateChat(params) {
|
|
3609
3190
|
var chatId = params.chatId,
|
|
3610
|
-
|
|
3191
|
+
rating = params.rating;
|
|
3611
3192
|
return api.listThreads({
|
|
3612
3193
|
chatId: chatId
|
|
3613
3194
|
}).then(function (_ref14) {
|
|
3614
3195
|
var threads = _ref14.threads;
|
|
3615
|
-
|
|
3616
3196
|
if (!threads.length) {
|
|
3617
3197
|
throw createError({
|
|
3618
3198
|
message: "There is no thread in \"" + chatId + "\".",
|
|
3619
3199
|
code: MISSING_CHAT_THREAD
|
|
3620
3200
|
});
|
|
3621
3201
|
}
|
|
3622
|
-
|
|
3623
3202
|
return api.updateThreadProperties({
|
|
3624
3203
|
chatId: chatId,
|
|
3625
3204
|
threadId: threads[0].id,
|
|
@@ -3632,7 +3211,7 @@ var init = function init(config, env) {
|
|
|
3632
3211
|
resumeChat: function resumeChat(data) {
|
|
3633
3212
|
log({
|
|
3634
3213
|
env: env,
|
|
3635
|
-
|
|
3214
|
+
organizationId: config.organizationId,
|
|
3636
3215
|
eventName: 'chat_started'
|
|
3637
3216
|
});
|
|
3638
3217
|
return sendRequestAction$1(sendRequest(RESUME_CHAT, parseResumeChatData(data)));
|
|
@@ -3641,11 +3220,9 @@ var init = function init(config, env) {
|
|
|
3641
3220
|
function sendEvent(_x) {
|
|
3642
3221
|
return _sendEvent.apply(this, arguments);
|
|
3643
3222
|
}
|
|
3644
|
-
|
|
3645
3223
|
sendEvent.toString = function () {
|
|
3646
3224
|
return _sendEvent.toString();
|
|
3647
3225
|
};
|
|
3648
|
-
|
|
3649
3226
|
return sendEvent;
|
|
3650
3227
|
}(function (params) {
|
|
3651
3228
|
return sendRequestAction$1(sendEvent(params));
|
|
@@ -3655,9 +3232,9 @@ var init = function init(config, env) {
|
|
|
3655
3232
|
},
|
|
3656
3233
|
sendRichMessagePostback: function sendRichMessagePostback(_ref15) {
|
|
3657
3234
|
var chatId = _ref15.chatId,
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3235
|
+
threadId = _ref15.threadId,
|
|
3236
|
+
eventId = _ref15.eventId,
|
|
3237
|
+
postback = _ref15.postback;
|
|
3661
3238
|
return sendRequestAction$1(sendRequest(SEND_RICH_MESSAGE_POSTBACK, {
|
|
3662
3239
|
chat_id: chatId,
|
|
3663
3240
|
event_id: eventId,
|
|
@@ -3673,13 +3250,11 @@ var init = function init(config, env) {
|
|
|
3673
3250
|
},
|
|
3674
3251
|
setSneakPeek: function setSneakPeek(_ref17) {
|
|
3675
3252
|
var chatId = _ref17.chatId,
|
|
3676
|
-
|
|
3253
|
+
sneakPeekText = _ref17.sneakPeekText;
|
|
3677
3254
|
var state = store.getState();
|
|
3678
|
-
|
|
3679
3255
|
if (!isChatActive(state, chatId) || !isConnected(state)) {
|
|
3680
3256
|
return;
|
|
3681
3257
|
}
|
|
3682
|
-
|
|
3683
3258
|
sendRequestAction$1(sendRequest(SEND_SNEAK_PEEK, {
|
|
3684
3259
|
chat_id: chatId,
|
|
3685
3260
|
sneak_peek_text: sneakPeekText
|
|
@@ -3689,17 +3264,16 @@ var init = function init(config, env) {
|
|
|
3689
3264
|
if (data === void 0) {
|
|
3690
3265
|
data = {};
|
|
3691
3266
|
}
|
|
3692
|
-
|
|
3693
3267
|
log({
|
|
3694
3268
|
env: env,
|
|
3695
|
-
|
|
3269
|
+
organizationId: config.organizationId,
|
|
3696
3270
|
eventName: 'chat_started'
|
|
3697
3271
|
});
|
|
3698
3272
|
return sendRequestAction$1(sendRequest(START_CHAT, parseStartChatData(data)));
|
|
3699
3273
|
},
|
|
3700
3274
|
updateChatProperties: function updateChatProperties(_ref18) {
|
|
3701
3275
|
var id = _ref18.id,
|
|
3702
|
-
|
|
3276
|
+
properties = _ref18.properties;
|
|
3703
3277
|
return sendRequestAction$1(sendRequest(UPDATE_CHAT_PROPERTIES, {
|
|
3704
3278
|
id: id,
|
|
3705
3279
|
properties: properties
|
|
@@ -3716,9 +3290,9 @@ var init = function init(config, env) {
|
|
|
3716
3290
|
},
|
|
3717
3291
|
updateEventProperties: function updateEventProperties(_ref19) {
|
|
3718
3292
|
var chatId = _ref19.chatId,
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3293
|
+
threadId = _ref19.threadId,
|
|
3294
|
+
eventId = _ref19.eventId,
|
|
3295
|
+
properties = _ref19.properties;
|
|
3722
3296
|
return sendRequestAction$1(sendRequest(UPDATE_EVENT_PROPERTIES, {
|
|
3723
3297
|
chat_id: chatId,
|
|
3724
3298
|
event_id: eventId,
|
|
@@ -3728,8 +3302,8 @@ var init = function init(config, env) {
|
|
|
3728
3302
|
},
|
|
3729
3303
|
updateThreadProperties: function updateThreadProperties(_ref20) {
|
|
3730
3304
|
var chatId = _ref20.chatId,
|
|
3731
|
-
|
|
3732
|
-
|
|
3305
|
+
threadId = _ref20.threadId,
|
|
3306
|
+
properties = _ref20.properties;
|
|
3733
3307
|
return sendRequestAction$1(sendRequest(UPDATE_THREAD_PROPERTIES, {
|
|
3734
3308
|
chat_id: chatId,
|
|
3735
3309
|
thread_id: threadId,
|
|
@@ -3743,7 +3317,6 @@ var init = function init(config, env) {
|
|
|
3743
3317
|
}, options);
|
|
3744
3318
|
}
|
|
3745
3319
|
});
|
|
3746
|
-
|
|
3747
3320
|
if (autoConnect) {
|
|
3748
3321
|
startConnection();
|
|
3749
3322
|
} else {
|
|
@@ -3754,7 +3327,6 @@ var init = function init(config, env) {
|
|
|
3754
3327
|
}
|
|
3755
3328
|
});
|
|
3756
3329
|
}
|
|
3757
|
-
|
|
3758
3330
|
return api;
|
|
3759
3331
|
};
|
|
3760
3332
|
|