wingbot 3.44.0 → 3.44.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.44.0",
3
+ "version": "3.44.1",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@ const Ai = require('../Ai');
11
11
 
12
12
  /**
13
13
  * @typedef {object} GAUser
14
- * @prop {string} id
14
+ * @prop {string} [id]
15
15
  */
16
16
 
17
17
  /**
@@ -55,6 +55,8 @@ const Ai = require('../Ai');
55
55
  * @param {Event[]} events
56
56
  * @param {GAUser} [user]
57
57
  * @param {number} [ts]
58
+ * @param {boolean} [nonInteractive]
59
+ * @param {boolean} [sessionStarted]
58
60
  * @returns {Promise}
59
61
  */
60
62
 
@@ -72,9 +74,9 @@ const Ai = require('../Ai');
72
74
  */
73
75
 
74
76
  /**
75
- * @callback MetadataExtractor
77
+ * @callback UserExtractor
76
78
  * @param {Request} req
77
- * @returns {object}
79
+ * @returns {object & GAUser}
78
80
  */
79
81
 
80
82
  /**
@@ -99,7 +101,7 @@ const Ai = require('../Ai');
99
101
  * @prop {boolean} [throwException] - default false
100
102
  * @prop {IGALogger} [log] - console like logger
101
103
  * @prop {Anonymizer} [anonymize] - text anonymization function
102
- * @prop {MetadataExtractor} [extractMetadata] - text anonymization function
104
+ * @prop {UserExtractor} [userExtractor] - text anonymization function
103
105
  */
104
106
 
105
107
  /**
@@ -121,7 +123,7 @@ function onInteractionHandler (
121
123
  throwException = false,
122
124
  log = console,
123
125
  anonymize = (x) => x,
124
- extractMetadata = (req) => ({}) // eslint-disable-line no-unused-vars
126
+ userExtractor = (req) => null // eslint-disable-line no-unused-vars
125
127
  },
126
128
  analyticsStorage,
127
129
  ai = Ai.ai
@@ -163,9 +165,7 @@ function onInteractionHandler (
163
165
  const metadata = {
164
166
  sessionCount,
165
167
  lang,
166
- action,
167
- cd1: (req.state.user && req.state.user.department) || 'unknown',
168
- ...extractMetadata(req)
168
+ action
169
169
  };
170
170
 
171
171
  await analyticsStorage.createUserSession(
@@ -366,7 +366,7 @@ function onInteractionHandler (
366
366
  });
367
367
  }
368
368
 
369
- const user = null;
369
+ const user = userExtractor(req);
370
370
 
371
371
  await analyticsStorage.storeEvents(
372
372
  pageId,
@@ -375,7 +375,9 @@ function onInteractionHandler (
375
375
  // @ts-ignore
376
376
  events,
377
377
  user,
378
- timestamp
378
+ timestamp,
379
+ nonInteractive,
380
+ createSession
379
381
  );
380
382
  } catch (e) {
381
383
  if (throwException) {