wingbot 3.48.1 → 3.49.0
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
|
@@ -32,7 +32,7 @@ const {
|
|
|
32
32
|
* @prop {string} [label]
|
|
33
33
|
* @prop {number} [value]
|
|
34
34
|
* @prop {string} [lang]
|
|
35
|
-
* @prop {string|null} [
|
|
35
|
+
* @prop {string|null} [pageCategory]
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -62,6 +62,7 @@ const {
|
|
|
62
62
|
* @prop {number} [intentScore]
|
|
63
63
|
* @prop {string[]|string} [entities]
|
|
64
64
|
* @prop {string|null} [pagePath]
|
|
65
|
+
* @prop {string|null} [pageCategory]
|
|
65
66
|
* @prop {string[]|string} allActions
|
|
66
67
|
* @prop {boolean} nonInteractive
|
|
67
68
|
*
|
|
@@ -99,6 +100,7 @@ const {
|
|
|
99
100
|
* @prop {number} [sessionDuration]
|
|
100
101
|
* @prop {string[]} [responseTexts]
|
|
101
102
|
* @prop {string|null} [pagePath]
|
|
103
|
+
* @prop {string|null} [pageCategory]
|
|
102
104
|
*/
|
|
103
105
|
|
|
104
106
|
/**
|
|
@@ -156,6 +158,12 @@ const {
|
|
|
156
158
|
* @returns {string}
|
|
157
159
|
*/
|
|
158
160
|
|
|
161
|
+
/**
|
|
162
|
+
* @callback PathCategoryExtractor
|
|
163
|
+
* @param {string} pathName
|
|
164
|
+
* @returns {string}
|
|
165
|
+
*/
|
|
166
|
+
|
|
159
167
|
/**
|
|
160
168
|
* @typedef {object} TrackingEvents
|
|
161
169
|
* @prop {TrackingEvent[]} events
|
|
@@ -177,6 +185,7 @@ const {
|
|
|
177
185
|
* @prop {IGALogger} [log] - console like logger
|
|
178
186
|
* @prop {Anonymizer} [anonymize] - text anonymization function
|
|
179
187
|
* @prop {UserExtractor} [userExtractor] - text anonymization function
|
|
188
|
+
* @prop {PathCategoryExtractor} [pathCategoryExtractor]
|
|
180
189
|
*/
|
|
181
190
|
|
|
182
191
|
/**
|
|
@@ -196,6 +205,17 @@ const {
|
|
|
196
205
|
* @returns {Promise}
|
|
197
206
|
*/
|
|
198
207
|
|
|
208
|
+
function defaultPathExtractor (pathName) {
|
|
209
|
+
if (!pathName) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const [firstElem] = pathName.split('/')
|
|
214
|
+
.filter((e) => !!e);
|
|
215
|
+
|
|
216
|
+
return firstElem || '/';
|
|
217
|
+
}
|
|
218
|
+
|
|
199
219
|
/**
|
|
200
220
|
*
|
|
201
221
|
* @param {HandlerConfig} config
|
|
@@ -212,6 +232,7 @@ function onInteractionHandler (
|
|
|
212
232
|
botId,
|
|
213
233
|
timeZone = 'UTC',
|
|
214
234
|
pagePathVar = '§pathname',
|
|
235
|
+
pathCategoryExtractor = defaultPathExtractor,
|
|
215
236
|
anonymize = (x) => x,
|
|
216
237
|
userExtractor = (state) => null // eslint-disable-line no-unused-vars
|
|
217
238
|
},
|
|
@@ -267,6 +288,8 @@ function onInteractionHandler (
|
|
|
267
288
|
[pagePathVar]: pagePath
|
|
268
289
|
} = state;
|
|
269
290
|
|
|
291
|
+
const pageCategory = pathCategoryExtractor(pagePath);
|
|
292
|
+
|
|
270
293
|
const trackEvents = [];
|
|
271
294
|
|
|
272
295
|
const [action = noneAction, ...otherActions] = actions;
|
|
@@ -304,7 +327,8 @@ function onInteractionHandler (
|
|
|
304
327
|
sessionStart,
|
|
305
328
|
responseTexts,
|
|
306
329
|
sessionDuration: sessionTs - sessionStart,
|
|
307
|
-
pagePath
|
|
330
|
+
pagePath,
|
|
331
|
+
pageCategory
|
|
308
332
|
};
|
|
309
333
|
|
|
310
334
|
let sessionPromise;
|
|
@@ -399,7 +423,8 @@ function onInteractionHandler (
|
|
|
399
423
|
entities: asArray(req.entities.map((e) => e.entity)),
|
|
400
424
|
text,
|
|
401
425
|
allActions,
|
|
402
|
-
pagePath
|
|
426
|
+
pagePath,
|
|
427
|
+
pageCategory
|
|
403
428
|
};
|
|
404
429
|
|
|
405
430
|
const notHandled = actions.some((a) => a.match(/\*$/)) && !req.isQuickReply();
|
|
@@ -521,7 +546,7 @@ function onInteractionHandler (
|
|
|
521
546
|
action,
|
|
522
547
|
label,
|
|
523
548
|
value,
|
|
524
|
-
|
|
549
|
+
pageCategory,
|
|
525
550
|
...langsExtension
|
|
526
551
|
});
|
|
527
552
|
}
|