@miso.ai/client-sdk-ui 1.9.5-beta.0 → 1.9.5-beta.2
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/dist/cjs/actor/data.js +12 -0
- package/dist/cjs/actor/feedback.js +16 -3
- package/dist/cjs/actor/tracker.js +5 -5
- package/dist/cjs/actor/utils.js +9 -5
- package/dist/cjs/actor/view.js +8 -4
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/ask.js +9 -9
- package/dist/cjs/workflow/explore.js +1 -1
- package/package.json +2 -2
- package/src/actor/data.js +8 -3
- package/src/actor/feedback.js +7 -3
- package/src/actor/tracker.js +5 -5
- package/src/actor/utils.js +6 -3
- package/src/actor/view.js +5 -6
- package/src/version.js +1 -1
- package/src/workflow/ask.js +8 -8
- package/src/workflow/explore.js +1 -1
package/dist/cjs/actor/data.js
CHANGED
|
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var fields = _interopRequireWildcard(require("./fields.js"));
|
|
8
|
+
const _excluded = ["session"];
|
|
8
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
12
|
class DataActor {
|
|
11
13
|
constructor(hub, _ref) {
|
|
12
14
|
let {
|
|
@@ -54,6 +56,13 @@ class DataActor {
|
|
|
54
56
|
const {
|
|
55
57
|
session
|
|
56
58
|
} = this._hub.states;
|
|
59
|
+
const request = _objectWithoutPropertiesLoose(event, _excluded);
|
|
60
|
+
|
|
61
|
+
// emit response to update request
|
|
62
|
+
this._emitResponse({
|
|
63
|
+
session,
|
|
64
|
+
request
|
|
65
|
+
});
|
|
57
66
|
try {
|
|
58
67
|
const {
|
|
59
68
|
signal
|
|
@@ -76,12 +85,14 @@ class DataActor {
|
|
|
76
85
|
}
|
|
77
86
|
this._emitResponse({
|
|
78
87
|
session,
|
|
88
|
+
request,
|
|
79
89
|
value
|
|
80
90
|
});
|
|
81
91
|
}
|
|
82
92
|
} else {
|
|
83
93
|
this._emitResponseWithSessionCheck({
|
|
84
94
|
session,
|
|
95
|
+
request,
|
|
85
96
|
value: response
|
|
86
97
|
});
|
|
87
98
|
}
|
|
@@ -89,6 +100,7 @@ class DataActor {
|
|
|
89
100
|
this._error(error);
|
|
90
101
|
this._emitResponseWithSessionCheck({
|
|
91
102
|
session,
|
|
103
|
+
request,
|
|
92
104
|
error
|
|
93
105
|
});
|
|
94
106
|
}
|
|
@@ -22,19 +22,32 @@ class FeedbackActor {
|
|
|
22
22
|
if (!question_id) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
// TODO: ad-hoc
|
|
26
|
+
const {
|
|
27
|
+
request
|
|
28
|
+
} = data || {};
|
|
29
|
+
const {
|
|
30
|
+
payload
|
|
31
|
+
} = request || {};
|
|
32
|
+
const question_source = payload && payload._meta && payload._meta.question_source;
|
|
33
|
+
this._hub.trigger(fields.interaction(), this._buildInteraction(state, {
|
|
34
|
+
question_source
|
|
35
|
+
}));
|
|
26
36
|
}
|
|
27
|
-
_buildInteraction(
|
|
37
|
+
_buildInteraction(_ref, _ref2) {
|
|
28
38
|
let {
|
|
29
39
|
value,
|
|
30
40
|
unselected
|
|
31
41
|
} = _ref;
|
|
42
|
+
let {
|
|
43
|
+
question_source
|
|
44
|
+
} = _ref2;
|
|
32
45
|
return {
|
|
33
46
|
type: 'feedback',
|
|
34
47
|
context: {
|
|
35
48
|
custom_context: {
|
|
36
49
|
result_type: 'answer',
|
|
37
|
-
|
|
50
|
+
question_source,
|
|
38
51
|
value: unselected ? 'unselected' : value
|
|
39
52
|
}
|
|
40
53
|
}
|
|
@@ -106,11 +106,11 @@ class Tracker {
|
|
|
106
106
|
const state = this._getViewState();
|
|
107
107
|
return state && state.meta && state.meta.miso_id || this._element && this._element.getAttribute('miso-id') || undefined;
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
_getRequestPayload() {
|
|
110
110
|
const {
|
|
111
|
-
|
|
111
|
+
request
|
|
112
112
|
} = this._getViewState() || {};
|
|
113
|
-
return
|
|
113
|
+
return request && request.payload;
|
|
114
114
|
}
|
|
115
115
|
getState(productId) {
|
|
116
116
|
return this._tracker.getState(productId);
|
|
@@ -118,12 +118,12 @@ class Tracker {
|
|
|
118
118
|
_handleEvent(data) {
|
|
119
119
|
const property = this._role === 'results' ? 'products' : this._role; // TODO: ad-hoc, see #83
|
|
120
120
|
const misoId = this._getMisoId();
|
|
121
|
-
const
|
|
121
|
+
const request = this._getRequestPayload();
|
|
122
122
|
// TODO: should trigger 'tracker' and let workflow translate to interactions
|
|
123
123
|
this._hub.trigger(fields.interaction(), (0, _utils.toInteraction)({
|
|
124
124
|
property,
|
|
125
125
|
misoId,
|
|
126
|
-
|
|
126
|
+
request
|
|
127
127
|
}, data));
|
|
128
128
|
}
|
|
129
129
|
_destroy() {
|
package/dist/cjs/actor/utils.js
CHANGED
|
@@ -17,7 +17,7 @@ function toInteraction(_ref, _ref2) {
|
|
|
17
17
|
let {
|
|
18
18
|
property,
|
|
19
19
|
misoId,
|
|
20
|
-
|
|
20
|
+
request
|
|
21
21
|
} = _ref;
|
|
22
22
|
let {
|
|
23
23
|
event,
|
|
@@ -30,20 +30,24 @@ function toInteraction(_ref, _ref2) {
|
|
|
30
30
|
api_ts = (0, _commons.uuidToTimestamp)(misoId);
|
|
31
31
|
} catch (e) {}
|
|
32
32
|
}
|
|
33
|
+
// TODO: ad-hoc
|
|
34
|
+
const question_source = request && request._meta && request._meta.question_source;
|
|
33
35
|
const isProductType = isProduct(property);
|
|
34
36
|
const product_ids = isProductType ? values.map(v => v.product_id).filter(v => v) : [];
|
|
35
37
|
const items = isProductType ? undefined : values.map(v => v.text || v);
|
|
36
|
-
|
|
38
|
+
const payload = (0, _commons.trimObj)({
|
|
37
39
|
type: event === 'viewable' ? 'viewable_impression' : event,
|
|
38
40
|
product_ids,
|
|
39
41
|
miso_id: misoId,
|
|
40
42
|
context: {
|
|
41
|
-
custom_context: (0, _commons.trimObj)(
|
|
43
|
+
custom_context: (0, _commons.trimObj)({
|
|
42
44
|
api_ts,
|
|
43
45
|
property,
|
|
44
46
|
items,
|
|
45
|
-
trigger: manual ? 'manual' : 'auto'
|
|
46
|
-
|
|
47
|
+
trigger: manual ? 'manual' : 'auto',
|
|
48
|
+
question_source
|
|
49
|
+
})
|
|
47
50
|
}
|
|
48
51
|
});
|
|
52
|
+
return payload;
|
|
49
53
|
}
|
package/dist/cjs/actor/view.js
CHANGED
|
@@ -116,6 +116,7 @@ class ViewActor {
|
|
|
116
116
|
session,
|
|
117
117
|
status,
|
|
118
118
|
ongoing,
|
|
119
|
+
request,
|
|
119
120
|
meta
|
|
120
121
|
} = data;
|
|
121
122
|
const active = session && session.active;
|
|
@@ -136,6 +137,7 @@ class ViewActor {
|
|
|
136
137
|
session,
|
|
137
138
|
status,
|
|
138
139
|
ongoing,
|
|
140
|
+
request,
|
|
139
141
|
meta
|
|
140
142
|
}, state), options);
|
|
141
143
|
};
|
|
@@ -155,6 +157,7 @@ class ViewActor {
|
|
|
155
157
|
session,
|
|
156
158
|
status,
|
|
157
159
|
ongoing,
|
|
160
|
+
request,
|
|
158
161
|
meta,
|
|
159
162
|
error
|
|
160
163
|
} = _ref;
|
|
@@ -168,6 +171,7 @@ class ViewActor {
|
|
|
168
171
|
session,
|
|
169
172
|
status,
|
|
170
173
|
ongoing,
|
|
174
|
+
request,
|
|
171
175
|
meta,
|
|
172
176
|
error
|
|
173
177
|
}));
|
|
@@ -178,14 +182,14 @@ class ViewActor {
|
|
|
178
182
|
silent
|
|
179
183
|
});
|
|
180
184
|
}
|
|
181
|
-
_sliceData(
|
|
182
|
-
|
|
185
|
+
_sliceData(_ref2) {
|
|
186
|
+
let {
|
|
183
187
|
value,
|
|
184
188
|
error,
|
|
185
189
|
status,
|
|
186
190
|
meta
|
|
187
|
-
} =
|
|
188
|
-
rest = _objectWithoutPropertiesLoose(
|
|
191
|
+
} = _ref2,
|
|
192
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
189
193
|
const sliced = Object.assign({
|
|
190
194
|
value: this.role === _constants.ROLE.ERROR ? error : value && value[this.role],
|
|
191
195
|
status,
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/workflow/ask.js
CHANGED
|
@@ -10,7 +10,7 @@ var _options = require("./options.js");
|
|
|
10
10
|
var _index = require("../actor/index.js");
|
|
11
11
|
var _constants = require("../constants.js");
|
|
12
12
|
var _index2 = require("../layout/index.js");
|
|
13
|
-
const _excluded = ["q", "
|
|
13
|
+
const _excluded = ["q", "qs"];
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
16
|
const DEFAULT_API_OPTIONS = Object.freeze({
|
|
@@ -118,7 +118,7 @@ class Ask extends _base.default {
|
|
|
118
118
|
} = this._autoQuery = options;
|
|
119
119
|
const searchParams = new URLSearchParams(window.location.search);
|
|
120
120
|
const q = searchParams.get('q');
|
|
121
|
-
const
|
|
121
|
+
const qs = searchParams.get('qs');
|
|
122
122
|
const {
|
|
123
123
|
layout
|
|
124
124
|
} = this._views.get(_constants.ROLE.QUERY);
|
|
@@ -133,7 +133,7 @@ class Ask extends _base.default {
|
|
|
133
133
|
if (q) {
|
|
134
134
|
this.query({
|
|
135
135
|
q,
|
|
136
|
-
|
|
136
|
+
qs
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -141,7 +141,7 @@ class Ask extends _base.default {
|
|
|
141
141
|
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
142
142
|
let {
|
|
143
143
|
q: question,
|
|
144
|
-
|
|
144
|
+
qs: questionSource
|
|
145
145
|
} = _ref,
|
|
146
146
|
payload = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
147
147
|
payload = Object.assign({}, payload, {
|
|
@@ -150,8 +150,8 @@ class Ask extends _base.default {
|
|
|
150
150
|
if (this.parentQuestionId) {
|
|
151
151
|
payload.parent_question_id = this.parentQuestionId;
|
|
152
152
|
}
|
|
153
|
-
if (
|
|
154
|
-
(payload._meta || (payload._meta = {})).question_source =
|
|
153
|
+
if (questionSource) {
|
|
154
|
+
(payload._meta || (payload._meta = {})).question_source = questionSource;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// clear question id from previous session
|
|
@@ -163,8 +163,8 @@ class Ask extends _base.default {
|
|
|
163
163
|
const {
|
|
164
164
|
session
|
|
165
165
|
} = this;
|
|
166
|
-
if (
|
|
167
|
-
session.meta.question_source =
|
|
166
|
+
if (questionSource) {
|
|
167
|
+
session.meta.question_source = questionSource;
|
|
168
168
|
}
|
|
169
169
|
this._hub.update(_index.fields.request(), (0, _options.mergeApiOptions)(this._options.resolved.api, {
|
|
170
170
|
payload,
|
|
@@ -317,7 +317,7 @@ class Ask extends _base.default {
|
|
|
317
317
|
questionId = parentQuestionId;
|
|
318
318
|
parentQuestionId = this.previous && this.previous.parentQuestionId;
|
|
319
319
|
custom_context.property = 'suggested_followup_questions';
|
|
320
|
-
|
|
320
|
+
custom_context.question_source = this.previous && this.previous.session.meta.question_source;
|
|
321
321
|
}
|
|
322
322
|
payload.context = Object.assign({}, context, {
|
|
323
323
|
custom_context: (0, _commons.trimObj)(Object.assign({
|
package/package.json
CHANGED
package/src/actor/data.js
CHANGED
|
@@ -47,6 +47,11 @@ export default class DataActor {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
const { session } = this._hub.states;
|
|
50
|
+
const { session: _, ...request } = event;
|
|
51
|
+
|
|
52
|
+
// emit response to update request
|
|
53
|
+
this._emitResponse({ session, request });
|
|
54
|
+
|
|
50
55
|
try {
|
|
51
56
|
const { signal } = this._ac || {};
|
|
52
57
|
const options = { ...event.options, signal };
|
|
@@ -59,14 +64,14 @@ export default class DataActor {
|
|
|
59
64
|
if (!this._isCurrentSession(session)) {
|
|
60
65
|
break;
|
|
61
66
|
}
|
|
62
|
-
this._emitResponse({ session, value });
|
|
67
|
+
this._emitResponse({ session, request, value });
|
|
63
68
|
}
|
|
64
69
|
} else {
|
|
65
|
-
this._emitResponseWithSessionCheck({ session, value: response });
|
|
70
|
+
this._emitResponseWithSessionCheck({ session, request, value: response });
|
|
66
71
|
}
|
|
67
72
|
} catch(error) {
|
|
68
73
|
this._error(error);
|
|
69
|
-
this._emitResponseWithSessionCheck({ session, error });
|
|
74
|
+
this._emitResponseWithSessionCheck({ session, request, error });
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
|
package/src/actor/feedback.js
CHANGED
|
@@ -15,16 +15,20 @@ export default class FeedbackActor {
|
|
|
15
15
|
if (!question_id) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
// TODO: ad-hoc
|
|
19
|
+
const { request } = data || {};
|
|
20
|
+
const { payload } = request || {};
|
|
21
|
+
const question_source = payload && payload._meta && payload._meta.question_source;
|
|
22
|
+
this._hub.trigger(fields.interaction(), this._buildInteraction(state, { question_source }));
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
_buildInteraction(
|
|
25
|
+
_buildInteraction({ value, unselected }, { question_source }) {
|
|
22
26
|
return {
|
|
23
27
|
type: 'feedback',
|
|
24
28
|
context: {
|
|
25
29
|
custom_context: {
|
|
26
30
|
result_type: 'answer',
|
|
27
|
-
|
|
31
|
+
question_source,
|
|
28
32
|
value: unselected ? 'unselected' : value,
|
|
29
33
|
},
|
|
30
34
|
},
|
package/src/actor/tracker.js
CHANGED
|
@@ -101,9 +101,9 @@ export default class Tracker {
|
|
|
101
101
|
return (state && state.meta && state.meta.miso_id) || (this._element && this._element.getAttribute('miso-id')) || undefined;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
const {
|
|
106
|
-
return
|
|
104
|
+
_getRequestPayload() {
|
|
105
|
+
const { request } = this._getViewState() || {};
|
|
106
|
+
return request && request.payload;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
getState(productId) {
|
|
@@ -113,9 +113,9 @@ export default class Tracker {
|
|
|
113
113
|
_handleEvent(data) {
|
|
114
114
|
const property = this._role === 'results' ? 'products' : this._role; // TODO: ad-hoc, see #83
|
|
115
115
|
const misoId = this._getMisoId();
|
|
116
|
-
const
|
|
116
|
+
const request = this._getRequestPayload();
|
|
117
117
|
// TODO: should trigger 'tracker' and let workflow translate to interactions
|
|
118
|
-
this._hub.trigger(fields.interaction(), toInteraction({ property, misoId,
|
|
118
|
+
this._hub.trigger(fields.interaction(), toInteraction({ property, misoId, request }, data));
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
_destroy() {
|
package/src/actor/utils.js
CHANGED
|
@@ -12,17 +12,19 @@ export function isProduct(property) {
|
|
|
12
12
|
return PRODUCT_TYPED_PROPERTIES.has(property);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function toInteraction({ property, misoId,
|
|
15
|
+
export function toInteraction({ property, misoId, request }, { event, values, manual }) {
|
|
16
16
|
let api_ts;
|
|
17
17
|
if (misoId) {
|
|
18
18
|
try {
|
|
19
19
|
api_ts = uuidToTimestamp(misoId);
|
|
20
20
|
} catch (e) {}
|
|
21
21
|
}
|
|
22
|
+
// TODO: ad-hoc
|
|
23
|
+
const question_source = request && request._meta && request._meta.question_source;
|
|
22
24
|
const isProductType = isProduct(property);
|
|
23
25
|
const product_ids = isProductType ? values.map(v => v.product_id).filter(v => v) : [];
|
|
24
26
|
const items = isProductType ? undefined : values.map(v => v.text || v);
|
|
25
|
-
|
|
27
|
+
const payload = trimObj({
|
|
26
28
|
type: event === 'viewable' ? 'viewable_impression' : event,
|
|
27
29
|
product_ids,
|
|
28
30
|
miso_id: misoId,
|
|
@@ -32,8 +34,9 @@ export function toInteraction({ property, misoId, meta }, { event, values, manua
|
|
|
32
34
|
property,
|
|
33
35
|
items,
|
|
34
36
|
trigger: manual ? 'manual' : 'auto',
|
|
35
|
-
|
|
37
|
+
question_source,
|
|
36
38
|
}),
|
|
37
39
|
},
|
|
38
40
|
});
|
|
41
|
+
return payload;
|
|
39
42
|
}
|
package/src/actor/view.js
CHANGED
|
@@ -102,7 +102,7 @@ export default class ViewActor {
|
|
|
102
102
|
this._data = data = this._sliceData(data || this._views._getData());
|
|
103
103
|
|
|
104
104
|
// protocol: no reaction until session starts
|
|
105
|
-
const { session, status, ongoing, meta } = data;
|
|
105
|
+
const { session, status, ongoing, request, meta } = data;
|
|
106
106
|
const active = session && session.active;
|
|
107
107
|
if (!force && !active) {
|
|
108
108
|
return;
|
|
@@ -115,7 +115,7 @@ export default class ViewActor {
|
|
|
115
115
|
|
|
116
116
|
// render
|
|
117
117
|
const notifyUpdate = (state = {}, options) => {
|
|
118
|
-
state !== false && this.updateState({ session, status, ongoing, meta, ...state }, options);
|
|
118
|
+
state !== false && this.updateState({ session, status, ongoing, request, meta, ...state }, options);
|
|
119
119
|
};
|
|
120
120
|
try {
|
|
121
121
|
await this._layout.render(element, data, { notifyUpdate });
|
|
@@ -125,17 +125,16 @@ export default class ViewActor {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
updateState({ session, status, ongoing, meta, error }, { silent = false } = {}) {
|
|
128
|
+
updateState({ session, status, ongoing, request, meta, error }, { silent = false } = {}) {
|
|
129
129
|
if (error) {
|
|
130
130
|
status = STATUS.ERRONEOUS;
|
|
131
131
|
}
|
|
132
|
-
const state = this._state = Object.freeze(trimObj({ session, status, ongoing, meta, error }));
|
|
132
|
+
const state = this._state = Object.freeze(trimObj({ session, status, ongoing, request, meta, error }));
|
|
133
133
|
const { role } = this;
|
|
134
134
|
this.hub.update(fields.view(role), state, { silent });
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
_sliceData(
|
|
138
|
-
const { value, error, status, meta, ...rest } = data;
|
|
137
|
+
_sliceData({ value, error, status, meta, ...rest }) {
|
|
139
138
|
const sliced = {
|
|
140
139
|
value: this.role === ROLE.ERROR ? error : (value && value[this.role]),
|
|
141
140
|
status,
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.9.5-beta.
|
|
1
|
+
export default '1.9.5-beta.2';
|
package/src/workflow/ask.js
CHANGED
|
@@ -101,7 +101,7 @@ export default class Ask extends Workflow {
|
|
|
101
101
|
const { setValue = true, focus = true } = this._autoQuery = options;
|
|
102
102
|
const searchParams = new URLSearchParams(window.location.search);
|
|
103
103
|
const q = searchParams.get('q');
|
|
104
|
-
const
|
|
104
|
+
const qs = searchParams.get('qs');
|
|
105
105
|
const { layout } = this._views.get(ROLE.QUERY);
|
|
106
106
|
if (layout) {
|
|
107
107
|
if (q && setValue) {
|
|
@@ -112,18 +112,18 @@ export default class Ask extends Workflow {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
if (q) {
|
|
115
|
-
this.query({ q,
|
|
115
|
+
this.query({ q, qs });
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
query({ q: question,
|
|
119
|
+
query({ q: question, qs: questionSource, ...payload } = {}) {
|
|
120
120
|
payload = { ...payload, question };
|
|
121
121
|
|
|
122
122
|
if (this.parentQuestionId) {
|
|
123
123
|
payload.parent_question_id = this.parentQuestionId;
|
|
124
124
|
}
|
|
125
|
-
if (
|
|
126
|
-
(payload._meta || (payload._meta = {})).question_source =
|
|
125
|
+
if (questionSource) {
|
|
126
|
+
(payload._meta || (payload._meta = {})).question_source = questionSource;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// clear question id from previous session
|
|
@@ -135,8 +135,8 @@ export default class Ask extends Workflow {
|
|
|
135
135
|
this.restart();
|
|
136
136
|
|
|
137
137
|
const { session } = this;
|
|
138
|
-
if (
|
|
139
|
-
session.meta.question_source =
|
|
138
|
+
if (questionSource) {
|
|
139
|
+
session.meta.question_source = questionSource;
|
|
140
140
|
}
|
|
141
141
|
this._hub.update(fields.request(), mergeApiOptions(this._options.resolved.api, { payload, session }));
|
|
142
142
|
|
|
@@ -251,7 +251,7 @@ export default class Ask extends Workflow {
|
|
|
251
251
|
questionId = parentQuestionId;
|
|
252
252
|
parentQuestionId = this.previous && this.previous.parentQuestionId;
|
|
253
253
|
custom_context.property = 'suggested_followup_questions';
|
|
254
|
-
|
|
254
|
+
custom_context.question_source = this.previous && this.previous.session.meta.question_source;
|
|
255
255
|
}
|
|
256
256
|
payload.context = {
|
|
257
257
|
...context,
|
package/src/workflow/explore.js
CHANGED
|
@@ -121,7 +121,7 @@ export default class Explore extends Workflow {
|
|
|
121
121
|
}
|
|
122
122
|
const url = this._linkFn(text);
|
|
123
123
|
if (this._productId) {
|
|
124
|
-
return `${url}&
|
|
124
|
+
return `${url}&qs=${encodeURIComponent(this._productId)}`;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|