typeahead-client-logger 0.0.1-security → 2.532.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.
Potentially problematic release.
This version of typeahead-client-logger might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +23 -3
- package/build.js +128 -0
- package/dist/ClientMetricsLogger.js +69 -0
- package/dist/EssClientLogger.js +127 -0
- package/dist/EssSelectedSuggestionLogger.js +372 -0
- package/dist/Experiments.js +52 -0
- package/dist/InteractionMetrics.js +73 -0
- package/dist/PerformanceMetrics.js +212 -0
- package/dist/RecommendationEvent.js +122 -0
- package/dist/SystemEvent.js +31 -0
- package/dist/TypeaheadEvent.js +345 -0
- package/dist/TypeaheadEventLogger.js +429 -0
- package/dist/index.js +15 -0
- package/dist/utils/Optional.js +45 -0
- package/dist/utils/Utils.js +88 -0
- package/package.json +19 -3
@@ -0,0 +1,372 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
4
|
+
if (!m) return o;
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
6
|
+
try {
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
8
|
+
}
|
9
|
+
catch (error) { e = { error: error }; }
|
10
|
+
finally {
|
11
|
+
try {
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
13
|
+
}
|
14
|
+
finally { if (e) throw e.error; }
|
15
|
+
}
|
16
|
+
return ar;
|
17
|
+
};
|
18
|
+
var __spread = (this && this.__spread) || function () {
|
19
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
20
|
+
return ar;
|
21
|
+
};
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
23
|
+
var Optional_1 = require("./utils/Optional");
|
24
|
+
var SuggestionType;
|
25
|
+
(function (SuggestionType) {
|
26
|
+
SuggestionType[SuggestionType["ORIGIN"] = 0] = "ORIGIN";
|
27
|
+
SuggestionType[SuggestionType["DEST"] = 1] = "DEST";
|
28
|
+
})(SuggestionType = exports.SuggestionType || (exports.SuggestionType = {}));
|
29
|
+
var LogType;
|
30
|
+
(function (LogType) {
|
31
|
+
LogType["TYPEAHEAD_BLUR"] = "typeahead-blur";
|
32
|
+
LogType["WIZARD_SUBMIT"] = "wizard-submit";
|
33
|
+
})(LogType = exports.LogType || (exports.LogType = {}));
|
34
|
+
var EssSelectedSuggestionLogger = /** @class */ (function () {
|
35
|
+
// 1 - Create logger
|
36
|
+
function EssSelectedSuggestionLogger(analytics, prefill) {
|
37
|
+
this.analytics = analytics;
|
38
|
+
this.sessionStore = {
|
39
|
+
prefill: prefill,
|
40
|
+
};
|
41
|
+
}
|
42
|
+
// 2 - initialize logger.
|
43
|
+
EssSelectedSuggestionLogger.prototype.initLogger = function (metadata) {
|
44
|
+
var client = metadata.client, packageType = metadata.packageType, lob = metadata.lob, locale = metadata.locale, siteId = metadata.siteId, personalize = metadata.personalize;
|
45
|
+
this.sessionStore.metadata = { client: client, packageType: packageType, lob: lob, locale: locale, siteId: siteId, personalize: personalize };
|
46
|
+
};
|
47
|
+
EssSelectedSuggestionLogger.prototype.logTypeaheadResponse = function (response) {
|
48
|
+
this.sessionStore.response = response;
|
49
|
+
this.sessionStore.mostRecentSelectedSuggestion = undefined;
|
50
|
+
};
|
51
|
+
EssSelectedSuggestionLogger.prototype.setPrefillText = function (prefill) {
|
52
|
+
this.sessionStore.prefill = prefill;
|
53
|
+
};
|
54
|
+
EssSelectedSuggestionLogger.prototype.logSuggestionSelected = function (selected) {
|
55
|
+
if (Optional_1.Optional.ofNullable(selected).isPresent()
|
56
|
+
&& this.sessionStore.response
|
57
|
+
&& this.sessionStore.response.sr
|
58
|
+
&& this.sessionStore.response.sr.length > 0) {
|
59
|
+
if (Optional_1.Optional.ofNullable(selected.dest).orElse(true)) {
|
60
|
+
this.sessionStore.destSelectedSuggestion = this.sessionStore.response.sr[selected.index - 1];
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
this.sessionStore.originSelectedSuggestion = this.sessionStore.response.sr[selected.index - 1];
|
64
|
+
}
|
65
|
+
this.sessionStore.mostRecentSelectedSuggestion = this.sessionStore.response.sr[selected.index - 1];
|
66
|
+
}
|
67
|
+
};
|
68
|
+
/* the following two methods to be used by blossom-ui / buttercup / any other client who uses typeahead*/
|
69
|
+
EssSelectedSuggestionLogger.prototype.logTypeaheadBlurEvent = function () {
|
70
|
+
this.logSessionEnd(LogType.TYPEAHEAD_BLUR);
|
71
|
+
};
|
72
|
+
EssSelectedSuggestionLogger.prototype.logWizardSubmitEvent = function () {
|
73
|
+
this.logSessionEnd(LogType.WIZARD_SUBMIT);
|
74
|
+
this.sessionStore.mostRecentSelectedSuggestion = undefined;
|
75
|
+
this.sessionStore.response = undefined;
|
76
|
+
this.sessionStore.originSelectedSuggestion = undefined;
|
77
|
+
this.sessionStore.destSelectedSuggestion = undefined;
|
78
|
+
};
|
79
|
+
EssSelectedSuggestionLogger.prototype.logSessionEnd = function (logType) {
|
80
|
+
if (typeof this.analytics === "object" &&
|
81
|
+
typeof this.analytics.trackEvent === "function") {
|
82
|
+
try {
|
83
|
+
var uisPrimeMessages = this.buildUisPrimeMessages();
|
84
|
+
this.analytics.trackEvent(this.getReferrerId(), logType, this.analytics.omnitureData, null, true, uisPrimeMessages);
|
85
|
+
}
|
86
|
+
catch (e) {
|
87
|
+
// do nothing
|
88
|
+
}
|
89
|
+
}
|
90
|
+
};
|
91
|
+
EssSelectedSuggestionLogger.prototype.getReferrerId = function () {
|
92
|
+
var metadata = this.sessionStore.metadata || {};
|
93
|
+
var parts = [];
|
94
|
+
parts.push(this.getLaunchView(metadata.client || ""));
|
95
|
+
parts.push(this.getWizard(metadata.client || ""));
|
96
|
+
parts.push(metadata.lob || "Unknown");
|
97
|
+
parts.push(this.getShortLob(metadata.lob || "", metadata.packageType));
|
98
|
+
parts.push(metadata.locale || "-");
|
99
|
+
parts.push(metadata.siteId || "-");
|
100
|
+
parts.push(this.getTypeaheadTrigger());
|
101
|
+
parts.push.apply(parts, __spread(this.getInstrumentationValue((metadata.lob || "").toLowerCase())));
|
102
|
+
return parts.join("|");
|
103
|
+
};
|
104
|
+
EssSelectedSuggestionLogger.prototype.getLaunchView = function (clientId) {
|
105
|
+
clientId = clientId.toLowerCase();
|
106
|
+
if (clientId.indexOf("home") > -1) {
|
107
|
+
return "Home";
|
108
|
+
}
|
109
|
+
if (clientId.indexOf("flight") > -1) {
|
110
|
+
return "FLT";
|
111
|
+
}
|
112
|
+
if (clientId.indexOf("hotels.search") > -1) {
|
113
|
+
// for hotels search page bernie appends "HOT.SR" so removing here
|
114
|
+
return "";
|
115
|
+
}
|
116
|
+
if (clientId.indexOf("hotel") > -1) {
|
117
|
+
return "HTL";
|
118
|
+
}
|
119
|
+
if (clientId.indexOf("vacationrental") > -1) {
|
120
|
+
return "VR";
|
121
|
+
}
|
122
|
+
if (clientId.indexOf("pack") > -1) {
|
123
|
+
return "PKG";
|
124
|
+
}
|
125
|
+
if (clientId.indexOf("car") > -1) {
|
126
|
+
return "CAR";
|
127
|
+
}
|
128
|
+
if (clientId.indexOf("cru") > -1) {
|
129
|
+
return "CRU";
|
130
|
+
}
|
131
|
+
if (clientId.indexOf("lx") > -1) {
|
132
|
+
return "LX";
|
133
|
+
}
|
134
|
+
if (clientId.indexOf("rail") > -1) {
|
135
|
+
return "RAIL";
|
136
|
+
}
|
137
|
+
if (clientId.indexOf("open") > -1) {
|
138
|
+
return "OPEN";
|
139
|
+
}
|
140
|
+
return clientId;
|
141
|
+
};
|
142
|
+
EssSelectedSuggestionLogger.prototype.buildUisPrimeMessages = function () {
|
143
|
+
return __spread(this.getTrackingDataEvents(), [
|
144
|
+
this.getSelectedSuggestionEvents(),
|
145
|
+
]);
|
146
|
+
};
|
147
|
+
EssSelectedSuggestionLogger.prototype.getSelectedSuggestionData = function (suggestion, searchField) {
|
148
|
+
var alternateName = searchField === "origin" ? "OriginNotApplicable" :
|
149
|
+
((this.sessionStore.response || {}).q ? (this.sessionStore.response || {}).q :
|
150
|
+
this.sessionStore.prefill ? this.sessionStore.prefill : "TANoneSelected");
|
151
|
+
var query = (this.sessionStore.response || { q: "" }).q;
|
152
|
+
var userTypedQuery = query === this.sessionStore.prefill ? "" : query;
|
153
|
+
var lastSearchName = suggestion && suggestion.regionNames && suggestion.regionNames.lastSearchName
|
154
|
+
|| alternateName;
|
155
|
+
return {
|
156
|
+
essRequestId: (this.sessionStore.response || { rid: "-" }).rid,
|
157
|
+
lastSearchName: lastSearchName,
|
158
|
+
relation: suggestion && suggestion.hierarchyInfo
|
159
|
+
&& suggestion.hierarchyInfo.relation && suggestion.hierarchyInfo.relation[0] || "-",
|
160
|
+
searchField: searchField,
|
161
|
+
sourceName: suggestion
|
162
|
+
? suggestion.essId
|
163
|
+
? suggestion.essId.sourceName
|
164
|
+
: suggestion.sourceName
|
165
|
+
? suggestion.sourceName
|
166
|
+
: "UNKNOWN"
|
167
|
+
: "UNKNOWN",
|
168
|
+
stringSourceId: (suggestion && suggestion.essId && suggestion.essId.sourceId || -1).toString(),
|
169
|
+
suggestionType: suggestion ? suggestion.type : "UNKNOWN",
|
170
|
+
userHistory: suggestion ? suggestion.category === "USERHISTORY" : false,
|
171
|
+
userTypedQuery: userTypedQuery,
|
172
|
+
};
|
173
|
+
};
|
174
|
+
EssSelectedSuggestionLogger.prototype.getSelectedSuggestionEvents = function () {
|
175
|
+
var originSuggestionData = this.getSelectedSuggestionData(this.sessionStore.originSelectedSuggestion, "origin");
|
176
|
+
var destSuggestionData = this.getSelectedSuggestionData(this.sessionStore.destSelectedSuggestion, "dest");
|
177
|
+
return Object.freeze({
|
178
|
+
messageContent: {
|
179
|
+
selectedSuggestions: [originSuggestionData, destSuggestionData],
|
180
|
+
},
|
181
|
+
schemaName: "allSelectedSuggestions",
|
182
|
+
});
|
183
|
+
};
|
184
|
+
EssSelectedSuggestionLogger.prototype.getTrackingDataEvents = function () {
|
185
|
+
var searchTerm = (this.sessionStore.response || { q: "" }).q;
|
186
|
+
var numOfCharsTyped = searchTerm ? searchTerm === this.sessionStore.prefill ? 0 : searchTerm.length : 0;
|
187
|
+
var trackingData = [];
|
188
|
+
if (this.sessionStore.mostRecentSelectedSuggestion) {
|
189
|
+
var index = -1;
|
190
|
+
if (this.sessionStore.mostRecentSelectedSuggestion
|
191
|
+
&& typeof this.sessionStore.mostRecentSelectedSuggestion.index !== "undefined") {
|
192
|
+
index = parseInt(this.sessionStore.mostRecentSelectedSuggestion.index, 10) + 1;
|
193
|
+
}
|
194
|
+
/* to get the position of selected suggestion [event44] */
|
195
|
+
trackingData.push(Object.freeze({
|
196
|
+
messageContent: {
|
197
|
+
name: "TypeaheadSelectionDepth",
|
198
|
+
value: index,
|
199
|
+
},
|
200
|
+
schemaName: "events",
|
201
|
+
}));
|
202
|
+
}
|
203
|
+
if (this.sessionStore.response) {
|
204
|
+
/* to see if user interacted with typeahead or not [event45] */
|
205
|
+
trackingData.push(Object.freeze({
|
206
|
+
messageContent: {
|
207
|
+
name: "TypeaheadSearch",
|
208
|
+
value: 0,
|
209
|
+
},
|
210
|
+
schemaName: "events",
|
211
|
+
}));
|
212
|
+
}
|
213
|
+
/* to get the number of characters typed by the user [event46] */
|
214
|
+
trackingData.push(Object.freeze({
|
215
|
+
messageContent: {
|
216
|
+
name: "TypeaheadCharactersTyped",
|
217
|
+
value: numOfCharsTyped,
|
218
|
+
},
|
219
|
+
schemaName: "events",
|
220
|
+
}));
|
221
|
+
return trackingData;
|
222
|
+
};
|
223
|
+
EssSelectedSuggestionLogger.prototype.getTypeaheadTrigger = function () {
|
224
|
+
var trigger = "";
|
225
|
+
if (Optional_1.Optional.ofNullable(this.sessionStore.response).isNotPresent()
|
226
|
+
&& Optional_1.Optional.ofNullable(this.sessionStore.prefill).isPresent()) {
|
227
|
+
return "TANoShow.TAPrevSearch";
|
228
|
+
}
|
229
|
+
if (this.sessionStore.response
|
230
|
+
&& this.sessionStore.response.sr
|
231
|
+
&& this.sessionStore.response.sr.length > 0) {
|
232
|
+
trigger = "TAShow";
|
233
|
+
}
|
234
|
+
else {
|
235
|
+
trigger = "TANoShow.TAPrevSearch";
|
236
|
+
return trigger;
|
237
|
+
}
|
238
|
+
var searchQuery = (this.sessionStore.response || { q: "" }).q;
|
239
|
+
var userTyped = this.sessionStore.prefill !== searchQuery && searchQuery !== "";
|
240
|
+
if (userTyped) {
|
241
|
+
if (this.sessionStore.mostRecentSelectedSuggestion) {
|
242
|
+
trigger += ".TASelection";
|
243
|
+
}
|
244
|
+
else {
|
245
|
+
trigger += ".TANoSelection";
|
246
|
+
}
|
247
|
+
return trigger;
|
248
|
+
}
|
249
|
+
else {
|
250
|
+
// history results ::: else -> last search results
|
251
|
+
if (this.sessionStore.response && this.sessionStore.response.q === "") {
|
252
|
+
if (this.sessionStore.mostRecentSelectedSuggestion) {
|
253
|
+
trigger += ".TAFocus";
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
trigger += ".TANoSelection";
|
257
|
+
}
|
258
|
+
}
|
259
|
+
else {
|
260
|
+
if (this.sessionStore.mostRecentSelectedSuggestion) {
|
261
|
+
trigger += ".TASelection";
|
262
|
+
}
|
263
|
+
else {
|
264
|
+
trigger += ".TANoSelection";
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
return trigger;
|
269
|
+
};
|
270
|
+
EssSelectedSuggestionLogger.prototype.getInstrumentationValue = function (lob) {
|
271
|
+
var result = [];
|
272
|
+
var index = "-";
|
273
|
+
if (this.sessionStore.mostRecentSelectedSuggestion
|
274
|
+
&& typeof this.sessionStore.mostRecentSelectedSuggestion.index !== "undefined") {
|
275
|
+
index = (parseInt(this.sessionStore.mostRecentSelectedSuggestion.index, 10) + 1).toString();
|
276
|
+
}
|
277
|
+
var length = ((this.sessionStore.response || {}).sr || []).length;
|
278
|
+
if (lob === "flights" || lob === "hotels") {
|
279
|
+
// Change logic when children present.
|
280
|
+
result.push(this.getHierarchyType(this.sessionStore.mostRecentSelectedSuggestion) + "#" + index);
|
281
|
+
}
|
282
|
+
else {
|
283
|
+
result.push("L#" + index);
|
284
|
+
}
|
285
|
+
result.push("ESS#" + length);
|
286
|
+
result.push("UH#" + this.getNumberOfUserHistorySuggestions());
|
287
|
+
return result;
|
288
|
+
};
|
289
|
+
EssSelectedSuggestionLogger.prototype.getNumberOfUserHistorySuggestions = function () {
|
290
|
+
if (this.sessionStore.response
|
291
|
+
&& this.sessionStore.response.sr
|
292
|
+
&& this.sessionStore.metadata
|
293
|
+
&& Optional_1.Optional.ofNullable(this.sessionStore.metadata.personalize).isPresent()
|
294
|
+
&& this.sessionStore.metadata.personalize) {
|
295
|
+
var suggestions = this.sessionStore.response.sr;
|
296
|
+
return suggestions.filter(function (suggestion) { return suggestion.category === "USERHISTORY"; }).length.toString();
|
297
|
+
}
|
298
|
+
return "-";
|
299
|
+
};
|
300
|
+
EssSelectedSuggestionLogger.prototype.getHierarchyType = function (suggestion) {
|
301
|
+
if (Optional_1.Optional.ofNullable(suggestion).isPresent()) {
|
302
|
+
if (this.isChild(suggestion)) {
|
303
|
+
return "CL";
|
304
|
+
}
|
305
|
+
if (this.isParent(suggestion)) {
|
306
|
+
return "PL";
|
307
|
+
}
|
308
|
+
}
|
309
|
+
return "DL";
|
310
|
+
};
|
311
|
+
EssSelectedSuggestionLogger.prototype.isParent = function (suggestion) {
|
312
|
+
if (Optional_1.Optional.ofNullable(suggestion).isNotPresent()
|
313
|
+
|| Optional_1.Optional.ofNullable(this.sessionStore.response).isNotPresent()) {
|
314
|
+
return false;
|
315
|
+
}
|
316
|
+
var index = parseInt(Optional_1.Optional.ofNullable(suggestion.index).orElse("-1"), 10);
|
317
|
+
if (index < 0 || (Optional_1.Optional.ofNullable(this.sessionStore.response.sr).orElse([])).length <= index + 1) {
|
318
|
+
return false;
|
319
|
+
}
|
320
|
+
return this.isChild(this.sessionStore.response.sr[index + 1]);
|
321
|
+
};
|
322
|
+
EssSelectedSuggestionLogger.prototype.isChild = function (suggestion) {
|
323
|
+
if (Optional_1.Optional.ofNullable(suggestion).isNotPresent()) {
|
324
|
+
return false;
|
325
|
+
}
|
326
|
+
var relation = suggestion && suggestion.hierarchyInfo
|
327
|
+
&& suggestion.hierarchyInfo.relation || [];
|
328
|
+
if (relation.length === 0) {
|
329
|
+
return false;
|
330
|
+
}
|
331
|
+
if (relation.indexOf("child") >= 0) {
|
332
|
+
return true;
|
333
|
+
}
|
334
|
+
return false;
|
335
|
+
};
|
336
|
+
// TODO - add flights after blossom sends the flight type (based on that)
|
337
|
+
EssSelectedSuggestionLogger.prototype.getShortLob = function (lob, packageType) {
|
338
|
+
switch (lob.toLowerCase()) {
|
339
|
+
case "hotels":
|
340
|
+
return "H";
|
341
|
+
case "package":
|
342
|
+
if (packageType) {
|
343
|
+
return packageType.toUpperCase();
|
344
|
+
}
|
345
|
+
else {
|
346
|
+
return "-";
|
347
|
+
}
|
348
|
+
case "activity":
|
349
|
+
return "LX";
|
350
|
+
case "cruise":
|
351
|
+
return "CR";
|
352
|
+
case "car":
|
353
|
+
return "C";
|
354
|
+
case "opensearch":
|
355
|
+
return "OS";
|
356
|
+
default:
|
357
|
+
return "-";
|
358
|
+
}
|
359
|
+
};
|
360
|
+
EssSelectedSuggestionLogger.prototype.getWizard = function (client) {
|
361
|
+
switch (client) {
|
362
|
+
case "Hotels.Search":
|
363
|
+
case "Flights.Search":
|
364
|
+
return "UpdateSearch";
|
365
|
+
default:
|
366
|
+
return "CoreWzd";
|
367
|
+
}
|
368
|
+
};
|
369
|
+
return EssSelectedSuggestionLogger;
|
370
|
+
}());
|
371
|
+
exports.EssSelectedSuggestionLogger = EssSelectedSuggestionLogger;
|
372
|
+
//# sourceMappingURL=EssSelectedSuggestionLogger.js.map
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Experiments = exports.Experiment = void 0;
|
4
|
+
// Add client side typeahead experiment info to the below enum for logging purpose
|
5
|
+
var Experiment;
|
6
|
+
(function (Experiment) {
|
7
|
+
Experiment[Experiment["EGTA_BEX_ML_V0"] = 36094] = "EGTA_BEX_ML_V0";
|
8
|
+
Experiment[Experiment["EGTA_uTA_Demo"] = 32216] = "EGTA_uTA_Demo";
|
9
|
+
Experiment[Experiment["ESS_Two_Line_Display"] = 33686] = "ESS_Two_Line_Display";
|
10
|
+
Experiment[Experiment["PWA_ESS_Feedback_Loop_Enable"] = 31052] = "PWA_ESS_Feedback_Loop_Enable";
|
11
|
+
Experiment[Experiment["EGTA_Rollout_Feature_Gate_for_Hotel_Property_Name_Filter"] = 37339] = "EGTA_Rollout_Feature_Gate_for_Hotel_Property_Name_Filter";
|
12
|
+
Experiment[Experiment["BEX_Driveable_destination_Web"] = 41955] = "BEX_Driveable_destination_Web";
|
13
|
+
})(Experiment = exports.Experiment || (exports.Experiment = {}));
|
14
|
+
var Experiments = /** @class */ (function () {
|
15
|
+
function Experiments() {
|
16
|
+
}
|
17
|
+
Experiments.init = function (experiments) {
|
18
|
+
var _this = this;
|
19
|
+
if (experiments) {
|
20
|
+
Object.keys(Experiment).forEach(function (name) {
|
21
|
+
var value = experiments[name];
|
22
|
+
var bucket;
|
23
|
+
if ("number" === typeof value) { // Blossom-flex
|
24
|
+
bucket = value;
|
25
|
+
}
|
26
|
+
else if (value && "number" === typeof value.bucket) { // Shopping-pwa
|
27
|
+
bucket = value.bucket;
|
28
|
+
}
|
29
|
+
if (bucket !== undefined) {
|
30
|
+
var id = Experiment[name];
|
31
|
+
_this.experimentMap[id] = { id: id, name: name, bucket: bucket };
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}
|
35
|
+
};
|
36
|
+
Experiments.isBucketed = function (experiment, bucket) {
|
37
|
+
if (bucket === void 0) { bucket = 1; }
|
38
|
+
return experiment in this.experimentMap && bucket === this.experimentMap[experiment].bucket;
|
39
|
+
};
|
40
|
+
Experiments.getClientVariants = function () {
|
41
|
+
var _this = this;
|
42
|
+
var variants = [];
|
43
|
+
Object.keys(this.experimentMap).forEach(function (key) {
|
44
|
+
variants.push(key + "." + _this.experimentMap[key].bucket);
|
45
|
+
});
|
46
|
+
return variants.join("|");
|
47
|
+
};
|
48
|
+
Experiments.experimentMap = {};
|
49
|
+
return Experiments;
|
50
|
+
}());
|
51
|
+
exports.Experiments = Experiments;
|
52
|
+
//# sourceMappingURL=Experiments.js.map
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
+
exports.InteractionMetrics = void 0;
|
15
|
+
var Experiments_1 = require("./Experiments");
|
16
|
+
var InteractionMetrics = /** @class */ (function () {
|
17
|
+
function InteractionMetrics() {
|
18
|
+
this.query = "";
|
19
|
+
this.response = undefined;
|
20
|
+
this.mostRecentSelectedSuggestion = undefined;
|
21
|
+
}
|
22
|
+
InteractionMetrics.getSuggestionTypes = function (s) {
|
23
|
+
if (s && s.length > 0) {
|
24
|
+
return s.map(function (item) { return (item.category === "GOOGLEMAPS") ? "GPA" : item.type; }).join(",");
|
25
|
+
}
|
26
|
+
return undefined;
|
27
|
+
};
|
28
|
+
InteractionMetrics.getSuggestionIds = function (s) {
|
29
|
+
if (s && s.length > 0) {
|
30
|
+
return s.map(function (item) { return (item.category === "GOOGLEMAPS") ? item.sourceName + ":" + item.sourceId :
|
31
|
+
(item.essId ? item.essId.sourceName + ":" + item.essId.sourceId : "-:-"); }).join(",");
|
32
|
+
}
|
33
|
+
return undefined;
|
34
|
+
};
|
35
|
+
InteractionMetrics.prototype.logTypeaheadOpen = function (prefill) {
|
36
|
+
this.interactionStart = Date.now();
|
37
|
+
this.prefill = prefill;
|
38
|
+
};
|
39
|
+
InteractionMetrics.prototype.logTypeaheadRequest = function (query) {
|
40
|
+
this.query = query || "";
|
41
|
+
this.mostRecentSelectedSuggestion = undefined;
|
42
|
+
this.response = undefined;
|
43
|
+
};
|
44
|
+
InteractionMetrics.prototype.logSuggestionShown = function (response) {
|
45
|
+
this.response = response;
|
46
|
+
};
|
47
|
+
InteractionMetrics.prototype.logTypeaheadSelection = function (selection) {
|
48
|
+
this.mostRecentSelectedSuggestion = this.response.sr[selection.index - 1];
|
49
|
+
};
|
50
|
+
InteractionMetrics.prototype.logTypeaheadEventMessage = function (m) {
|
51
|
+
this.selectionTypeaheadEventMessage = m;
|
52
|
+
};
|
53
|
+
InteractionMetrics.prototype.getMetrics = function (metadata) {
|
54
|
+
var userTypedQuery = this.query === this.prefill ? "" : this.query;
|
55
|
+
var isAddrAutocomplete = this.response && this.response.sr && this.response.sr.length > 0
|
56
|
+
&& this.response.sr[0].category === "GOOGLEMAPS";
|
57
|
+
var deviceType = metadata.getDevice && "function" === typeof metadata.getDevice ?
|
58
|
+
metadata.getDevice(window.navigator.useragent) : undefined;
|
59
|
+
var metric = __assign({ contentFlavor: "uitk", deviceType: deviceType, inputLength: userTypedQuery ? userTypedQuery.length : 0, interactionTime: this.interactionStart ? (Date.now() - this.interactionStart) : undefined, isAddrAutocomplete: isAddrAutocomplete, lob: metadata.lob, locale: metadata.locale, pageId: metadata.client, pointOfSale: window.location.hostname, selectionDepth: this.getSelectionDepth(), siteId: metadata.siteId + "", suggestionIds: this.response && InteractionMetrics.getSuggestionIds(this.response.sr), suggestionSelected: !!this.mostRecentSelectedSuggestion, suggestionShown: !!(this.response && this.response.sr && this.response.sr.length > 0), suggestionTypes: this.response && InteractionMetrics.getSuggestionTypes(this.response.sr), textInputElementId: metadata.inputId, timestamp: Date.now(), type: "TypeaheadInteraction", userAgent: window.navigator.userAgent, userTypedQuery: userTypedQuery, variants: [this.response && this.response.activeABTests, Experiments_1.Experiments.getClientVariants()]
|
60
|
+
.filter(Boolean).join("|"), zeroResults: this.response && this.response.sr && this.response.sr.length === 0 }, this.selectionTypeaheadEventMessage);
|
61
|
+
return metric;
|
62
|
+
};
|
63
|
+
InteractionMetrics.prototype.getSelectionDepth = function () {
|
64
|
+
if (this.mostRecentSelectedSuggestion
|
65
|
+
&& typeof this.mostRecentSelectedSuggestion.index !== "undefined") {
|
66
|
+
return (parseInt(this.mostRecentSelectedSuggestion.index, 10) + 1).toString();
|
67
|
+
}
|
68
|
+
return "undefined";
|
69
|
+
};
|
70
|
+
return InteractionMetrics;
|
71
|
+
}());
|
72
|
+
exports.InteractionMetrics = InteractionMetrics;
|
73
|
+
//# sourceMappingURL=InteractionMetrics.js.map
|