wingbot 3.46.0-alpha.4 → 3.46.0-alpha.6
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
package/src/analytics/consts.js
CHANGED
|
@@ -62,12 +62,12 @@ const TrackingCategory = { // max length 3
|
|
|
62
62
|
|
|
63
63
|
// TRAINING: 'train'
|
|
64
64
|
INTENT_DETECTION: 'int',
|
|
65
|
-
HANDOVER_OCCURRED: 'hum',
|
|
66
65
|
DISAMBIGUATION_SELECTED: 'dis',
|
|
67
66
|
DISAMBIGUATION_OFFERED: 'dio',
|
|
68
67
|
|
|
69
68
|
// REPORT: 'report'
|
|
70
|
-
REPORT_FEEDBACK: 'fdb'
|
|
69
|
+
REPORT_FEEDBACK: 'fdb',
|
|
70
|
+
HANDOVER_OCCURRED: 'hum'
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -94,12 +94,12 @@ const CATEGORY_LABELS = {
|
|
|
94
94
|
|
|
95
95
|
// TRAINING: 'train'
|
|
96
96
|
[TrackingCategory.INTENT_DETECTION]: 'Intent: Detection',
|
|
97
|
-
[TrackingCategory.HANDOVER_OCCURRED]: 'Bot: Handover out',
|
|
98
97
|
[TrackingCategory.DISAMBIGUATION_SELECTED]: 'Disambiguation: selected',
|
|
99
98
|
[TrackingCategory.DISAMBIGUATION_OFFERED]: 'Disambiguation: offered',
|
|
100
99
|
|
|
101
100
|
// REPORT: 'report'
|
|
102
|
-
[TrackingCategory.REPORT_FEEDBACK]: 'User: Feedback'
|
|
101
|
+
[TrackingCategory.REPORT_FEEDBACK]: 'User: Feedback',
|
|
102
|
+
[TrackingCategory.HANDOVER_OCCURRED]: 'Bot: Handover out'
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
module.exports = {
|
|
@@ -32,10 +32,12 @@ const {
|
|
|
32
32
|
* @prop {string} [label]
|
|
33
33
|
* @prop {number} [value]
|
|
34
34
|
* @prop {string} [lang]
|
|
35
|
+
* @prop {number} [sessionStart]
|
|
35
36
|
*/
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* @typedef {object} ConversationEventExtension
|
|
40
|
+
* @prop {string} [lastAction]
|
|
39
41
|
* @prop {string} [skill]
|
|
40
42
|
* @prop {string} [text]
|
|
41
43
|
* @prop {string} [expected]
|
|
@@ -51,7 +53,6 @@ const {
|
|
|
51
53
|
* @prop {boolean} withUser
|
|
52
54
|
* @prop {string} [userId]
|
|
53
55
|
* @prop {number} [feedback]
|
|
54
|
-
* @prop {number} sessionStart
|
|
55
56
|
* @prop {number} sessionDuration
|
|
56
57
|
* @prop {string} [winnerAction]
|
|
57
58
|
* @prop {string} [winnerIntent]
|
|
@@ -70,7 +71,23 @@ const {
|
|
|
70
71
|
*/
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
|
-
* @typedef {
|
|
74
|
+
* @typedef {object} PageViewEventExtension
|
|
75
|
+
* @prop {string} [lastAction]
|
|
76
|
+
* @prop {string} [prevAction]
|
|
77
|
+
* @prop {string} [skill]
|
|
78
|
+
* @prop {number} sessionDuration
|
|
79
|
+
* @prop {string[]|string} allActions
|
|
80
|
+
* @prop {boolean} nonInteractive
|
|
81
|
+
* @prop {boolean} isGoto
|
|
82
|
+
* @prop {boolean} withUser
|
|
83
|
+
* @prop {string} [snapshot]
|
|
84
|
+
* @prop {string} [botId]
|
|
85
|
+
*
|
|
86
|
+
* @typedef {Event & PageViewEventExtension} PageViewEvent
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {ConversationEvent | Event | PageViewEvent} TrackingEvent
|
|
74
91
|
*/
|
|
75
92
|
|
|
76
93
|
/**
|
|
@@ -208,7 +225,7 @@ function onInteractionHandler (
|
|
|
208
225
|
const asArray = (data = []) => (supportsArrays ? data : data.join(','));
|
|
209
226
|
const asCategory = (cat) => (useDescriptiveCategories && CATEGORY_LABELS[cat]) || cat;
|
|
210
227
|
const noneAction = useExtendedScalars ? null : '(none)';
|
|
211
|
-
const noneValue = useExtendedScalars ?
|
|
228
|
+
const noneValue = useExtendedScalars ? null : 0;
|
|
212
229
|
|
|
213
230
|
/**
|
|
214
231
|
* @param {InteractionEvent} params
|
|
@@ -281,6 +298,7 @@ function onInteractionHandler (
|
|
|
281
298
|
: anonymize(
|
|
282
299
|
replaceDiacritics(req.text()).replace(/\s+/g, ' ').toLowerCase().trim()
|
|
283
300
|
);
|
|
301
|
+
const useSkill = (skill && webalize(skill)) || noneAction;
|
|
284
302
|
|
|
285
303
|
let winnerAction = '';
|
|
286
304
|
let winnerScore = 0;
|
|
@@ -300,6 +318,8 @@ function onInteractionHandler (
|
|
|
300
318
|
winnerTaken = action === winnerAction;
|
|
301
319
|
}
|
|
302
320
|
|
|
321
|
+
const trackEvents = [];
|
|
322
|
+
|
|
303
323
|
const expected = req.expected() ? req.expected().action : '';
|
|
304
324
|
|
|
305
325
|
const feedbackEvent = events.find((e) => e.type === TrackingType.REPORT
|
|
@@ -307,7 +327,21 @@ function onInteractionHandler (
|
|
|
307
327
|
const feedback = feedbackEvent
|
|
308
328
|
? feedbackEvent.value
|
|
309
329
|
: noneValue;
|
|
310
|
-
|
|
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
|
+
}
|
|
311
345
|
|
|
312
346
|
const user = userExtractor(req.state);
|
|
313
347
|
|
|
@@ -322,12 +356,12 @@ function onInteractionHandler (
|
|
|
322
356
|
const allActions = asArray(actions);
|
|
323
357
|
const requestAction = req.action();
|
|
324
358
|
|
|
325
|
-
const trackEvents = [];
|
|
326
|
-
|
|
327
359
|
const langsExtension = hasExtendedEvents
|
|
328
360
|
? { lang }
|
|
329
361
|
: { cd1: lang };
|
|
330
362
|
|
|
363
|
+
const withUser = user !== null && !!user.id;
|
|
364
|
+
|
|
331
365
|
const actionMeta = {
|
|
332
366
|
requestAction: req.action() || noneAction,
|
|
333
367
|
expected,
|
|
@@ -340,11 +374,11 @@ function onInteractionHandler (
|
|
|
340
374
|
isText,
|
|
341
375
|
isPostback,
|
|
342
376
|
didHandover,
|
|
343
|
-
withUser
|
|
377
|
+
withUser,
|
|
344
378
|
sessionStart,
|
|
345
379
|
sessionDuration: sessionTs - sessionStart,
|
|
346
380
|
feedback,
|
|
347
|
-
skill:
|
|
381
|
+
skill: useSkill,
|
|
348
382
|
snapshot,
|
|
349
383
|
botId,
|
|
350
384
|
winnerAction,
|
|
@@ -371,10 +405,16 @@ function onInteractionHandler (
|
|
|
371
405
|
allActions,
|
|
372
406
|
nonInteractive,
|
|
373
407
|
lastAction,
|
|
408
|
+
// @ts-ignore
|
|
374
409
|
prevAction: lastAction,
|
|
375
|
-
skill,
|
|
376
|
-
|
|
377
|
-
|
|
410
|
+
skill: useSkill,
|
|
411
|
+
isGoto: false,
|
|
412
|
+
sessionStart,
|
|
413
|
+
sessionDuration: timestamp - sessionStart,
|
|
414
|
+
withUser,
|
|
415
|
+
snapshot,
|
|
416
|
+
botId,
|
|
417
|
+
...langsExtension,
|
|
378
418
|
...(hasExtendedEvents ? {} : actionMeta)
|
|
379
419
|
});
|
|
380
420
|
|
|
@@ -391,8 +431,12 @@ function onInteractionHandler (
|
|
|
391
431
|
nonInteractive: false,
|
|
392
432
|
lastAction,
|
|
393
433
|
prevAction,
|
|
394
|
-
skill,
|
|
434
|
+
skill: useSkill,
|
|
395
435
|
isGoto: true,
|
|
436
|
+
sessionStart,
|
|
437
|
+
sessionDuration: timestamp - sessionStart,
|
|
438
|
+
snapshot,
|
|
439
|
+
botId,
|
|
396
440
|
...langsExtension
|
|
397
441
|
};
|
|
398
442
|
|
|
@@ -407,10 +451,11 @@ function onInteractionHandler (
|
|
|
407
451
|
}) => ({
|
|
408
452
|
lastAction,
|
|
409
453
|
type,
|
|
410
|
-
category,
|
|
454
|
+
category: asCategory(category),
|
|
411
455
|
action: eventAction,
|
|
412
456
|
label,
|
|
413
457
|
value: eVal,
|
|
458
|
+
sessionStart,
|
|
414
459
|
...langsExtension
|
|
415
460
|
}))
|
|
416
461
|
);
|
|
@@ -427,6 +472,7 @@ function onInteractionHandler (
|
|
|
427
472
|
action,
|
|
428
473
|
label: text,
|
|
429
474
|
value: score >= ai.confidence ? 0 : 1,
|
|
475
|
+
sessionStart,
|
|
430
476
|
...langsExtension
|
|
431
477
|
});
|
|
432
478
|
}
|
|
@@ -469,12 +515,12 @@ function onInteractionHandler (
|
|
|
469
515
|
trackEvents.push({
|
|
470
516
|
...(analyticsStorage.hasExtendedEvents ? actionMeta : {}),
|
|
471
517
|
type: TrackingType.CONVERSATION_EVENT,
|
|
472
|
-
// @ts-ignore
|
|
473
518
|
lastAction,
|
|
474
519
|
category: asCategory(actionCategory),
|
|
475
520
|
action,
|
|
476
521
|
label,
|
|
477
522
|
value,
|
|
523
|
+
sessionStart,
|
|
478
524
|
...langsExtension
|
|
479
525
|
});
|
|
480
526
|
}
|