wingbot 3.46.0-alpha.2 → 3.46.0-alpha.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/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.3",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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 [{
@@ -450,7 +458,7 @@ function onInteractionHandler (
450
458
  actionCategory = TrackingCategory.REFERRAL;
451
459
  } else if (isPostback) {
452
460
  actionCategory = TrackingCategory.POSTBACK_BUTTON;
453
- label = req.data.postback.title || '(unknown)';
461
+ label = req.event.postback.title || '(unknown)';
454
462
  } else {
455
463
  actionCategory = TrackingCategory.OTHER;
456
464
  }
@@ -468,18 +476,21 @@ function onInteractionHandler (
468
476
  });
469
477
  }
470
478
 
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
- );
479
+ await Promise.all([
480
+ analyticsStorage.storeEvents(
481
+ pageId,
482
+ senderId,
483
+ sessionId,
484
+ // @ts-ignore
485
+ trackEvents,
486
+ user,
487
+ timestamp,
488
+ nonInteractive,
489
+ createSession,
490
+ timeZone
491
+ ),
492
+ sessionPromise
493
+ ]);
483
494
  } catch (e) {
484
495
  if (throwException) {
485
496
  throw e;