wingbot 3.46.3 → 3.46.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 +1 -1
- package/src/Processor.js +7 -10
- package/src/analytics/onInteractionHandler.js +45 -43
package/package.json
CHANGED
package/src/Processor.js
CHANGED
|
@@ -63,6 +63,7 @@ const { mergeState, isUserInteraction } = require('./utils/stateVariables');
|
|
|
63
63
|
* @prop {ResponseFlag|null} flag
|
|
64
64
|
* @prop {boolean} nonInteractive
|
|
65
65
|
* @prop {string[]} responseTexts
|
|
66
|
+
* @prop {boolean} doNotTrack
|
|
66
67
|
*/
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -421,12 +422,7 @@ class Processor extends EventEmitter {
|
|
|
421
422
|
* @returns {Promise}
|
|
422
423
|
*/
|
|
423
424
|
_emitInteractionEvent (req, res, messageSender, state, data) {
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
if (shouldNotTrack) {
|
|
427
|
-
return Promise.resolve();
|
|
428
|
-
}
|
|
429
|
-
|
|
425
|
+
const doNotTrack = data._initialEventShouldNotBeTracked === true;
|
|
430
426
|
const { _lastAction: lastAction = null } = req.state;
|
|
431
427
|
const actions = messageSender.visitedInteractions;
|
|
432
428
|
const skill = typeof res.newState._trackAsSkill === 'undefined'
|
|
@@ -435,6 +431,7 @@ class Processor extends EventEmitter {
|
|
|
435
431
|
const { events = [] } = messageSender.tracking;
|
|
436
432
|
|
|
437
433
|
const event = {
|
|
434
|
+
doNotTrack,
|
|
438
435
|
responseTexts: messageSender.responseTexts,
|
|
439
436
|
req,
|
|
440
437
|
actions,
|
|
@@ -445,7 +442,7 @@ class Processor extends EventEmitter {
|
|
|
445
442
|
tracking: messageSender.tracking,
|
|
446
443
|
events,
|
|
447
444
|
flag: res.senderMeta.flag,
|
|
448
|
-
nonInteractive: !isUserInteraction(req)
|
|
445
|
+
nonInteractive: !isUserInteraction(req) || doNotTrack
|
|
449
446
|
};
|
|
450
447
|
|
|
451
448
|
return Promise.allSettled([
|
|
@@ -610,10 +607,10 @@ class Processor extends EventEmitter {
|
|
|
610
607
|
|
|
611
608
|
const interactive = isUserInteraction(req);
|
|
612
609
|
|
|
613
|
-
|
|
614
|
-
&& (sessionTs + this.options.sessionDuration) < Date.now()
|
|
615
|
-
|| !sessionId) {
|
|
610
|
+
const sessionExpired = interactive
|
|
611
|
+
&& (sessionTs + this.options.sessionDuration) < Date.now();
|
|
616
612
|
|
|
613
|
+
if (sessionExpired || !sessionId) {
|
|
617
614
|
sessionStart = timestamp;
|
|
618
615
|
sessionTs = timestamp;
|
|
619
616
|
sessionId = Processor._createSessionId(req.pageId, req.senderId, timestamp);
|
|
@@ -239,7 +239,8 @@ function onInteractionHandler (
|
|
|
239
239
|
events,
|
|
240
240
|
flag,
|
|
241
241
|
nonInteractive,
|
|
242
|
-
responseTexts
|
|
242
|
+
responseTexts,
|
|
243
|
+
doNotTrack = false
|
|
243
244
|
}) {
|
|
244
245
|
if (!enabled) {
|
|
245
246
|
return;
|
|
@@ -321,7 +322,7 @@ function onInteractionHandler (
|
|
|
321
322
|
score = 0
|
|
322
323
|
} = {}] = req.intents;
|
|
323
324
|
|
|
324
|
-
const text = req.isConfidentInput()
|
|
325
|
+
const text = req.isConfidentInput() || doNotTrack
|
|
325
326
|
? '*****'
|
|
326
327
|
: anonymize(
|
|
327
328
|
replaceDiacritics(req.text()).replace(/\s+/g, ' ').toLowerCase().trim()
|
|
@@ -396,47 +397,49 @@ function onInteractionHandler (
|
|
|
396
397
|
const notHandled = actions.some((a) => a.match(/\*$/)) && !req.isQuickReply();
|
|
397
398
|
const value = notHandled ? 1 : 0;
|
|
398
399
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
let prevAction = action;
|
|
418
|
-
|
|
419
|
-
trackEvents.push(
|
|
420
|
-
...otherActions.map((a) => {
|
|
421
|
-
const r = {
|
|
422
|
-
type: TrackingType.PAGE_VIEW,
|
|
423
|
-
category: asCategory(TrackingCategory.PAGE_VIEW_SUBSEQUENT),
|
|
424
|
-
action: a,
|
|
425
|
-
value: 0,
|
|
426
|
-
allActions,
|
|
427
|
-
nonInteractive: false,
|
|
428
|
-
lastAction,
|
|
429
|
-
prevAction,
|
|
430
|
-
skill: useSkill,
|
|
431
|
-
isGoto: true,
|
|
432
|
-
withUser,
|
|
433
|
-
...langsExtension
|
|
434
|
-
};
|
|
400
|
+
if (!doNotTrack) {
|
|
401
|
+
trackEvents.push({
|
|
402
|
+
type: TrackingType.PAGE_VIEW,
|
|
403
|
+
category: asCategory(TrackingCategory.PAGE_VIEW_FIRST),
|
|
404
|
+
action,
|
|
405
|
+
label: (isText || isQuickReply ? text : null),
|
|
406
|
+
value,
|
|
407
|
+
allActions,
|
|
408
|
+
nonInteractive,
|
|
409
|
+
lastAction,
|
|
410
|
+
// @ts-ignore
|
|
411
|
+
prevAction: lastAction,
|
|
412
|
+
skill: useSkill,
|
|
413
|
+
isGoto: false,
|
|
414
|
+
withUser,
|
|
415
|
+
...langsExtension,
|
|
416
|
+
...(hasExtendedEvents ? {} : actionMeta)
|
|
417
|
+
});
|
|
435
418
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
419
|
+
let prevAction = action;
|
|
420
|
+
|
|
421
|
+
trackEvents.push(
|
|
422
|
+
...otherActions.map((a) => {
|
|
423
|
+
const r = {
|
|
424
|
+
type: TrackingType.PAGE_VIEW,
|
|
425
|
+
category: asCategory(TrackingCategory.PAGE_VIEW_SUBSEQUENT),
|
|
426
|
+
action: a,
|
|
427
|
+
value: 0,
|
|
428
|
+
allActions,
|
|
429
|
+
nonInteractive: false,
|
|
430
|
+
lastAction,
|
|
431
|
+
prevAction,
|
|
432
|
+
skill: useSkill,
|
|
433
|
+
isGoto: true,
|
|
434
|
+
withUser,
|
|
435
|
+
...langsExtension
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
prevAction = a;
|
|
439
|
+
return r;
|
|
440
|
+
})
|
|
441
|
+
);
|
|
442
|
+
}
|
|
440
443
|
|
|
441
444
|
trackEvents.push(
|
|
442
445
|
...events.map(({
|
|
@@ -453,7 +456,6 @@ function onInteractionHandler (
|
|
|
453
456
|
);
|
|
454
457
|
|
|
455
458
|
if (!nonInteractive) {
|
|
456
|
-
|
|
457
459
|
if (req.isText()) {
|
|
458
460
|
trackEvents.push({
|
|
459
461
|
type: TrackingType.TRAINING,
|