wingbot 3.46.0-alpha.6 → 3.46.0-alpha.8
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
|
@@ -97,6 +97,10 @@ const {
|
|
|
97
97
|
* @prop {string} [action]
|
|
98
98
|
* @prop {string} [snapshot]
|
|
99
99
|
* @prop {string} [botId]
|
|
100
|
+
* @prop {boolean} [didHandover]
|
|
101
|
+
* @prop {number|null} [feedback]
|
|
102
|
+
* @prop {string} [timeZone]
|
|
103
|
+
* @prop {number} [sessionStart]
|
|
100
104
|
*/
|
|
101
105
|
|
|
102
106
|
/**
|
|
@@ -107,7 +111,6 @@ const {
|
|
|
107
111
|
* @param {SessionMetadata} [metadata]
|
|
108
112
|
* @param {number} [ts]
|
|
109
113
|
* @param {boolean} [nonInteractive]
|
|
110
|
-
* @param {string} [timeZone]
|
|
111
114
|
* @returns {Promise}
|
|
112
115
|
*/
|
|
113
116
|
|
|
@@ -121,7 +124,7 @@ const {
|
|
|
121
124
|
* @param {number} [ts]
|
|
122
125
|
* @param {boolean} [nonInteractive]
|
|
123
126
|
* @param {boolean} [sessionStarted]
|
|
124
|
-
* @param {
|
|
127
|
+
* @param {SessionMetadata} [metadata]
|
|
125
128
|
* @returns {Promise}
|
|
126
129
|
*/
|
|
127
130
|
|
|
@@ -260,26 +263,52 @@ function onInteractionHandler (
|
|
|
260
263
|
lang
|
|
261
264
|
} = req.state;
|
|
262
265
|
|
|
266
|
+
const trackEvents = [];
|
|
267
|
+
|
|
263
268
|
const [action = noneAction, ...otherActions] = actions;
|
|
264
269
|
|
|
270
|
+
const feedbackEvent = events.find((e) => e.type === TrackingType.REPORT
|
|
271
|
+
&& e.category === TrackingCategory.REPORT_FEEDBACK);
|
|
272
|
+
const feedback = feedbackEvent
|
|
273
|
+
? feedbackEvent.value
|
|
274
|
+
: noneValue;
|
|
275
|
+
let didHandover = flag === ResponseFlag.HANDOVER;
|
|
276
|
+
const hasHandoverEvent = events
|
|
277
|
+
.some((e) => e.category === TrackingCategory.HANDOVER_OCCURRED);
|
|
278
|
+
|
|
279
|
+
if (didHandover && !hasHandoverEvent) {
|
|
280
|
+
trackEvents.push({
|
|
281
|
+
type: TrackingType.REPORT,
|
|
282
|
+
category: asCategory(TrackingCategory.HANDOVER_OCCURRED),
|
|
283
|
+
action: null,
|
|
284
|
+
label: null,
|
|
285
|
+
value: noneValue
|
|
286
|
+
});
|
|
287
|
+
} else if (hasHandoverEvent) {
|
|
288
|
+
didHandover = true;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const metadata = {
|
|
292
|
+
sessionCount,
|
|
293
|
+
lang,
|
|
294
|
+
action,
|
|
295
|
+
snapshot,
|
|
296
|
+
botId,
|
|
297
|
+
didHandover,
|
|
298
|
+
feedback,
|
|
299
|
+
timeZone,
|
|
300
|
+
sessionStart
|
|
301
|
+
};
|
|
302
|
+
|
|
265
303
|
let sessionPromise;
|
|
266
304
|
if (createSession) {
|
|
267
|
-
const metadata = {
|
|
268
|
-
sessionCount,
|
|
269
|
-
lang,
|
|
270
|
-
action,
|
|
271
|
-
snapshot,
|
|
272
|
-
botId
|
|
273
|
-
};
|
|
274
|
-
|
|
275
305
|
sessionPromise = analyticsStorage.createUserSession(
|
|
276
306
|
pageId,
|
|
277
307
|
senderId,
|
|
278
308
|
sessionId,
|
|
279
309
|
metadata,
|
|
280
310
|
timestamp,
|
|
281
|
-
nonInteractive
|
|
282
|
-
timeZone
|
|
311
|
+
nonInteractive
|
|
283
312
|
);
|
|
284
313
|
|
|
285
314
|
if (!parallelSessionInsert) {
|
|
@@ -318,31 +347,7 @@ function onInteractionHandler (
|
|
|
318
347
|
winnerTaken = action === winnerAction;
|
|
319
348
|
}
|
|
320
349
|
|
|
321
|
-
const trackEvents = [];
|
|
322
|
-
|
|
323
350
|
const expected = req.expected() ? req.expected().action : '';
|
|
324
|
-
|
|
325
|
-
const feedbackEvent = events.find((e) => e.type === TrackingType.REPORT
|
|
326
|
-
&& e.category === TrackingCategory.REPORT_FEEDBACK);
|
|
327
|
-
const feedback = feedbackEvent
|
|
328
|
-
? feedbackEvent.value
|
|
329
|
-
: noneValue;
|
|
330
|
-
let didHandover = flag === ResponseFlag.HANDOVER;
|
|
331
|
-
const hasHandoverEvent = events
|
|
332
|
-
.some((e) => e.category === TrackingCategory.HANDOVER_OCCURRED);
|
|
333
|
-
|
|
334
|
-
if (didHandover && !hasHandoverEvent) {
|
|
335
|
-
trackEvents.push({
|
|
336
|
-
type: TrackingType.REPORT,
|
|
337
|
-
category: asCategory(TrackingCategory.HANDOVER_OCCURRED),
|
|
338
|
-
action: null,
|
|
339
|
-
label: null,
|
|
340
|
-
value: noneValue
|
|
341
|
-
});
|
|
342
|
-
} else if (hasHandoverEvent) {
|
|
343
|
-
didHandover = true;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
351
|
const user = userExtractor(req.state);
|
|
347
352
|
|
|
348
353
|
const isContextUpdate = req.isSetContext();
|
|
@@ -409,11 +414,8 @@ function onInteractionHandler (
|
|
|
409
414
|
prevAction: lastAction,
|
|
410
415
|
skill: useSkill,
|
|
411
416
|
isGoto: false,
|
|
412
|
-
sessionStart,
|
|
413
417
|
sessionDuration: timestamp - sessionStart,
|
|
414
418
|
withUser,
|
|
415
|
-
snapshot,
|
|
416
|
-
botId,
|
|
417
419
|
...langsExtension,
|
|
418
420
|
...(hasExtendedEvents ? {} : actionMeta)
|
|
419
421
|
});
|
|
@@ -433,10 +435,7 @@ function onInteractionHandler (
|
|
|
433
435
|
prevAction,
|
|
434
436
|
skill: useSkill,
|
|
435
437
|
isGoto: true,
|
|
436
|
-
sessionStart,
|
|
437
438
|
sessionDuration: timestamp - sessionStart,
|
|
438
|
-
snapshot,
|
|
439
|
-
botId,
|
|
440
439
|
...langsExtension
|
|
441
440
|
};
|
|
442
441
|
|
|
@@ -455,7 +454,6 @@ function onInteractionHandler (
|
|
|
455
454
|
action: eventAction,
|
|
456
455
|
label,
|
|
457
456
|
value: eVal,
|
|
458
|
-
sessionStart,
|
|
459
457
|
...langsExtension
|
|
460
458
|
}))
|
|
461
459
|
);
|
|
@@ -472,7 +470,6 @@ function onInteractionHandler (
|
|
|
472
470
|
action,
|
|
473
471
|
label: text,
|
|
474
472
|
value: score >= ai.confidence ? 0 : 1,
|
|
475
|
-
sessionStart,
|
|
476
473
|
...langsExtension
|
|
477
474
|
});
|
|
478
475
|
}
|
|
@@ -520,7 +517,6 @@ function onInteractionHandler (
|
|
|
520
517
|
action,
|
|
521
518
|
label,
|
|
522
519
|
value,
|
|
523
|
-
sessionStart,
|
|
524
520
|
...langsExtension
|
|
525
521
|
});
|
|
526
522
|
}
|
|
@@ -536,7 +532,7 @@ function onInteractionHandler (
|
|
|
536
532
|
timestamp,
|
|
537
533
|
nonInteractive,
|
|
538
534
|
createSession,
|
|
539
|
-
|
|
535
|
+
metadata
|
|
540
536
|
),
|
|
541
537
|
sessionPromise
|
|
542
538
|
]);
|