wingbot 3.46.0-alpha.1 → 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
package/src/analytics/consts.js
CHANGED
|
@@ -42,6 +42,10 @@ const TrackingType = { // max length 12
|
|
|
42
42
|
* @enum {string} TrackingCategory
|
|
43
43
|
*/
|
|
44
44
|
const TrackingCategory = { // max length 3
|
|
45
|
+
// PAGE_VIEW: 'page_view'
|
|
46
|
+
PAGE_VIEW_FIRST: 'pf',
|
|
47
|
+
PAGE_VIEW_SUBSEQUENT: 'pp',
|
|
48
|
+
|
|
45
49
|
// CONVERSATION_EVENT: 'conversation'
|
|
46
50
|
STICKER: 'sti',
|
|
47
51
|
IMAGE: 'img',
|
|
@@ -70,6 +74,10 @@ const TrackingCategory = { // max length 3
|
|
|
70
74
|
* @type {Object<TrackingCategory,string>}
|
|
71
75
|
*/
|
|
72
76
|
const CATEGORY_LABELS = {
|
|
77
|
+
// PAGE_VIEW: 'page_view'
|
|
78
|
+
[TrackingCategory.PAGE_VIEW_FIRST]: 'Bot: Interaction',
|
|
79
|
+
[TrackingCategory.PAGE_VIEW_SUBSEQUENT]: 'Bot: Sub-interaction',
|
|
80
|
+
|
|
73
81
|
// CONVERSATION_EVENT: 'conversation'
|
|
74
82
|
[TrackingCategory.STICKER]: 'User: Sticker',
|
|
75
83
|
[TrackingCategory.IMAGE]: 'User: Image',
|
|
@@ -31,6 +31,46 @@ const {
|
|
|
31
31
|
* @prop {string} [action]
|
|
32
32
|
* @prop {string} [label]
|
|
33
33
|
* @prop {number} [value]
|
|
34
|
+
* @prop {string} [lang]
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {object} ConversationEventExtension
|
|
39
|
+
* @prop {string} [skill]
|
|
40
|
+
* @prop {string} [text]
|
|
41
|
+
* @prop {string} [expected]
|
|
42
|
+
* @prop {boolean} expectedTaken
|
|
43
|
+
* @prop {boolean} isContextUpdate
|
|
44
|
+
* @prop {boolean} isAttachment
|
|
45
|
+
* @prop {boolean} isNotification
|
|
46
|
+
* @prop {boolean} isQuickReply
|
|
47
|
+
* @prop {boolean} isPassThread
|
|
48
|
+
* @prop {boolean} isPostback
|
|
49
|
+
* @prop {boolean} isText
|
|
50
|
+
* @prop {boolean} didHandover
|
|
51
|
+
* @prop {boolean} withUser
|
|
52
|
+
* @prop {string} [userId]
|
|
53
|
+
* @prop {number} [feedback]
|
|
54
|
+
* @prop {number} sessionStart
|
|
55
|
+
* @prop {number} sessionDuration
|
|
56
|
+
* @prop {string} [winnerAction]
|
|
57
|
+
* @prop {string} [winnerIntent]
|
|
58
|
+
* @prop {string[]|string} [winnerEntities]
|
|
59
|
+
* @prop {number} [winnerScore]
|
|
60
|
+
* @prop {boolean} [winnerTaken]
|
|
61
|
+
* @prop {string} [intent]
|
|
62
|
+
* @prop {number} [intentScore]
|
|
63
|
+
* @prop {string[]|string} [entities]
|
|
64
|
+
* @prop {string[]|string} allActions
|
|
65
|
+
* @prop {boolean} nonInteractive
|
|
66
|
+
* @prop {string} [snapshot]
|
|
67
|
+
* @prop {string} [botId]
|
|
68
|
+
*
|
|
69
|
+
* @typedef {Event & ConversationEventExtension} ConversationEvent
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @typedef {ConversationEvent | Event} TrackingEvent
|
|
34
74
|
*/
|
|
35
75
|
|
|
36
76
|
/**
|
|
@@ -59,7 +99,7 @@ const {
|
|
|
59
99
|
* @param {string} pageId
|
|
60
100
|
* @param {string} senderId
|
|
61
101
|
* @param {string} sessionId
|
|
62
|
-
* @param {
|
|
102
|
+
* @param {TrackingEvent[]} events
|
|
63
103
|
* @param {GAUser} [user]
|
|
64
104
|
* @param {number} [ts]
|
|
65
105
|
* @param {boolean} [nonInteractive]
|
|
@@ -82,6 +122,7 @@ const {
|
|
|
82
122
|
* @prop {boolean} [supportsArrays]
|
|
83
123
|
* @prop {boolean} [useDescriptiveCategories]
|
|
84
124
|
* @prop {boolean} [useExtendedScalars]
|
|
125
|
+
* @prop {boolean} [parallelSessionInsert]
|
|
85
126
|
*/
|
|
86
127
|
|
|
87
128
|
/**
|
|
@@ -98,7 +139,7 @@ const {
|
|
|
98
139
|
|
|
99
140
|
/**
|
|
100
141
|
* @typedef {object} TrackingEvents
|
|
101
|
-
* @prop {
|
|
142
|
+
* @prop {TrackingEvent[]} events
|
|
102
143
|
*/
|
|
103
144
|
|
|
104
145
|
/**
|
|
@@ -160,7 +201,8 @@ function onInteractionHandler (
|
|
|
160
201
|
supportsArrays = false,
|
|
161
202
|
useExtendedScalars = false,
|
|
162
203
|
hasExtendedEvents = false,
|
|
163
|
-
useDescriptiveCategories = true
|
|
204
|
+
useDescriptiveCategories = true,
|
|
205
|
+
parallelSessionInsert = false
|
|
164
206
|
} = analyticsStorage;
|
|
165
207
|
|
|
166
208
|
const asArray = (data = []) => (supportsArrays ? data : data.join(','));
|
|
@@ -203,6 +245,7 @@ function onInteractionHandler (
|
|
|
203
245
|
|
|
204
246
|
const [action = noneAction, ...otherActions] = actions;
|
|
205
247
|
|
|
248
|
+
let sessionPromise;
|
|
206
249
|
if (createSession) {
|
|
207
250
|
const metadata = {
|
|
208
251
|
sessionCount,
|
|
@@ -212,7 +255,7 @@ function onInteractionHandler (
|
|
|
212
255
|
botId
|
|
213
256
|
};
|
|
214
257
|
|
|
215
|
-
|
|
258
|
+
sessionPromise = analyticsStorage.createUserSession(
|
|
216
259
|
pageId,
|
|
217
260
|
senderId,
|
|
218
261
|
sessionId,
|
|
@@ -221,6 +264,11 @@ function onInteractionHandler (
|
|
|
221
264
|
nonInteractive,
|
|
222
265
|
timeZone
|
|
223
266
|
);
|
|
267
|
+
|
|
268
|
+
if (!parallelSessionInsert) {
|
|
269
|
+
await sessionPromise;
|
|
270
|
+
sessionPromise = null;
|
|
271
|
+
}
|
|
224
272
|
}
|
|
225
273
|
|
|
226
274
|
const [{
|
|
@@ -313,6 +361,7 @@ function onInteractionHandler (
|
|
|
313
361
|
|
|
314
362
|
trackEvents.push({
|
|
315
363
|
type: TrackingType.PAGE_VIEW,
|
|
364
|
+
category: asCategory(TrackingCategory.PAGE_VIEW_FIRST),
|
|
316
365
|
action,
|
|
317
366
|
allActions,
|
|
318
367
|
nonInteractive,
|
|
@@ -330,6 +379,7 @@ function onInteractionHandler (
|
|
|
330
379
|
...otherActions.map((a) => {
|
|
331
380
|
const r = {
|
|
332
381
|
type: TrackingType.PAGE_VIEW,
|
|
382
|
+
category: asCategory(TrackingCategory.PAGE_VIEW_SUBSEQUENT),
|
|
333
383
|
action: a,
|
|
334
384
|
allActions,
|
|
335
385
|
nonInteractive: false,
|
|
@@ -408,7 +458,7 @@ function onInteractionHandler (
|
|
|
408
458
|
actionCategory = TrackingCategory.REFERRAL;
|
|
409
459
|
} else if (isPostback) {
|
|
410
460
|
actionCategory = TrackingCategory.POSTBACK_BUTTON;
|
|
411
|
-
label = req.
|
|
461
|
+
label = req.event.postback.title || '(unknown)';
|
|
412
462
|
} else {
|
|
413
463
|
actionCategory = TrackingCategory.OTHER;
|
|
414
464
|
}
|
|
@@ -426,18 +476,21 @@ function onInteractionHandler (
|
|
|
426
476
|
});
|
|
427
477
|
}
|
|
428
478
|
|
|
429
|
-
await
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
+
]);
|
|
441
494
|
} catch (e) {
|
|
442
495
|
if (throwException) {
|
|
443
496
|
throw e;
|