@azzas/azzas-tracker-web 1.0.40 → 1.0.41
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/mod.vtex.global.js +1757 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1757 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _array_without_holes(arr) {
|
|
11
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
+
}
|
|
13
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
14
|
+
try {
|
|
15
|
+
var info = gen[key](arg);
|
|
16
|
+
var value = info.value;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
reject(error);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (info.done) {
|
|
22
|
+
resolve(value);
|
|
23
|
+
} else {
|
|
24
|
+
Promise.resolve(value).then(_next, _throw);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function _async_to_generator(fn) {
|
|
28
|
+
return function() {
|
|
29
|
+
var self = this, args = arguments;
|
|
30
|
+
return new Promise(function(resolve, reject) {
|
|
31
|
+
var gen = fn.apply(self, args);
|
|
32
|
+
function _next(value) {
|
|
33
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
34
|
+
}
|
|
35
|
+
function _throw(err) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
37
|
+
}
|
|
38
|
+
_next(undefined);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function _iterable_to_array(iter) {
|
|
43
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
44
|
+
}
|
|
45
|
+
function _iterable_to_array_limit(arr, i) {
|
|
46
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
47
|
+
if (_i == null) return;
|
|
48
|
+
var _arr = [];
|
|
49
|
+
var _n = true;
|
|
50
|
+
var _d = false;
|
|
51
|
+
var _s, _e;
|
|
52
|
+
try {
|
|
53
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
54
|
+
_arr.push(_s.value);
|
|
55
|
+
if (i && _arr.length === i) break;
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
_d = true;
|
|
59
|
+
_e = err;
|
|
60
|
+
} finally{
|
|
61
|
+
try {
|
|
62
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
63
|
+
} finally{
|
|
64
|
+
if (_d) throw _e;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return _arr;
|
|
68
|
+
}
|
|
69
|
+
function _non_iterable_rest() {
|
|
70
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
71
|
+
}
|
|
72
|
+
function _non_iterable_spread() {
|
|
73
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
74
|
+
}
|
|
75
|
+
function _sliced_to_array(arr, i) {
|
|
76
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
77
|
+
}
|
|
78
|
+
function _to_consumable_array(arr) {
|
|
79
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
80
|
+
}
|
|
81
|
+
function _type_of(obj) {
|
|
82
|
+
"@swc/helpers - typeof";
|
|
83
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
84
|
+
}
|
|
85
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
86
|
+
if (!o) return;
|
|
87
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
88
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
89
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
90
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
91
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
92
|
+
}
|
|
93
|
+
function _ts_generator(thisArg, body) {
|
|
94
|
+
var f, y, t, _ = {
|
|
95
|
+
label: 0,
|
|
96
|
+
sent: function() {
|
|
97
|
+
if (t[0] & 1) throw t[1];
|
|
98
|
+
return t[1];
|
|
99
|
+
},
|
|
100
|
+
trys: [],
|
|
101
|
+
ops: []
|
|
102
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
103
|
+
return d(g, "next", {
|
|
104
|
+
value: verb(0)
|
|
105
|
+
}), d(g, "throw", {
|
|
106
|
+
value: verb(1)
|
|
107
|
+
}), d(g, "return", {
|
|
108
|
+
value: verb(2)
|
|
109
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
110
|
+
value: function() {
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
}), g;
|
|
114
|
+
function verb(n) {
|
|
115
|
+
return function(v) {
|
|
116
|
+
return step([
|
|
117
|
+
n,
|
|
118
|
+
v
|
|
119
|
+
]);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function step(op) {
|
|
123
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
124
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
125
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
126
|
+
if (y = 0, t) op = [
|
|
127
|
+
op[0] & 2,
|
|
128
|
+
t.value
|
|
129
|
+
];
|
|
130
|
+
switch(op[0]){
|
|
131
|
+
case 0:
|
|
132
|
+
case 1:
|
|
133
|
+
t = op;
|
|
134
|
+
break;
|
|
135
|
+
case 4:
|
|
136
|
+
_.label++;
|
|
137
|
+
return {
|
|
138
|
+
value: op[1],
|
|
139
|
+
done: false
|
|
140
|
+
};
|
|
141
|
+
case 5:
|
|
142
|
+
_.label++;
|
|
143
|
+
y = op[1];
|
|
144
|
+
op = [
|
|
145
|
+
0
|
|
146
|
+
];
|
|
147
|
+
continue;
|
|
148
|
+
case 7:
|
|
149
|
+
op = _.ops.pop();
|
|
150
|
+
_.trys.pop();
|
|
151
|
+
continue;
|
|
152
|
+
default:
|
|
153
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
154
|
+
_ = 0;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
158
|
+
_.label = op[1];
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
162
|
+
_.label = t[1];
|
|
163
|
+
t = op;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
if (t && _.label < t[2]) {
|
|
167
|
+
_.label = t[2];
|
|
168
|
+
_.ops.push(op);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
if (t[2]) _.ops.pop();
|
|
172
|
+
_.trys.pop();
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
op = body.call(thisArg, _);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
op = [
|
|
178
|
+
6,
|
|
179
|
+
e
|
|
180
|
+
];
|
|
181
|
+
y = 0;
|
|
182
|
+
} finally{
|
|
183
|
+
f = t = 0;
|
|
184
|
+
}
|
|
185
|
+
if (op[0] & 5) throw op[1];
|
|
186
|
+
return {
|
|
187
|
+
value: op[0] ? op[1] : void 0,
|
|
188
|
+
done: true
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
var AzzasTracker = function() {
|
|
193
|
+
var pushToDataLayer = // src/adapters/datalayer.ts
|
|
194
|
+
function pushToDataLayer(event, ecomm, dest) {
|
|
195
|
+
var targetWindow = ecomm.window;
|
|
196
|
+
var ecommercePayload = Object.assign({}, ecomm);
|
|
197
|
+
delete ecommercePayload.window;
|
|
198
|
+
if (targetWindow) {
|
|
199
|
+
targetWindow.dataLayer = targetWindow.dataLayer || [];
|
|
200
|
+
targetWindow.dataLayer.push({
|
|
201
|
+
event: event,
|
|
202
|
+
ecommerce: ecommercePayload
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
window.dataLayer = window.dataLayer || [];
|
|
207
|
+
window.dataLayer.push({
|
|
208
|
+
event: event,
|
|
209
|
+
ecommerce: ecommercePayload
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
var dataTrackingLog = // src/core/utils.ts
|
|
213
|
+
function dataTrackingLog(data, color, destination) {
|
|
214
|
+
console.log("%c[DT - ".concat(destination, "] EVENTO DISPARADO:%c "), "background: ".concat(color, "; color: white; font-weight: bold; padding: 2px 4px; border-radius: 3px;"), "color: #fff;", data || "");
|
|
215
|
+
};
|
|
216
|
+
var pushToDito = // src/adapters/dito.ts
|
|
217
|
+
function pushToDito(event, ecomm, dest) {
|
|
218
|
+
dataTrackingLog({
|
|
219
|
+
id: event,
|
|
220
|
+
custom_data: ecomm
|
|
221
|
+
}, "#00c851", dest);
|
|
222
|
+
};
|
|
223
|
+
var dispatchTrackEvent = function dispatchTrackEvent(eventName, data) {
|
|
224
|
+
return _async_to_generator(function() {
|
|
225
|
+
var eventConfig;
|
|
226
|
+
return _ts_generator(this, function(_state) {
|
|
227
|
+
switch(_state.label){
|
|
228
|
+
case 0:
|
|
229
|
+
eventConfig = EVENTS[eventName];
|
|
230
|
+
if (!eventConfig) return [
|
|
231
|
+
2
|
|
232
|
+
];
|
|
233
|
+
return [
|
|
234
|
+
4,
|
|
235
|
+
Promise.allSettled(eventConfig.destinations.map(function(dest) {
|
|
236
|
+
return _async_to_generator(function() {
|
|
237
|
+
var err;
|
|
238
|
+
return _ts_generator(this, function(_state) {
|
|
239
|
+
switch(_state.label){
|
|
240
|
+
case 0:
|
|
241
|
+
_state.trys.push([
|
|
242
|
+
0,
|
|
243
|
+
2,
|
|
244
|
+
,
|
|
245
|
+
3
|
|
246
|
+
]);
|
|
247
|
+
return [
|
|
248
|
+
4,
|
|
249
|
+
adapters[dest](eventName.toLowerCase(), data, dest)
|
|
250
|
+
];
|
|
251
|
+
case 1:
|
|
252
|
+
_state.sent();
|
|
253
|
+
return [
|
|
254
|
+
3,
|
|
255
|
+
3
|
|
256
|
+
];
|
|
257
|
+
case 2:
|
|
258
|
+
err = _state.sent();
|
|
259
|
+
console.error("[DT] Failed to send ".concat(eventName, " to ").concat(dest, ":"), err);
|
|
260
|
+
return [
|
|
261
|
+
3,
|
|
262
|
+
3
|
|
263
|
+
];
|
|
264
|
+
case 3:
|
|
265
|
+
return [
|
|
266
|
+
2
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
})();
|
|
271
|
+
}))
|
|
272
|
+
];
|
|
273
|
+
case 1:
|
|
274
|
+
_state.sent();
|
|
275
|
+
return [
|
|
276
|
+
2
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
})();
|
|
281
|
+
};
|
|
282
|
+
var getProductDataById = // src/params/utils/index.ts
|
|
283
|
+
function getProductDataById(id) {
|
|
284
|
+
return _async_to_generator(function() {
|
|
285
|
+
var response, e;
|
|
286
|
+
return _ts_generator(this, function(_state) {
|
|
287
|
+
switch(_state.label){
|
|
288
|
+
case 0:
|
|
289
|
+
_state.trys.push([
|
|
290
|
+
0,
|
|
291
|
+
3,
|
|
292
|
+
,
|
|
293
|
+
4
|
|
294
|
+
]);
|
|
295
|
+
return [
|
|
296
|
+
4,
|
|
297
|
+
fetch("/api/catalog_system/pub/products/search?fq=productId:".concat(id))
|
|
298
|
+
];
|
|
299
|
+
case 1:
|
|
300
|
+
response = _state.sent();
|
|
301
|
+
return [
|
|
302
|
+
4,
|
|
303
|
+
response.json()
|
|
304
|
+
];
|
|
305
|
+
case 2:
|
|
306
|
+
return [
|
|
307
|
+
2,
|
|
308
|
+
_state.sent()
|
|
309
|
+
];
|
|
310
|
+
case 3:
|
|
311
|
+
e = _state.sent();
|
|
312
|
+
console.log("[DT] Erro ao buscar dados do produto", e);
|
|
313
|
+
return [
|
|
314
|
+
3,
|
|
315
|
+
4
|
|
316
|
+
];
|
|
317
|
+
case 4:
|
|
318
|
+
return [
|
|
319
|
+
2
|
|
320
|
+
];
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
})();
|
|
324
|
+
};
|
|
325
|
+
var isPDP = function isPDP(url) {
|
|
326
|
+
try {
|
|
327
|
+
var pathname = new URL(url, window.location.origin).pathname;
|
|
328
|
+
return /\/p\/?$/.test(pathname);
|
|
329
|
+
} catch (unused) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
var extractRefIdFromUrl = function extractRefIdFromUrl(url) {
|
|
334
|
+
if (!url) return null;
|
|
335
|
+
var path = function() {
|
|
336
|
+
try {
|
|
337
|
+
return new URL(url, location.origin).pathname;
|
|
338
|
+
} catch (unused) {
|
|
339
|
+
return url.split("?")[0];
|
|
340
|
+
}
|
|
341
|
+
}();
|
|
342
|
+
var match = decodeURIComponent(path).match(/(\d+-\d+)(?=\/p|$)/);
|
|
343
|
+
return match ? match[1].replace("-", "_") : null;
|
|
344
|
+
};
|
|
345
|
+
var getProductByRefId = function getProductByRefId(url) {
|
|
346
|
+
return _async_to_generator(function() {
|
|
347
|
+
var refId, res, products, err;
|
|
348
|
+
return _ts_generator(this, function(_state) {
|
|
349
|
+
switch(_state.label){
|
|
350
|
+
case 0:
|
|
351
|
+
refId = extractRefIdFromUrl(url);
|
|
352
|
+
if (!refId) return [
|
|
353
|
+
2,
|
|
354
|
+
(console.error("N\xE3o foi poss\xEDvel extrair o RefId da URL"), null)
|
|
355
|
+
];
|
|
356
|
+
_state.label = 1;
|
|
357
|
+
case 1:
|
|
358
|
+
_state.trys.push([
|
|
359
|
+
1,
|
|
360
|
+
4,
|
|
361
|
+
,
|
|
362
|
+
5
|
|
363
|
+
]);
|
|
364
|
+
return [
|
|
365
|
+
4,
|
|
366
|
+
fetch("/api/catalog_system/pub/products/search?fq=alternateIds_RefId:".concat(refId))
|
|
367
|
+
];
|
|
368
|
+
case 2:
|
|
369
|
+
res = _state.sent();
|
|
370
|
+
if (!res.ok) throw new Error("Erro na API: ".concat(res.status));
|
|
371
|
+
return [
|
|
372
|
+
4,
|
|
373
|
+
res.json()
|
|
374
|
+
];
|
|
375
|
+
case 3:
|
|
376
|
+
products = _state.sent();
|
|
377
|
+
return [
|
|
378
|
+
2,
|
|
379
|
+
(products === null || products === void 0 ? void 0 : products[0]) || null
|
|
380
|
+
];
|
|
381
|
+
case 4:
|
|
382
|
+
err = _state.sent();
|
|
383
|
+
console.error("Erro ao buscar dados do produto:", err);
|
|
384
|
+
return [
|
|
385
|
+
2,
|
|
386
|
+
null
|
|
387
|
+
];
|
|
388
|
+
case 5:
|
|
389
|
+
return [
|
|
390
|
+
2
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
})();
|
|
395
|
+
};
|
|
396
|
+
var getItemShippingTier = function getItemShippingTier(orderForm, item) {
|
|
397
|
+
var _orderForm_shippingData_logisticsInfo, _orderForm_shippingData, _info_slas, _selectedSla_pickupStoreInfo;
|
|
398
|
+
var info = orderForm === null || orderForm === void 0 ? void 0 : (_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : (_orderForm_shippingData_logisticsInfo = _orderForm_shippingData.logisticsInfo) === null || _orderForm_shippingData_logisticsInfo === void 0 ? void 0 : _orderForm_shippingData_logisticsInfo.find(function(li) {
|
|
399
|
+
return li.itemId === item.id;
|
|
400
|
+
});
|
|
401
|
+
var selectedSla = info === null || info === void 0 ? void 0 : (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.find(function(sla) {
|
|
402
|
+
return sla.id === info.selectedSla;
|
|
403
|
+
});
|
|
404
|
+
return (selectedSla === null || selectedSla === void 0 ? void 0 : (_selectedSla_pickupStoreInfo = selectedSla.pickupStoreInfo) === null || _selectedSla_pickupStoreInfo === void 0 ? void 0 : _selectedSla_pickupStoreInfo.friendlyName) ? "retirada em loja: ".concat(selectedSla.pickupStoreInfo.friendlyName) : (selectedSla === null || selectedSla === void 0 ? void 0 : selectedSla.name) ? "Receba em casa: ".concat(selectedSla.name) : null;
|
|
405
|
+
};
|
|
406
|
+
var getItemSku = function getItemSku(item) {
|
|
407
|
+
return _async_to_generator(function() {
|
|
408
|
+
var _ref, _product__items_find, product;
|
|
409
|
+
return _ts_generator(this, function(_state) {
|
|
410
|
+
switch(_state.label){
|
|
411
|
+
case 0:
|
|
412
|
+
return [
|
|
413
|
+
4,
|
|
414
|
+
getProductDataById(item.productId || item.productID || item.item_group_id)
|
|
415
|
+
];
|
|
416
|
+
case 1:
|
|
417
|
+
product = _state.sent();
|
|
418
|
+
if (!product.length) return [
|
|
419
|
+
2,
|
|
420
|
+
null
|
|
421
|
+
];
|
|
422
|
+
return [
|
|
423
|
+
2,
|
|
424
|
+
(_ref = (_product__items_find = product[0].items.find(function(i) {
|
|
425
|
+
return i.name === item.skuName;
|
|
426
|
+
})) === null || _product__items_find === void 0 ? void 0 : _product__items_find.itemId) !== null && _ref !== void 0 ? _ref : null
|
|
427
|
+
];
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
})();
|
|
431
|
+
};
|
|
432
|
+
var getDiscount = function getDiscount(item) {
|
|
433
|
+
return item.discount || item.discount === 0 ? item.discount : parseFloat(Math.max(item.listPrice - item.sellingPrice, 0).toFixed(2)) / 100 || 0;
|
|
434
|
+
};
|
|
435
|
+
var getItemCategory = function getItemCategory(item) {
|
|
436
|
+
var strategies = [
|
|
437
|
+
function() {
|
|
438
|
+
var _item_productCategories;
|
|
439
|
+
return (item === null || item === void 0 ? void 0 : (_item_productCategories = item.productCategories) === null || _item_productCategories === void 0 ? void 0 : _item_productCategories["39"]) === "BAZAR" ? "Sale" : "Cole\xE7\xE3o";
|
|
440
|
+
},
|
|
441
|
+
function() {
|
|
442
|
+
return item.item_category || item.category;
|
|
443
|
+
},
|
|
444
|
+
// deco select_item context
|
|
445
|
+
function() {
|
|
446
|
+
return item.categories[0];
|
|
447
|
+
}
|
|
448
|
+
];
|
|
449
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
450
|
+
try {
|
|
451
|
+
for(var _iterator = strategies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
452
|
+
var getValue = _step.value;
|
|
453
|
+
var value = getValue();
|
|
454
|
+
if (value !== null && value !== void 0) {
|
|
455
|
+
return value;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
} catch (err) {
|
|
459
|
+
_didIteratorError = true;
|
|
460
|
+
_iteratorError = err;
|
|
461
|
+
} finally{
|
|
462
|
+
try {
|
|
463
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
464
|
+
_iterator.return();
|
|
465
|
+
}
|
|
466
|
+
} finally{
|
|
467
|
+
if (_didIteratorError) {
|
|
468
|
+
throw _iteratorError;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return null;
|
|
473
|
+
};
|
|
474
|
+
var getItemCategory2 = function getItemCategory2(item) {
|
|
475
|
+
var strategies = [
|
|
476
|
+
function() {
|
|
477
|
+
return Object.values((item === null || item === void 0 ? void 0 : item.productCategories) || {}).pop();
|
|
478
|
+
},
|
|
479
|
+
// checkout select_item context
|
|
480
|
+
function() {
|
|
481
|
+
return Object.values((item === null || item === void 0 ? void 0 : item.categories) || {}).pop();
|
|
482
|
+
},
|
|
483
|
+
//
|
|
484
|
+
function() {
|
|
485
|
+
var _item_category_split__trim, _item_category_split_, _item_category_split, _item_category_split1, _item_category;
|
|
486
|
+
return item === null || item === void 0 ? void 0 : (_item_category = item.category) === null || _item_category === void 0 ? void 0 : (_item_category_split1 = _item_category.split) === null || _item_category_split1 === void 0 ? void 0 : (_item_category_split = _item_category_split1.call(_item_category, ">")) === null || _item_category_split === void 0 ? void 0 : (_item_category_split_ = _item_category_split[1]) === null || _item_category_split_ === void 0 ? void 0 : (_item_category_split__trim = _item_category_split_.trim) === null || _item_category_split__trim === void 0 ? void 0 : _item_category_split__trim.call(_item_category_split_);
|
|
487
|
+
},
|
|
488
|
+
// deco select_item context
|
|
489
|
+
function() {
|
|
490
|
+
return item.item_category2;
|
|
491
|
+
}
|
|
492
|
+
];
|
|
493
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
494
|
+
try {
|
|
495
|
+
for(var _iterator = strategies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
496
|
+
var getValue = _step.value;
|
|
497
|
+
var value = getValue();
|
|
498
|
+
if (value !== null && value !== void 0) {
|
|
499
|
+
return value;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
} catch (err) {
|
|
503
|
+
_didIteratorError = true;
|
|
504
|
+
_iteratorError = err;
|
|
505
|
+
} finally{
|
|
506
|
+
try {
|
|
507
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
508
|
+
_iterator.return();
|
|
509
|
+
}
|
|
510
|
+
} finally{
|
|
511
|
+
if (_didIteratorError) {
|
|
512
|
+
throw _iteratorError;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return null;
|
|
517
|
+
};
|
|
518
|
+
var getItemCategory4 = function getItemCategory4(item) {
|
|
519
|
+
var _item_additionalInfo;
|
|
520
|
+
var tags = (item === null || item === void 0 ? void 0 : (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.tags) || (item === null || item === void 0 ? void 0 : item.tags);
|
|
521
|
+
return Array.isArray(tags) && tags.length ? tags.join(",") : null;
|
|
522
|
+
};
|
|
523
|
+
var getBrandCode = function getBrandCode(brand) {
|
|
524
|
+
if (!brand) return null;
|
|
525
|
+
var standardized = brand.toLowerCase().trim();
|
|
526
|
+
return BRAND_CODES[standardized] || null;
|
|
527
|
+
};
|
|
528
|
+
var normalizeBrand = function normalizeBrand(input) {
|
|
529
|
+
var brandStrings = [];
|
|
530
|
+
if (Array.isArray(input) && input.every(function(item) {
|
|
531
|
+
return typeof item === "string";
|
|
532
|
+
})) {
|
|
533
|
+
brandStrings = input;
|
|
534
|
+
} else if (Array.isArray(input)) {
|
|
535
|
+
brandStrings = input.map(function(item) {
|
|
536
|
+
var _item_additionalInfo;
|
|
537
|
+
return ((_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || item.brand;
|
|
538
|
+
});
|
|
539
|
+
} else if ((typeof input === "undefined" ? "undefined" : _type_of(input)) === "object" && input !== null && "brand" in input) {
|
|
540
|
+
var _input_additionalInfo;
|
|
541
|
+
brandStrings = [
|
|
542
|
+
((_input_additionalInfo = input.additionalInfo) === null || _input_additionalInfo === void 0 ? void 0 : _input_additionalInfo.brandName) || input.brand
|
|
543
|
+
];
|
|
544
|
+
} else if (typeof input === "string") {
|
|
545
|
+
return getBrandCode(input);
|
|
546
|
+
} else {
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
var brandCodes = brandStrings.map(getBrandCode).filter(function(code) {
|
|
550
|
+
return code !== null;
|
|
551
|
+
});
|
|
552
|
+
var uniqueSortedCodes = _to_consumable_array(new Set(brandCodes)).sort();
|
|
553
|
+
return uniqueSortedCodes.length > 0 ? uniqueSortedCodes.join("_") : null;
|
|
554
|
+
};
|
|
555
|
+
var brandFromOrderForm = // src/params/resolvers/brand/fromOrderForm.ts
|
|
556
|
+
function brandFromOrderForm(context) {
|
|
557
|
+
var _context_orderForm_items;
|
|
558
|
+
if (!context.orderForm && !((_context_orderForm_items = context.orderForm.items) === null || _context_orderForm_items === void 0 ? void 0 : _context_orderForm_items.length)) return null;
|
|
559
|
+
var items = context.orderForm.items;
|
|
560
|
+
return normalizeBrand(items);
|
|
561
|
+
};
|
|
562
|
+
var brandFromItem = // src/params/resolvers/brand/fromItem.ts
|
|
563
|
+
function brandFromItem(context) {
|
|
564
|
+
var _item_additionalInfo;
|
|
565
|
+
var item = context.item;
|
|
566
|
+
return normalizeBrand((item === null || item === void 0 ? void 0 : (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || item.brand || item.item_brand);
|
|
567
|
+
};
|
|
568
|
+
var getBrand = // src/params/brand.ts
|
|
569
|
+
function getBrand(context, eventName) {
|
|
570
|
+
if (context === null || context === void 0 ? void 0 : context.brand) return normalizeBrand(context.brand) || context.brand || null;
|
|
571
|
+
switch(eventName){
|
|
572
|
+
case "CUSTOM_VIEW_CART":
|
|
573
|
+
case "ADD_COUPON":
|
|
574
|
+
case "ADD_PERSONAL_INFO":
|
|
575
|
+
case "CUSTOM_ADD_SHIPPING_INFO":
|
|
576
|
+
case "CUSTOM_ADD_PAYMENT_INFO":
|
|
577
|
+
case "BEGIN_CHECKOUT":
|
|
578
|
+
case "CUSTOM_BEGIN_CHECKOUT":
|
|
579
|
+
case "SEARCH_ZIPCODE":
|
|
580
|
+
case "ORDER_REVIEWED":
|
|
581
|
+
case "PURCHASE":
|
|
582
|
+
case "CUSTOM_PURCHASE":
|
|
583
|
+
return brandFromOrderForm(context);
|
|
584
|
+
case "ADD_TO_CART":
|
|
585
|
+
case "REMOVE_FROM_CART":
|
|
586
|
+
return brandFromItem(context);
|
|
587
|
+
default:
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
var itemsFromOrderForm = // src/params/resolvers/items/fromOrderForm.ts
|
|
592
|
+
function itemsFromOrderForm(context) {
|
|
593
|
+
return _async_to_generator(function() {
|
|
594
|
+
var _context_orderForm, items;
|
|
595
|
+
return _ts_generator(this, function(_state) {
|
|
596
|
+
switch(_state.label){
|
|
597
|
+
case 0:
|
|
598
|
+
items = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items) || [];
|
|
599
|
+
if (!items.length) return [
|
|
600
|
+
2,
|
|
601
|
+
[]
|
|
602
|
+
];
|
|
603
|
+
return [
|
|
604
|
+
4,
|
|
605
|
+
Promise.all(items.map(function(item) {
|
|
606
|
+
return _async_to_generator(function() {
|
|
607
|
+
var _item_additionalInfo, _item_additionalInfo1, _item_skuName_split_pop, _tmp;
|
|
608
|
+
return _ts_generator(this, function(_state) {
|
|
609
|
+
switch(_state.label){
|
|
610
|
+
case 0:
|
|
611
|
+
_tmp = {
|
|
612
|
+
item_id: item.productId,
|
|
613
|
+
item_category2: getItemCategory2(item),
|
|
614
|
+
item_category4: getItemCategory4(item),
|
|
615
|
+
item_shipping_tier: getItemShippingTier(context.orderForm, item),
|
|
616
|
+
price: parseFloat((item.price / 100).toFixed(2)) || 0,
|
|
617
|
+
quantity: item.quantity || 1,
|
|
618
|
+
item_ref: item.refId || null,
|
|
619
|
+
item_brand: normalizeBrand((_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || ((_item_additionalInfo1 = item.additionalInfo) === null || _item_additionalInfo1 === void 0 ? void 0 : _item_additionalInfo1.brandName) || null
|
|
620
|
+
};
|
|
621
|
+
return [
|
|
622
|
+
4,
|
|
623
|
+
getItemSku(item)
|
|
624
|
+
];
|
|
625
|
+
case 1:
|
|
626
|
+
return [
|
|
627
|
+
2,
|
|
628
|
+
(_tmp.item_sku = _state.sent() || item.id || null, _tmp.item_name = item.name || item.id || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = item.skuName.split(/[-/]/)[0].trim(), _tmp.item_variant2 = ((_item_skuName_split_pop = item.skuName.split(/[-/]/).pop()) === null || _item_skuName_split_pop === void 0 ? void 0 : _item_skuName_split_pop.trim()) || "", _tmp.discount = getDiscount(item), _tmp)
|
|
629
|
+
];
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
})();
|
|
633
|
+
}))
|
|
634
|
+
];
|
|
635
|
+
case 1:
|
|
636
|
+
return [
|
|
637
|
+
2,
|
|
638
|
+
_state.sent()
|
|
639
|
+
];
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
})();
|
|
643
|
+
};
|
|
644
|
+
var itemsFromItem = // src/params/resolvers/items/fromItem.ts
|
|
645
|
+
function itemsFromItem(context, event) {
|
|
646
|
+
return _async_to_generator(function() {
|
|
647
|
+
var _item_additionalInfo, _item_itemAttributes, _split_pop, item, orderForm, _tmp, _tmp1;
|
|
648
|
+
return _ts_generator(this, function(_state) {
|
|
649
|
+
switch(_state.label){
|
|
650
|
+
case 0:
|
|
651
|
+
item = context.item, orderForm = context.orderForm;
|
|
652
|
+
_tmp = {
|
|
653
|
+
index: 0,
|
|
654
|
+
quantity: 1,
|
|
655
|
+
item_id: item.productId || item.item_group_id || item.sku || null,
|
|
656
|
+
item_category2: getItemCategory2(item),
|
|
657
|
+
item_category4: getItemCategory4(item),
|
|
658
|
+
item_shipping_tier: event === "REMOVE_FROM_CART" ? getItemShippingTier(orderForm, item) : null,
|
|
659
|
+
price: item.listPrice || parseFloat((item.price / 100).toFixed(2)) || 0,
|
|
660
|
+
item_ref: item.refId || item.item_ref || (item === null || item === void 0 ? void 0 : item.additionalProperty.find(function(i) {
|
|
661
|
+
return i.name === "RefId";
|
|
662
|
+
}).value) || null,
|
|
663
|
+
item_brand: ((_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || item.item_brand || item.brand.name || null
|
|
664
|
+
};
|
|
665
|
+
_tmp1 = item.sku || item.id || item.item_id;
|
|
666
|
+
if (_tmp1) return [
|
|
667
|
+
3,
|
|
668
|
+
2
|
|
669
|
+
];
|
|
670
|
+
return [
|
|
671
|
+
4,
|
|
672
|
+
getItemSku(item)
|
|
673
|
+
];
|
|
674
|
+
case 1:
|
|
675
|
+
_tmp1 = _state.sent();
|
|
676
|
+
_state.label = 2;
|
|
677
|
+
case 2:
|
|
678
|
+
return [
|
|
679
|
+
2,
|
|
680
|
+
[
|
|
681
|
+
(_tmp.item_sku = _tmp1 || null, _tmp.item_name = item.name || item.item_name || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = (item.skuName || item.item_variant || item.name).split(/[-/]/)[0].trim() || null, _tmp.item_variant2 = item.size || (item === null || item === void 0 ? void 0 : (_item_itemAttributes = item.itemAttributes) === null || _item_itemAttributes === void 0 ? void 0 : _item_itemAttributes.size) || ((_split_pop = (item.skuName || item.name).split(/[-/]/).pop()) === null || _split_pop === void 0 ? void 0 : _split_pop.trim()) || null, _tmp.discount = getDiscount(item), _tmp.item_list_name = getItemCategory(item) || null, _tmp.item_url = item.item_url || null, _tmp)
|
|
682
|
+
]
|
|
683
|
+
];
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
})();
|
|
687
|
+
};
|
|
688
|
+
var itemsFromList = // src/params/resolvers/items/fromList.ts
|
|
689
|
+
function itemsFromList(context) {
|
|
690
|
+
return _async_to_generator(function() {
|
|
691
|
+
return _ts_generator(this, function(_state) {
|
|
692
|
+
return [
|
|
693
|
+
2,
|
|
694
|
+
((context === null || context === void 0 ? void 0 : context.list) || []).map(function(item) {
|
|
695
|
+
var _item_price, _item_offers, _item_brand, _item_name;
|
|
696
|
+
return {
|
|
697
|
+
price: (item === null || item === void 0 ? void 0 : (_item_price = item.price) === null || _item_price === void 0 ? void 0 : _item_price.list) || (item === null || item === void 0 ? void 0 : item.price) || (item === null || item === void 0 ? void 0 : (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : _item_offers.lowPrice) || 0,
|
|
698
|
+
quantity: 1,
|
|
699
|
+
item_ref: (item === null || item === void 0 ? void 0 : item.ref) || (item === null || item === void 0 ? void 0 : item.item_ref) || (item === null || item === void 0 ? void 0 : item.additionalProperty.find(function(i) {
|
|
700
|
+
return i.name === "RefId";
|
|
701
|
+
}).value) || null,
|
|
702
|
+
index: typeof (context === null || context === void 0 ? void 0 : context.index) === "number" ? context.index : null,
|
|
703
|
+
item_brand: normalizeBrand(item === null || item === void 0 ? void 0 : (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : _item_brand.name) || normalizeBrand(context.brand) || normalizeBrand(item === null || item === void 0 ? void 0 : item.item_brand) || null,
|
|
704
|
+
item_name: (item === null || item === void 0 ? void 0 : item.productName) || (item === null || item === void 0 ? void 0 : item.alternateName) || (item === null || item === void 0 ? void 0 : item.item_name) || null,
|
|
705
|
+
item_category: getItemCategory(item) || null,
|
|
706
|
+
item_variant: (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : _item_name.split("-")[0].trim()) || (item === null || item === void 0 ? void 0 : item.item_variant) || null,
|
|
707
|
+
item_category2: getItemCategory2(item) || null,
|
|
708
|
+
item_id: (item === null || item === void 0 ? void 0 : item.productID) || (item === null || item === void 0 ? void 0 : item.productId) || (item === null || item === void 0 ? void 0 : item.item_id) || null,
|
|
709
|
+
discount: getDiscount(item) || null,
|
|
710
|
+
item_list_name: (context === null || context === void 0 ? void 0 : context.itemListName) || getItemCategory(item) || null
|
|
711
|
+
};
|
|
712
|
+
})
|
|
713
|
+
];
|
|
714
|
+
});
|
|
715
|
+
})();
|
|
716
|
+
};
|
|
717
|
+
var itemsFromPDP = // src/params/resolvers/items/fromPdp.ts
|
|
718
|
+
function itemsFromPDP(context) {
|
|
719
|
+
return _async_to_generator(function() {
|
|
720
|
+
var _item_name, _item_category_split_, _item_category, item;
|
|
721
|
+
return _ts_generator(this, function(_state) {
|
|
722
|
+
item = context.item;
|
|
723
|
+
return [
|
|
724
|
+
2,
|
|
725
|
+
[
|
|
726
|
+
{
|
|
727
|
+
price: context.value || 0,
|
|
728
|
+
quantity: 1,
|
|
729
|
+
item_ref: item.ref || item.additionalProperty.find(function(i) {
|
|
730
|
+
return i.name === "RefId";
|
|
731
|
+
}).value || null,
|
|
732
|
+
item_brand: normalizeBrand(item.brand.name) || normalizeBrand(context.brand) || null,
|
|
733
|
+
item_name: item.productName || item.alternateName || null,
|
|
734
|
+
item_category: getItemCategory(item) || null,
|
|
735
|
+
item_variant: (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : _item_name.split("-")[0].trim()) || null,
|
|
736
|
+
item_category2: getItemCategory2(item) || (item === null || item === void 0 ? void 0 : (_item_category = item.category) === null || _item_category === void 0 ? void 0 : (_item_category_split_ = _item_category.split(">")[1]) === null || _item_category_split_ === void 0 ? void 0 : _item_category_split_.trim()) || null,
|
|
737
|
+
item_id: (item === null || item === void 0 ? void 0 : item.productID) || (item === null || item === void 0 ? void 0 : item.productId) || item.item_group_id || null,
|
|
738
|
+
discount: getDiscount(item) || null,
|
|
739
|
+
// dito params view_item
|
|
740
|
+
item_sku: (item === null || item === void 0 ? void 0 : item.sku) || (item === null || item === void 0 ? void 0 : item.productId) || null,
|
|
741
|
+
item_url: item.url || item.item_url || null,
|
|
742
|
+
seller_id: item.seller || null
|
|
743
|
+
}
|
|
744
|
+
]
|
|
745
|
+
];
|
|
746
|
+
});
|
|
747
|
+
})();
|
|
748
|
+
};
|
|
749
|
+
var itemsFromBanner = // src/params/resolvers/items/fromBanner.ts
|
|
750
|
+
function itemsFromBanner(context) {
|
|
751
|
+
return _async_to_generator(function() {
|
|
752
|
+
var _item_name, isUrlFromPDP, product, item;
|
|
753
|
+
return _ts_generator(this, function(_state) {
|
|
754
|
+
switch(_state.label){
|
|
755
|
+
case 0:
|
|
756
|
+
isUrlFromPDP = isPDP(context === null || context === void 0 ? void 0 : context.bannerUrl);
|
|
757
|
+
if (!isUrlFromPDP) return [
|
|
758
|
+
2,
|
|
759
|
+
[]
|
|
760
|
+
];
|
|
761
|
+
return [
|
|
762
|
+
4,
|
|
763
|
+
getProductByRefId(context === null || context === void 0 ? void 0 : context.bannerUrl)
|
|
764
|
+
];
|
|
765
|
+
case 1:
|
|
766
|
+
product = _state.sent();
|
|
767
|
+
item = product === null || product === void 0 ? void 0 : product.items[0];
|
|
768
|
+
return [
|
|
769
|
+
2,
|
|
770
|
+
{
|
|
771
|
+
price: (item === null || item === void 0 ? void 0 : item.sellers[0].commertialOffer.Price) || 0,
|
|
772
|
+
quantity: 1,
|
|
773
|
+
item_ref: extractRefIdFromUrl(context === null || context === void 0 ? void 0 : context.bannerUrl),
|
|
774
|
+
item_brand: normalizeBrand(product.brand) || null,
|
|
775
|
+
item_name: (product === null || product === void 0 ? void 0 : product.productName) || (product === null || product === void 0 ? void 0 : product.alternateName) || (product === null || product === void 0 ? void 0 : product.item_name) || null,
|
|
776
|
+
item_category: getItemCategory(product) || null,
|
|
777
|
+
item_variant: (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : _item_name.split("-").pop().trim()) || null,
|
|
778
|
+
item_category2: getItemCategory2(product) || null,
|
|
779
|
+
item_id: (product === null || product === void 0 ? void 0 : product.productId) || null,
|
|
780
|
+
discount: (item === null || item === void 0 ? void 0 : item.sellers[0].commertialOffer.ListPrice) - (item === null || item === void 0 ? void 0 : item.sellers[0].commertialOffer.Price) || null
|
|
781
|
+
}
|
|
782
|
+
];
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
})();
|
|
786
|
+
};
|
|
787
|
+
var getItems = // src/params/items.ts
|
|
788
|
+
function getItems(context, eventName) {
|
|
789
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
790
|
+
switch(eventName){
|
|
791
|
+
case "CUSTOM_VIEW_CART":
|
|
792
|
+
case "BEGIN_CHECKOUT":
|
|
793
|
+
case "CUSTOM_BEGIN_CHECKOUT":
|
|
794
|
+
case "CUSTOM_ADD_SHIPPING_INFO":
|
|
795
|
+
case "CUSTOM_ADD_PAYMENT_INFO":
|
|
796
|
+
case "PURCHASE":
|
|
797
|
+
case "CUSTOM_PURCHASE":
|
|
798
|
+
return itemsFromOrderForm(context);
|
|
799
|
+
case "ADD_TO_CART":
|
|
800
|
+
case "ADD_TO_WISHLIST":
|
|
801
|
+
case "REMOVE_FROM_CART":
|
|
802
|
+
return itemsFromItem(context, eventName);
|
|
803
|
+
case "SELECT_ITEM":
|
|
804
|
+
case "VIEW_ITEM_LIST":
|
|
805
|
+
return itemsFromList(context);
|
|
806
|
+
case "VIEW_ITEM":
|
|
807
|
+
return itemsFromPDP(context);
|
|
808
|
+
case "VIEW_PROMOTION":
|
|
809
|
+
case "SELECT_PROMOTION":
|
|
810
|
+
return itemsFromBanner(context);
|
|
811
|
+
default:
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
var paymentTypeFromOrderForm = // src/params/resolvers/paymentType/fromOrderForm.ts
|
|
816
|
+
function paymentTypeFromOrderForm(context) {
|
|
817
|
+
var _context_orderForm_paymentData, _context_orderForm_paymentData1, _system_name;
|
|
818
|
+
if (!context.orderForm) return null;
|
|
819
|
+
var payments = ((_context_orderForm_paymentData = context.orderForm.paymentData) === null || _context_orderForm_paymentData === void 0 ? void 0 : _context_orderForm_paymentData.payments) || [];
|
|
820
|
+
var systems = ((_context_orderForm_paymentData1 = context.orderForm.paymentData) === null || _context_orderForm_paymentData1 === void 0 ? void 0 : _context_orderForm_paymentData1.paymentSystems) || [];
|
|
821
|
+
if (!payments.length || !systems.length) return null;
|
|
822
|
+
var selectedPayment = payments.find(function(p) {
|
|
823
|
+
return p === null || p === void 0 ? void 0 : p.paymentSystem;
|
|
824
|
+
}) || payments[0];
|
|
825
|
+
var id = String((selectedPayment === null || selectedPayment === void 0 ? void 0 : selectedPayment.paymentSystem) || "").trim();
|
|
826
|
+
if (!id) return null;
|
|
827
|
+
var system = systems.find(function(s) {
|
|
828
|
+
return String(s.id) === id;
|
|
829
|
+
});
|
|
830
|
+
var name = (system === null || system === void 0 ? void 0 : (_system_name = system.name) === null || _system_name === void 0 ? void 0 : _system_name.toLowerCase()) || "";
|
|
831
|
+
var match = paymentTypeMap.find(function(param) {
|
|
832
|
+
var _param = _sliced_to_array(param, 1), key = _param[0];
|
|
833
|
+
return name.includes(key);
|
|
834
|
+
});
|
|
835
|
+
return match ? match[1] : null;
|
|
836
|
+
};
|
|
837
|
+
var paymentTypeFromOrderGroup = // src/params/resolvers/paymentType/fromOrderGroup.ts
|
|
838
|
+
function paymentTypeFromOrderGroup(context) {
|
|
839
|
+
var _context_orderForm_paymentData, _transactions_, _payments__paymentSystemName, _payments_;
|
|
840
|
+
if (!context.orderForm) return null;
|
|
841
|
+
var transactions = ((_context_orderForm_paymentData = context.orderForm.paymentData) === null || _context_orderForm_paymentData === void 0 ? void 0 : _context_orderForm_paymentData.transactions) || [];
|
|
842
|
+
if (!transactions.length) return null;
|
|
843
|
+
var payments = ((_transactions_ = transactions[0]) === null || _transactions_ === void 0 ? void 0 : _transactions_.payments) || [];
|
|
844
|
+
if (!payments.length) return null;
|
|
845
|
+
var name = ((_payments_ = payments[0]) === null || _payments_ === void 0 ? void 0 : (_payments__paymentSystemName = _payments_.paymentSystemName) === null || _payments__paymentSystemName === void 0 ? void 0 : _payments__paymentSystemName.toLowerCase()) || "";
|
|
846
|
+
var match = paymentTypeMap.find(function(param) {
|
|
847
|
+
var _param = _sliced_to_array(param, 1), key = _param[0];
|
|
848
|
+
return name.includes(key);
|
|
849
|
+
});
|
|
850
|
+
return match ? match[1] : null;
|
|
851
|
+
};
|
|
852
|
+
var getPaymentType = // src/params/paymentType.ts
|
|
853
|
+
function getPaymentType(context, eventName) {
|
|
854
|
+
if (context === null || context === void 0 ? void 0 : context.paymentType) return context.paymentType;
|
|
855
|
+
switch(eventName){
|
|
856
|
+
case "ORDER_REVIEWED":
|
|
857
|
+
case "CUSTOM_ADD_PAYMENT_INFO":
|
|
858
|
+
return paymentTypeFromOrderForm(context);
|
|
859
|
+
case "PURCHASE":
|
|
860
|
+
case "CUSTOM_PURCHASE":
|
|
861
|
+
return paymentTypeFromOrderGroup(context);
|
|
862
|
+
default:
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
var getParameters = // src/formatter/index.ts
|
|
867
|
+
function getParameters(_0) {
|
|
868
|
+
return _async_to_generator(function() {
|
|
869
|
+
var context, eventName, eventConfig, params, _;
|
|
870
|
+
var _arguments = arguments;
|
|
871
|
+
return _ts_generator(this, function(_state) {
|
|
872
|
+
switch(_state.label){
|
|
873
|
+
case 0:
|
|
874
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, eventName = _arguments.length > 1 ? _arguments[1] : void 0;
|
|
875
|
+
eventConfig = EVENTS[eventName];
|
|
876
|
+
if (!eventConfig) return [
|
|
877
|
+
2
|
|
878
|
+
];
|
|
879
|
+
_ = Object.fromEntries;
|
|
880
|
+
return [
|
|
881
|
+
4,
|
|
882
|
+
Promise.all(eventConfig.requiredParams.map(function(param) {
|
|
883
|
+
return _async_to_generator(function() {
|
|
884
|
+
var getter, _tmp;
|
|
885
|
+
return _ts_generator(this, function(_state) {
|
|
886
|
+
switch(_state.label){
|
|
887
|
+
case 0:
|
|
888
|
+
getter = paramGetters[param];
|
|
889
|
+
if (typeof getter !== "function") {
|
|
890
|
+
console.error("[DT] Missing paramGetter for param: ".concat(param));
|
|
891
|
+
return [
|
|
892
|
+
2,
|
|
893
|
+
[
|
|
894
|
+
param,
|
|
895
|
+
null
|
|
896
|
+
]
|
|
897
|
+
];
|
|
898
|
+
}
|
|
899
|
+
_tmp = [
|
|
900
|
+
param
|
|
901
|
+
];
|
|
902
|
+
return [
|
|
903
|
+
4,
|
|
904
|
+
getter(context, eventName)
|
|
905
|
+
];
|
|
906
|
+
case 1:
|
|
907
|
+
return [
|
|
908
|
+
2,
|
|
909
|
+
_tmp.concat([
|
|
910
|
+
_state.sent()
|
|
911
|
+
])
|
|
912
|
+
];
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
})();
|
|
916
|
+
}))
|
|
917
|
+
];
|
|
918
|
+
case 1:
|
|
919
|
+
params = _.apply(Object, [
|
|
920
|
+
_state.sent()
|
|
921
|
+
]);
|
|
922
|
+
return [
|
|
923
|
+
2,
|
|
924
|
+
params
|
|
925
|
+
];
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
}).apply(this, arguments);
|
|
929
|
+
};
|
|
930
|
+
var trackWebEvent = // src/index.ts
|
|
931
|
+
function trackWebEvent(_0) {
|
|
932
|
+
return _async_to_generator(function(event) {
|
|
933
|
+
var context, parameters, err;
|
|
934
|
+
var _arguments = arguments;
|
|
935
|
+
return _ts_generator(this, function(_state) {
|
|
936
|
+
switch(_state.label){
|
|
937
|
+
case 0:
|
|
938
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
939
|
+
_state.label = 1;
|
|
940
|
+
case 1:
|
|
941
|
+
_state.trys.push([
|
|
942
|
+
1,
|
|
943
|
+
4,
|
|
944
|
+
,
|
|
945
|
+
5
|
|
946
|
+
]);
|
|
947
|
+
return [
|
|
948
|
+
4,
|
|
949
|
+
getParameters(context, event)
|
|
950
|
+
];
|
|
951
|
+
case 2:
|
|
952
|
+
parameters = _state.sent();
|
|
953
|
+
return [
|
|
954
|
+
4,
|
|
955
|
+
dispatchTrackEvent(event, Object.assign({}, parameters, {
|
|
956
|
+
window: context.window
|
|
957
|
+
}))
|
|
958
|
+
];
|
|
959
|
+
case 3:
|
|
960
|
+
return [
|
|
961
|
+
2,
|
|
962
|
+
_state.sent()
|
|
963
|
+
];
|
|
964
|
+
case 4:
|
|
965
|
+
err = _state.sent();
|
|
966
|
+
return [
|
|
967
|
+
2,
|
|
968
|
+
console.error("[DT] Error tracking event ".concat(event, ":"), err)
|
|
969
|
+
];
|
|
970
|
+
case 5:
|
|
971
|
+
return [
|
|
972
|
+
2
|
|
973
|
+
];
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
}).apply(this, arguments);
|
|
977
|
+
};
|
|
978
|
+
var __defProp = Object.defineProperty;
|
|
979
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
980
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
981
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
982
|
+
var __export = function(target, all) {
|
|
983
|
+
for(var name in all)__defProp(target, name, {
|
|
984
|
+
get: all[name],
|
|
985
|
+
enumerable: true
|
|
986
|
+
});
|
|
987
|
+
};
|
|
988
|
+
var __copyProps = function(to, from, except, desc) {
|
|
989
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
990
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
991
|
+
try {
|
|
992
|
+
var _loop = function() {
|
|
993
|
+
var key = _step.value;
|
|
994
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
995
|
+
get: function() {
|
|
996
|
+
return from[key];
|
|
997
|
+
},
|
|
998
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
999
|
+
});
|
|
1000
|
+
};
|
|
1001
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
1002
|
+
} catch (err) {
|
|
1003
|
+
_didIteratorError = true;
|
|
1004
|
+
_iteratorError = err;
|
|
1005
|
+
} finally{
|
|
1006
|
+
try {
|
|
1007
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1008
|
+
_iterator.return();
|
|
1009
|
+
}
|
|
1010
|
+
} finally{
|
|
1011
|
+
if (_didIteratorError) {
|
|
1012
|
+
throw _iteratorError;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return to;
|
|
1018
|
+
};
|
|
1019
|
+
var __toCommonJS = function(mod) {
|
|
1020
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
1021
|
+
value: true
|
|
1022
|
+
}), mod);
|
|
1023
|
+
};
|
|
1024
|
+
// src/index.ts
|
|
1025
|
+
var src_exports = {};
|
|
1026
|
+
__export(src_exports, {
|
|
1027
|
+
EVENTS: function() {
|
|
1028
|
+
return EVENTS;
|
|
1029
|
+
},
|
|
1030
|
+
default: function() {
|
|
1031
|
+
return src_default;
|
|
1032
|
+
},
|
|
1033
|
+
trackWebEvent: function() {
|
|
1034
|
+
return trackWebEvent;
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
// src/core/constants.ts
|
|
1038
|
+
var EVENTS = {
|
|
1039
|
+
CUSTOM_VIEW_CART: {
|
|
1040
|
+
name: "custom_view_cart",
|
|
1041
|
+
destinations: [
|
|
1042
|
+
"DataLayer"
|
|
1043
|
+
],
|
|
1044
|
+
requiredParams: [
|
|
1045
|
+
"brand",
|
|
1046
|
+
"region",
|
|
1047
|
+
"line_items",
|
|
1048
|
+
"currency",
|
|
1049
|
+
"value",
|
|
1050
|
+
"total_discount",
|
|
1051
|
+
"subtotal",
|
|
1052
|
+
"items"
|
|
1053
|
+
]
|
|
1054
|
+
},
|
|
1055
|
+
ADD_TO_WISHLIST: {
|
|
1056
|
+
name: "add_to_wishlist",
|
|
1057
|
+
destinations: [
|
|
1058
|
+
"DataLayer"
|
|
1059
|
+
],
|
|
1060
|
+
requiredParams: [
|
|
1061
|
+
"brand",
|
|
1062
|
+
"region",
|
|
1063
|
+
"line_items",
|
|
1064
|
+
"currency",
|
|
1065
|
+
"value",
|
|
1066
|
+
"items"
|
|
1067
|
+
]
|
|
1068
|
+
},
|
|
1069
|
+
ADD_TO_CART: {
|
|
1070
|
+
name: "add_to_cart",
|
|
1071
|
+
destinations: [
|
|
1072
|
+
"DataLayer"
|
|
1073
|
+
],
|
|
1074
|
+
requiredParams: [
|
|
1075
|
+
"brand",
|
|
1076
|
+
"region",
|
|
1077
|
+
"line_items",
|
|
1078
|
+
"currency",
|
|
1079
|
+
"value",
|
|
1080
|
+
"items"
|
|
1081
|
+
]
|
|
1082
|
+
},
|
|
1083
|
+
REMOVE_FROM_CART: {
|
|
1084
|
+
name: "remove_from_cart",
|
|
1085
|
+
destinations: [
|
|
1086
|
+
"DataLayer"
|
|
1087
|
+
],
|
|
1088
|
+
requiredParams: [
|
|
1089
|
+
"brand",
|
|
1090
|
+
"region",
|
|
1091
|
+
"line_items",
|
|
1092
|
+
"currency",
|
|
1093
|
+
"value",
|
|
1094
|
+
"items"
|
|
1095
|
+
]
|
|
1096
|
+
},
|
|
1097
|
+
ADD_COUPON: {
|
|
1098
|
+
name: "add_coupon",
|
|
1099
|
+
destinations: [
|
|
1100
|
+
"DataLayer"
|
|
1101
|
+
],
|
|
1102
|
+
requiredParams: [
|
|
1103
|
+
"brand",
|
|
1104
|
+
"region",
|
|
1105
|
+
"coupon",
|
|
1106
|
+
"coupon_message",
|
|
1107
|
+
"seller_cod_name"
|
|
1108
|
+
]
|
|
1109
|
+
},
|
|
1110
|
+
SEARCH: {
|
|
1111
|
+
name: "search",
|
|
1112
|
+
destinations: [
|
|
1113
|
+
"DataLayer"
|
|
1114
|
+
],
|
|
1115
|
+
requiredParams: [
|
|
1116
|
+
"brand",
|
|
1117
|
+
"search_term",
|
|
1118
|
+
"search_found",
|
|
1119
|
+
"search_quantity"
|
|
1120
|
+
]
|
|
1121
|
+
},
|
|
1122
|
+
SEARCH_ZIPCODE: {
|
|
1123
|
+
name: "search_zipcode",
|
|
1124
|
+
destinations: [
|
|
1125
|
+
"DataLayer"
|
|
1126
|
+
],
|
|
1127
|
+
requiredParams: [
|
|
1128
|
+
"brand",
|
|
1129
|
+
"region",
|
|
1130
|
+
"shippings",
|
|
1131
|
+
"zipcode",
|
|
1132
|
+
"flag_pickup"
|
|
1133
|
+
]
|
|
1134
|
+
},
|
|
1135
|
+
VIEW_PROMOTION: {
|
|
1136
|
+
name: "view_promotion",
|
|
1137
|
+
destinations: [
|
|
1138
|
+
"DataLayer"
|
|
1139
|
+
],
|
|
1140
|
+
requiredParams: [
|
|
1141
|
+
"brand",
|
|
1142
|
+
"region",
|
|
1143
|
+
"currency",
|
|
1144
|
+
"promotion_name",
|
|
1145
|
+
"creative_slot",
|
|
1146
|
+
"creative_name",
|
|
1147
|
+
"items"
|
|
1148
|
+
]
|
|
1149
|
+
},
|
|
1150
|
+
SELECT_PROMOTION: {
|
|
1151
|
+
name: "select_promotion",
|
|
1152
|
+
destinations: [
|
|
1153
|
+
"DataLayer"
|
|
1154
|
+
],
|
|
1155
|
+
requiredParams: [
|
|
1156
|
+
"brand",
|
|
1157
|
+
"region",
|
|
1158
|
+
"currency",
|
|
1159
|
+
"promotion_name",
|
|
1160
|
+
"creative_slot",
|
|
1161
|
+
"creative_name",
|
|
1162
|
+
"items"
|
|
1163
|
+
]
|
|
1164
|
+
},
|
|
1165
|
+
SELECT_CONTENT: {
|
|
1166
|
+
name: "select_content",
|
|
1167
|
+
destinations: [
|
|
1168
|
+
"DataLayer"
|
|
1169
|
+
],
|
|
1170
|
+
requiredParams: [
|
|
1171
|
+
"brand",
|
|
1172
|
+
"content_type"
|
|
1173
|
+
]
|
|
1174
|
+
},
|
|
1175
|
+
SELECT_ITEM: {
|
|
1176
|
+
name: "select_item",
|
|
1177
|
+
destinations: [
|
|
1178
|
+
"DataLayer"
|
|
1179
|
+
],
|
|
1180
|
+
requiredParams: [
|
|
1181
|
+
"brand",
|
|
1182
|
+
"region",
|
|
1183
|
+
"items",
|
|
1184
|
+
"line_items"
|
|
1185
|
+
]
|
|
1186
|
+
},
|
|
1187
|
+
VIEW_ITEM: {
|
|
1188
|
+
name: "view_item",
|
|
1189
|
+
destinations: [
|
|
1190
|
+
"DataLayer"
|
|
1191
|
+
],
|
|
1192
|
+
requiredParams: [
|
|
1193
|
+
"brand",
|
|
1194
|
+
"line_items",
|
|
1195
|
+
"currency",
|
|
1196
|
+
"value",
|
|
1197
|
+
"available_grid",
|
|
1198
|
+
"items"
|
|
1199
|
+
]
|
|
1200
|
+
},
|
|
1201
|
+
VIEW_ITEM_LIST: {
|
|
1202
|
+
name: "view_item_list",
|
|
1203
|
+
destinations: [
|
|
1204
|
+
"DataLayer"
|
|
1205
|
+
],
|
|
1206
|
+
requiredParams: [
|
|
1207
|
+
"region",
|
|
1208
|
+
"brand",
|
|
1209
|
+
"line_items",
|
|
1210
|
+
"items"
|
|
1211
|
+
]
|
|
1212
|
+
},
|
|
1213
|
+
BEGIN_CHECKOUT: {
|
|
1214
|
+
name: "begin_checkout",
|
|
1215
|
+
destinations: [
|
|
1216
|
+
"DataLayer"
|
|
1217
|
+
],
|
|
1218
|
+
requiredParams: [
|
|
1219
|
+
"brand",
|
|
1220
|
+
"line_items",
|
|
1221
|
+
"currency",
|
|
1222
|
+
"value",
|
|
1223
|
+
"total_discount",
|
|
1224
|
+
"subtotal",
|
|
1225
|
+
"items"
|
|
1226
|
+
]
|
|
1227
|
+
},
|
|
1228
|
+
CUSTOM_BEGIN_CHECKOUT: {
|
|
1229
|
+
name: "custom_begin_checkout",
|
|
1230
|
+
destinations: [
|
|
1231
|
+
"DataLayer"
|
|
1232
|
+
],
|
|
1233
|
+
requiredParams: [
|
|
1234
|
+
"brand",
|
|
1235
|
+
"line_items",
|
|
1236
|
+
"currency",
|
|
1237
|
+
"value",
|
|
1238
|
+
"total_discount",
|
|
1239
|
+
"subtotal",
|
|
1240
|
+
"items"
|
|
1241
|
+
]
|
|
1242
|
+
},
|
|
1243
|
+
AUTH_ACTION: {
|
|
1244
|
+
name: "auth_action",
|
|
1245
|
+
requiredParams: [
|
|
1246
|
+
"region"
|
|
1247
|
+
]
|
|
1248
|
+
},
|
|
1249
|
+
ADD_PERSONAL_INFO: {
|
|
1250
|
+
name: "add_personal_info",
|
|
1251
|
+
destinations: [
|
|
1252
|
+
"DataLayer"
|
|
1253
|
+
],
|
|
1254
|
+
requiredParams: [
|
|
1255
|
+
"brand",
|
|
1256
|
+
"pre_filled",
|
|
1257
|
+
"line_items",
|
|
1258
|
+
"currency",
|
|
1259
|
+
"value",
|
|
1260
|
+
"total_discount",
|
|
1261
|
+
"subtotal"
|
|
1262
|
+
]
|
|
1263
|
+
},
|
|
1264
|
+
CUSTOM_ADD_SHIPPING_INFO: {
|
|
1265
|
+
name: "add_shipping_info",
|
|
1266
|
+
destinations: [
|
|
1267
|
+
"DataLayer"
|
|
1268
|
+
],
|
|
1269
|
+
requiredParams: [
|
|
1270
|
+
"brand",
|
|
1271
|
+
"pre_filled",
|
|
1272
|
+
"shipping",
|
|
1273
|
+
"shipping_tier",
|
|
1274
|
+
"line_items",
|
|
1275
|
+
"currency",
|
|
1276
|
+
"value",
|
|
1277
|
+
"total_discount",
|
|
1278
|
+
"subtotal",
|
|
1279
|
+
"items"
|
|
1280
|
+
]
|
|
1281
|
+
},
|
|
1282
|
+
CUSTOM_ADD_PAYMENT_INFO: {
|
|
1283
|
+
name: "add_payment_info",
|
|
1284
|
+
destinations: [
|
|
1285
|
+
"DataLayer"
|
|
1286
|
+
],
|
|
1287
|
+
requiredParams: [
|
|
1288
|
+
"brand",
|
|
1289
|
+
"pre_filled",
|
|
1290
|
+
"line_items",
|
|
1291
|
+
"currency",
|
|
1292
|
+
"value",
|
|
1293
|
+
"total_discount",
|
|
1294
|
+
"payment_type",
|
|
1295
|
+
"subtotal",
|
|
1296
|
+
"items"
|
|
1297
|
+
]
|
|
1298
|
+
},
|
|
1299
|
+
ORDER_REVIEWED: {
|
|
1300
|
+
name: "order_reviewed",
|
|
1301
|
+
destinations: [
|
|
1302
|
+
"DataLayer"
|
|
1303
|
+
],
|
|
1304
|
+
requiredParams: [
|
|
1305
|
+
"brand",
|
|
1306
|
+
"line_items",
|
|
1307
|
+
"currency",
|
|
1308
|
+
"value",
|
|
1309
|
+
"total_discount",
|
|
1310
|
+
"subtotal",
|
|
1311
|
+
"payment_type"
|
|
1312
|
+
]
|
|
1313
|
+
},
|
|
1314
|
+
PURCHASE: {
|
|
1315
|
+
name: "purchase",
|
|
1316
|
+
destinations: [
|
|
1317
|
+
"DataLayer"
|
|
1318
|
+
],
|
|
1319
|
+
requiredParams: [
|
|
1320
|
+
"brand",
|
|
1321
|
+
"shipping_tier",
|
|
1322
|
+
"line_items",
|
|
1323
|
+
"currency",
|
|
1324
|
+
"value",
|
|
1325
|
+
"shipping",
|
|
1326
|
+
"transaction_id",
|
|
1327
|
+
"total_discount",
|
|
1328
|
+
"payment_type",
|
|
1329
|
+
"seller_cod_name",
|
|
1330
|
+
"subtotal",
|
|
1331
|
+
"coupon",
|
|
1332
|
+
"items"
|
|
1333
|
+
]
|
|
1334
|
+
},
|
|
1335
|
+
CUSTOM_PURCHASE: {
|
|
1336
|
+
name: "custom_purchase",
|
|
1337
|
+
destinations: [
|
|
1338
|
+
"DataLayer"
|
|
1339
|
+
],
|
|
1340
|
+
requiredParams: [
|
|
1341
|
+
"brand",
|
|
1342
|
+
"shipping_tier",
|
|
1343
|
+
"line_items",
|
|
1344
|
+
"currency",
|
|
1345
|
+
"value",
|
|
1346
|
+
"shipping",
|
|
1347
|
+
"transaction_id",
|
|
1348
|
+
"total_discount",
|
|
1349
|
+
"payment_type",
|
|
1350
|
+
"seller_cod_name",
|
|
1351
|
+
"subtotal",
|
|
1352
|
+
"coupon",
|
|
1353
|
+
"items"
|
|
1354
|
+
]
|
|
1355
|
+
},
|
|
1356
|
+
CUSTOM_USER_INFO: {
|
|
1357
|
+
name: "custom_user_info",
|
|
1358
|
+
destinations: [
|
|
1359
|
+
"DataLayer"
|
|
1360
|
+
],
|
|
1361
|
+
requiredParams: [
|
|
1362
|
+
"user_info"
|
|
1363
|
+
]
|
|
1364
|
+
},
|
|
1365
|
+
NOTIFY_ME: {
|
|
1366
|
+
name: "notify_me",
|
|
1367
|
+
destinations: [
|
|
1368
|
+
"DataLayer"
|
|
1369
|
+
],
|
|
1370
|
+
requiredParams: [
|
|
1371
|
+
"brand",
|
|
1372
|
+
"line_items",
|
|
1373
|
+
"size",
|
|
1374
|
+
"item_ref"
|
|
1375
|
+
]
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
var paymentTypeMap = [
|
|
1379
|
+
[
|
|
1380
|
+
"vale",
|
|
1381
|
+
"vale cr\xE9dito"
|
|
1382
|
+
],
|
|
1383
|
+
[
|
|
1384
|
+
"pagaleve",
|
|
1385
|
+
"pix"
|
|
1386
|
+
],
|
|
1387
|
+
[
|
|
1388
|
+
"pix parcel",
|
|
1389
|
+
"pix parcelado"
|
|
1390
|
+
],
|
|
1391
|
+
[
|
|
1392
|
+
"pix",
|
|
1393
|
+
"pix"
|
|
1394
|
+
],
|
|
1395
|
+
[
|
|
1396
|
+
"apple",
|
|
1397
|
+
"apple pay"
|
|
1398
|
+
],
|
|
1399
|
+
[
|
|
1400
|
+
"google",
|
|
1401
|
+
"google pay"
|
|
1402
|
+
],
|
|
1403
|
+
[
|
|
1404
|
+
"boleto",
|
|
1405
|
+
"boleto"
|
|
1406
|
+
],
|
|
1407
|
+
[
|
|
1408
|
+
"paypal",
|
|
1409
|
+
"paypal"
|
|
1410
|
+
],
|
|
1411
|
+
[
|
|
1412
|
+
"cred",
|
|
1413
|
+
"cart\xE3o"
|
|
1414
|
+
],
|
|
1415
|
+
[
|
|
1416
|
+
"visa",
|
|
1417
|
+
"cart\xE3o"
|
|
1418
|
+
],
|
|
1419
|
+
[
|
|
1420
|
+
"master",
|
|
1421
|
+
"cart\xE3o"
|
|
1422
|
+
],
|
|
1423
|
+
[
|
|
1424
|
+
"amex",
|
|
1425
|
+
"cart\xE3o"
|
|
1426
|
+
],
|
|
1427
|
+
[
|
|
1428
|
+
"elo",
|
|
1429
|
+
"cart\xE3o"
|
|
1430
|
+
],
|
|
1431
|
+
[
|
|
1432
|
+
"hiper",
|
|
1433
|
+
"cart\xE3o"
|
|
1434
|
+
],
|
|
1435
|
+
[
|
|
1436
|
+
"diner",
|
|
1437
|
+
"cart\xE3o"
|
|
1438
|
+
],
|
|
1439
|
+
[
|
|
1440
|
+
"deb",
|
|
1441
|
+
"cart\xE3o"
|
|
1442
|
+
]
|
|
1443
|
+
];
|
|
1444
|
+
// src/adapters/index.ts
|
|
1445
|
+
var adapters = {
|
|
1446
|
+
DataLayer: pushToDataLayer,
|
|
1447
|
+
Dito: pushToDito
|
|
1448
|
+
};
|
|
1449
|
+
var BRAND_CODES = {
|
|
1450
|
+
farm: "farmrio",
|
|
1451
|
+
"farm etc": "farmetc",
|
|
1452
|
+
"farm rio": "farmrio"
|
|
1453
|
+
};
|
|
1454
|
+
// src/params/index.ts
|
|
1455
|
+
var paramGetters = {
|
|
1456
|
+
brand: getBrand,
|
|
1457
|
+
items: getItems,
|
|
1458
|
+
payment_type: getPaymentType,
|
|
1459
|
+
user_info: function(context, eventName) {
|
|
1460
|
+
return _async_to_generator(function() {
|
|
1461
|
+
var _PROD_DOMAINS_, PROD_DOMAINS, domain, api, response, _;
|
|
1462
|
+
return _ts_generator(this, function(_state) {
|
|
1463
|
+
switch(_state.label){
|
|
1464
|
+
case 0:
|
|
1465
|
+
PROD_DOMAINS = {
|
|
1466
|
+
"animale": {
|
|
1467
|
+
"store": "https://www.animale.com.br",
|
|
1468
|
+
"checkout": "https://secure.animale.com.br"
|
|
1469
|
+
},
|
|
1470
|
+
"farm": {
|
|
1471
|
+
"store": "https://lojafarm.myvtex.com"
|
|
1472
|
+
},
|
|
1473
|
+
"mariafilo": {
|
|
1474
|
+
"store": "https://mariafilo.myvtex.com",
|
|
1475
|
+
"checkout": "https://secure.mariafilo.com.br"
|
|
1476
|
+
},
|
|
1477
|
+
"crisbarros": {
|
|
1478
|
+
"store": "https://lojacrisbarros.myvtex.com",
|
|
1479
|
+
"checkout": "https://secure.lojacrisbarros.com.br"
|
|
1480
|
+
},
|
|
1481
|
+
"lojaoffpremium": {
|
|
1482
|
+
"store": "https://lojaoffpremium.myvtex.com",
|
|
1483
|
+
"checkout": "https://secure.lojaoffpremium.com.br"
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
domain = (_PROD_DOMAINS_ = PROD_DOMAINS[context.account || "https://www.animale.com.br"]) === null || _PROD_DOMAINS_ === void 0 ? void 0 : _PROD_DOMAINS_[context.platform || "store"];
|
|
1487
|
+
if (!domain) return [
|
|
1488
|
+
2,
|
|
1489
|
+
null
|
|
1490
|
+
];
|
|
1491
|
+
_state.label = 1;
|
|
1492
|
+
case 1:
|
|
1493
|
+
_state.trys.push([
|
|
1494
|
+
1,
|
|
1495
|
+
4,
|
|
1496
|
+
,
|
|
1497
|
+
5
|
|
1498
|
+
]);
|
|
1499
|
+
api = "".concat(domain, "/_v/user-info");
|
|
1500
|
+
return [
|
|
1501
|
+
4,
|
|
1502
|
+
fetch(api, {
|
|
1503
|
+
method: "POST",
|
|
1504
|
+
body: JSON.stringify({
|
|
1505
|
+
email: context.userEmail
|
|
1506
|
+
})
|
|
1507
|
+
})
|
|
1508
|
+
];
|
|
1509
|
+
case 2:
|
|
1510
|
+
response = _state.sent();
|
|
1511
|
+
return [
|
|
1512
|
+
4,
|
|
1513
|
+
response.json()
|
|
1514
|
+
];
|
|
1515
|
+
case 3:
|
|
1516
|
+
return [
|
|
1517
|
+
2,
|
|
1518
|
+
_state.sent()
|
|
1519
|
+
];
|
|
1520
|
+
case 4:
|
|
1521
|
+
_ = _state.sent();
|
|
1522
|
+
return [
|
|
1523
|
+
2,
|
|
1524
|
+
null
|
|
1525
|
+
];
|
|
1526
|
+
case 5:
|
|
1527
|
+
return [
|
|
1528
|
+
2
|
|
1529
|
+
];
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
})();
|
|
1533
|
+
},
|
|
1534
|
+
content_type: function(context, eventName) {
|
|
1535
|
+
return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
1536
|
+
},
|
|
1537
|
+
region: function(context, eventName) {
|
|
1538
|
+
return context.region || null;
|
|
1539
|
+
},
|
|
1540
|
+
line_items: function(context, eventName) {
|
|
1541
|
+
if (context === null || context === void 0 ? void 0 : context.lineItems) return context.lineItems;
|
|
1542
|
+
if (context === null || context === void 0 ? void 0 : context.item) {
|
|
1543
|
+
return [
|
|
1544
|
+
context.item.productId || context.item.productID || context.item.item_id
|
|
1545
|
+
];
|
|
1546
|
+
}
|
|
1547
|
+
if (context === null || context === void 0 ? void 0 : context.list) {
|
|
1548
|
+
return context.list.map(function(item) {
|
|
1549
|
+
return item.productID;
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
return (context.orderForm.items || []).map(function(item) {
|
|
1553
|
+
return item.productId;
|
|
1554
|
+
}).join(",");
|
|
1555
|
+
},
|
|
1556
|
+
currency: function(context, eventName) {
|
|
1557
|
+
var _context_orderForm_storePreferencesData, _context_orderForm;
|
|
1558
|
+
if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
|
|
1559
|
+
if (context === null || context === void 0 ? void 0 : context.bannerUrl) return "BRL";
|
|
1560
|
+
if (context === null || context === void 0 ? void 0 : context.item) {
|
|
1561
|
+
var _context_item_offers, _context_item;
|
|
1562
|
+
return ((_context_item = context.item) === null || _context_item === void 0 ? void 0 : (_context_item_offers = _context_item.offers) === null || _context_item_offers === void 0 ? void 0 : _context_item_offers.priceCurrency) || "BRL";
|
|
1563
|
+
}
|
|
1564
|
+
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_storePreferencesData = _context_orderForm.storePreferencesData) === null || _context_orderForm_storePreferencesData === void 0 ? void 0 : _context_orderForm_storePreferencesData.currencyCode) || null;
|
|
1565
|
+
},
|
|
1566
|
+
value: function(context, eventName) {
|
|
1567
|
+
var _context_orderForm;
|
|
1568
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
1569
|
+
return context.item ? context.item.price : ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.value) != null ? context.orderForm.value / 100 : null;
|
|
1570
|
+
},
|
|
1571
|
+
total_discount: function(context, eventName) {
|
|
1572
|
+
var _context_orderForm, _context_orderForm1;
|
|
1573
|
+
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
1574
|
+
var discounts = totalsList.find(function(t) {
|
|
1575
|
+
return t.id === "Discounts";
|
|
1576
|
+
});
|
|
1577
|
+
return discounts ? Math.abs(discounts.value) / 100 : 0;
|
|
1578
|
+
},
|
|
1579
|
+
subtotal: function(context, eventName) {
|
|
1580
|
+
var _context_orderForm, _context_orderForm1;
|
|
1581
|
+
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
1582
|
+
var subtotal = totalsList.filter(function(t) {
|
|
1583
|
+
return t.id === "Items";
|
|
1584
|
+
}).reduce(function(acc, t) {
|
|
1585
|
+
return acc + (t.value || 0);
|
|
1586
|
+
}, 0) / 100 || 0;
|
|
1587
|
+
return subtotal;
|
|
1588
|
+
},
|
|
1589
|
+
coupon_message: function(context, eventName) {
|
|
1590
|
+
var _context_orderForm;
|
|
1591
|
+
if (context.couponMessage) return context.couponMessage;
|
|
1592
|
+
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
1593
|
+
if (messages.length === 0) return null;
|
|
1594
|
+
var couponMessages = messages.filter(function(msg) {
|
|
1595
|
+
return msg.text.toLowerCase().includes("cupom");
|
|
1596
|
+
});
|
|
1597
|
+
if (couponMessages.length === 0) return null;
|
|
1598
|
+
return couponMessages.map(function(msg) {
|
|
1599
|
+
return msg.text;
|
|
1600
|
+
}).join(" | ");
|
|
1601
|
+
},
|
|
1602
|
+
seller_cod_name: function(context, eventName) {
|
|
1603
|
+
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
1604
|
+
},
|
|
1605
|
+
coupon: function(context, eventName) {
|
|
1606
|
+
var _context_orderForm_marketingData, _context_orderForm;
|
|
1607
|
+
return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
|
|
1608
|
+
},
|
|
1609
|
+
pre_filled: function(context, eventName) {
|
|
1610
|
+
return !!context.preFilled;
|
|
1611
|
+
},
|
|
1612
|
+
search_term: function(context, eventName) {
|
|
1613
|
+
return context.searchTerm || null;
|
|
1614
|
+
},
|
|
1615
|
+
search_found: function(context, eventName) {
|
|
1616
|
+
return !!context.searchFound;
|
|
1617
|
+
},
|
|
1618
|
+
search_quantity: function(context, eventName) {
|
|
1619
|
+
return context.searchQuantity || 0;
|
|
1620
|
+
},
|
|
1621
|
+
promotion_name: function(context, eventName) {
|
|
1622
|
+
return context.promotionName || null;
|
|
1623
|
+
},
|
|
1624
|
+
creative_name: function(context, eventName) {
|
|
1625
|
+
return context.creativeName || null;
|
|
1626
|
+
},
|
|
1627
|
+
creative_slot: function(context, eventName) {
|
|
1628
|
+
return context.creativeSlot || null;
|
|
1629
|
+
},
|
|
1630
|
+
zipcode: function(context, eventName) {
|
|
1631
|
+
return context.zipCode || null;
|
|
1632
|
+
},
|
|
1633
|
+
size: function(context, eventName) {
|
|
1634
|
+
return context.size || null;
|
|
1635
|
+
},
|
|
1636
|
+
item_ref: function(context, eventName) {
|
|
1637
|
+
return context.itemRef || null;
|
|
1638
|
+
},
|
|
1639
|
+
flag_pickup: function(context, eventName) {
|
|
1640
|
+
var _orderForm_shippingData;
|
|
1641
|
+
var orderForm = context.orderForm;
|
|
1642
|
+
if (!orderForm) return null;
|
|
1643
|
+
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
1644
|
+
var hasPickup = logisticsInfo.some(function(info) {
|
|
1645
|
+
var _info_slas;
|
|
1646
|
+
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
1647
|
+
return sla.deliveryChannel === "pickup-in-point";
|
|
1648
|
+
});
|
|
1649
|
+
});
|
|
1650
|
+
return hasPickup;
|
|
1651
|
+
},
|
|
1652
|
+
shippings: function(context, eventName) {
|
|
1653
|
+
var orderForm = context.orderForm;
|
|
1654
|
+
if (!orderForm) return null;
|
|
1655
|
+
var groupShipping = {};
|
|
1656
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1657
|
+
try {
|
|
1658
|
+
for(var _iterator = orderForm.shippingData.logisticsInfo[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1659
|
+
var info = _step.value;
|
|
1660
|
+
var item = orderForm.items[info.itemIndex];
|
|
1661
|
+
if (!item) continue;
|
|
1662
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
1663
|
+
try {
|
|
1664
|
+
for(var _iterator1 = info.slas[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
1665
|
+
var sla = _step1.value;
|
|
1666
|
+
var key = sla.name;
|
|
1667
|
+
if (!groupShipping[key]) {
|
|
1668
|
+
groupShipping[key] = {
|
|
1669
|
+
shipping_tier: sla.name,
|
|
1670
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
1671
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
1672
|
+
line_items: []
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
groupShipping[key].line_items.push(item.id);
|
|
1676
|
+
}
|
|
1677
|
+
} catch (err) {
|
|
1678
|
+
_didIteratorError1 = true;
|
|
1679
|
+
_iteratorError1 = err;
|
|
1680
|
+
} finally{
|
|
1681
|
+
try {
|
|
1682
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1683
|
+
_iterator1.return();
|
|
1684
|
+
}
|
|
1685
|
+
} finally{
|
|
1686
|
+
if (_didIteratorError1) {
|
|
1687
|
+
throw _iteratorError1;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
} catch (err) {
|
|
1693
|
+
_didIteratorError = true;
|
|
1694
|
+
_iteratorError = err;
|
|
1695
|
+
} finally{
|
|
1696
|
+
try {
|
|
1697
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1698
|
+
_iterator.return();
|
|
1699
|
+
}
|
|
1700
|
+
} finally{
|
|
1701
|
+
if (_didIteratorError) {
|
|
1702
|
+
throw _iteratorError;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
var shippings = Object.values(groupShipping).map(function(s) {
|
|
1707
|
+
return {
|
|
1708
|
+
shipping: s.shipping,
|
|
1709
|
+
shipping_tier: s.shipping_tier,
|
|
1710
|
+
delivery_time: s.delivery_time,
|
|
1711
|
+
line_items: s.line_items.join(",")
|
|
1712
|
+
};
|
|
1713
|
+
});
|
|
1714
|
+
return shippings || null;
|
|
1715
|
+
},
|
|
1716
|
+
shipping: function(context, eventName) {
|
|
1717
|
+
var _ref;
|
|
1718
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
1719
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
1720
|
+
return logistics.reduce(function(total, item) {
|
|
1721
|
+
var _ref;
|
|
1722
|
+
var _item_slas;
|
|
1723
|
+
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
1724
|
+
return sla.id === item.selectedSla;
|
|
1725
|
+
});
|
|
1726
|
+
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
1727
|
+
}, 0);
|
|
1728
|
+
},
|
|
1729
|
+
shipping_tier: function(context, eventName) {
|
|
1730
|
+
var _ref;
|
|
1731
|
+
var _context_orderForm_shippingData, _context_orderForm, _selected_slas;
|
|
1732
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
1733
|
+
var selected = logistics.find(function(item) {
|
|
1734
|
+
return item.selectedSla;
|
|
1735
|
+
});
|
|
1736
|
+
if (!selected) return null;
|
|
1737
|
+
var sla = (_selected_slas = selected.slas) === null || _selected_slas === void 0 ? void 0 : _selected_slas.find(function(s) {
|
|
1738
|
+
return s.id === selected.selectedSla;
|
|
1739
|
+
});
|
|
1740
|
+
if (!sla) return null;
|
|
1741
|
+
var deliveryChannel = sla.deliveryChannel, name = sla.name, pickupStoreInfo = sla.pickupStoreInfo;
|
|
1742
|
+
return deliveryChannel === "pickup-in-point" ? "retirada em loja".concat((pickupStoreInfo === null || pickupStoreInfo === void 0 ? void 0 : pickupStoreInfo.friendlyName) ? ": ".concat(pickupStoreInfo.friendlyName) : "") : deliveryChannel === "delivery" ? "receba em casa".concat(name ? ": ".concat(name) : "") : null;
|
|
1743
|
+
},
|
|
1744
|
+
transaction_id: function(context, eventName) {
|
|
1745
|
+
var _context_orderForm_orderGroup, _context_orderForm;
|
|
1746
|
+
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
|
|
1747
|
+
},
|
|
1748
|
+
available_grid: function(context, eventName) {
|
|
1749
|
+
return context.availableGrid || null;
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
var src_default = {
|
|
1753
|
+
trackWebEvent: trackWebEvent,
|
|
1754
|
+
EVENTS: EVENTS
|
|
1755
|
+
};
|
|
1756
|
+
return __toCommonJS(src_exports);
|
|
1757
|
+
}();
|