wingbot 3.46.0-alpha.2 → 3.46.0-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.46.0-alpha.2",
3
+ "version": "3.46.0-alpha.4",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "doc": "npm run doc:gql && node ./bin/makeApiDoc.js && cpy ./CHANGELOG.md ./doc && gitbook install ./doc && gitbook build ./doc && rimraf -rf ./docs && rimraf --rf ./doc/CHANGELOG.md && move-cli ./doc/_book ./docs",
10
10
  "test": "npm run test:lint && npm run test:coverage && npm run test:coverage:threshold",
11
11
  "test:coverage": "nyc --reporter=html mocha ./test && nyc report",
12
- "test:coverage:threshold": "nyc check-coverage --lines 90 --functions 90 --branches 80",
12
+ "test:coverage:threshold": "nyc check-coverage --lines 90 --functions 89 --branches 80",
13
13
  "test:backend": "mocha ./test",
14
14
  "test:lint": "eslint --ext .js src test *.js plugins"
15
15
  },
@@ -122,6 +122,7 @@ const {
122
122
  * @prop {boolean} [supportsArrays]
123
123
  * @prop {boolean} [useDescriptiveCategories]
124
124
  * @prop {boolean} [useExtendedScalars]
125
+ * @prop {boolean} [parallelSessionInsert]
125
126
  */
126
127
 
127
128
  /**
@@ -200,7 +201,8 @@ function onInteractionHandler (
200
201
  supportsArrays = false,
201
202
  useExtendedScalars = false,
202
203
  hasExtendedEvents = false,
203
- useDescriptiveCategories = true
204
+ useDescriptiveCategories = true,
205
+ parallelSessionInsert = false
204
206
  } = analyticsStorage;
205
207
 
206
208
  const asArray = (data = []) => (supportsArrays ? data : data.join(','));
@@ -243,6 +245,7 @@ function onInteractionHandler (
243
245
 
244
246
  const [action = noneAction, ...otherActions] = actions;
245
247
 
248
+ let sessionPromise;
246
249
  if (createSession) {
247
250
  const metadata = {
248
251
  sessionCount,
@@ -252,7 +255,7 @@ function onInteractionHandler (
252
255
  botId
253
256
  };
254
257
 
255
- await analyticsStorage.createUserSession(
258
+ sessionPromise = analyticsStorage.createUserSession(
256
259
  pageId,
257
260
  senderId,
258
261
  sessionId,
@@ -261,6 +264,11 @@ function onInteractionHandler (
261
264
  nonInteractive,
262
265
  timeZone
263
266
  );
267
+
268
+ if (!parallelSessionInsert) {
269
+ await sessionPromise;
270
+ sessionPromise = null;
271
+ }
264
272
  }
265
273
 
266
274
  const [{
@@ -351,10 +359,15 @@ function onInteractionHandler (
351
359
  allActions
352
360
  };
353
361
 
362
+ const notHandled = actions.some((a) => a.match(/\*$/)) && !req.isQuickReply();
363
+ const value = notHandled ? 1 : 0;
364
+
354
365
  trackEvents.push({
355
366
  type: TrackingType.PAGE_VIEW,
356
367
  category: asCategory(TrackingCategory.PAGE_VIEW_FIRST),
357
368
  action,
369
+ label: (isText || isQuickReply ? text : null),
370
+ value,
358
371
  allActions,
359
372
  nonInteractive,
360
373
  lastAction,
@@ -373,6 +386,7 @@ function onInteractionHandler (
373
386
  type: TrackingType.PAGE_VIEW,
374
387
  category: asCategory(TrackingCategory.PAGE_VIEW_SUBSEQUENT),
375
388
  action: a,
389
+ value: 0,
376
390
  allActions,
377
391
  nonInteractive: false,
378
392
  lastAction,
@@ -389,14 +403,14 @@ function onInteractionHandler (
389
403
 
390
404
  trackEvents.push(
391
405
  ...events.map(({
392
- type, category, action: eventAction, label, value
406
+ type, category, action: eventAction, label, value: eVal
393
407
  }) => ({
394
408
  lastAction,
395
409
  type,
396
410
  category,
397
411
  action: eventAction,
398
412
  label,
399
- value,
413
+ value: eVal,
400
414
  ...langsExtension
401
415
  }))
402
416
  );
@@ -417,11 +431,8 @@ function onInteractionHandler (
417
431
  });
418
432
  }
419
433
 
420
- const notHandled = actions.some((a) => a.match(/\*$/)) && !req.isQuickReply();
421
-
422
434
  let actionCategory;
423
435
  let label = noneAction;
424
- const value = notHandled ? 1 : 0;
425
436
 
426
437
  if (isPassThread) {
427
438
  actionCategory = TrackingCategory.HANDOVER_TO_BOT;
@@ -450,7 +461,7 @@ function onInteractionHandler (
450
461
  actionCategory = TrackingCategory.REFERRAL;
451
462
  } else if (isPostback) {
452
463
  actionCategory = TrackingCategory.POSTBACK_BUTTON;
453
- label = req.data.postback.title || '(unknown)';
464
+ label = req.event.postback.title || (useExtendedScalars ? null : '(unknown)');
454
465
  } else {
455
466
  actionCategory = TrackingCategory.OTHER;
456
467
  }
@@ -468,18 +479,21 @@ function onInteractionHandler (
468
479
  });
469
480
  }
470
481
 
471
- await analyticsStorage.storeEvents(
472
- pageId,
473
- senderId,
474
- sessionId,
475
- // @ts-ignore
476
- trackEvents,
477
- user,
478
- timestamp,
479
- nonInteractive,
480
- createSession,
481
- timeZone
482
- );
482
+ await Promise.all([
483
+ analyticsStorage.storeEvents(
484
+ pageId,
485
+ senderId,
486
+ sessionId,
487
+ // @ts-ignore
488
+ trackEvents,
489
+ user,
490
+ timestamp,
491
+ nonInteractive,
492
+ createSession,
493
+ timeZone
494
+ ),
495
+ sessionPromise
496
+ ]);
483
497
  } catch (e) {
484
498
  if (throwException) {
485
499
  throw e;