@sentecacommerce-theme/lib 0.12.89 → 0.12.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analytics/Pixel/hooks/index.js +36 -0
- package/dist/cjs/analytics/Pixel/hooks/usePixelFinishOrder.js +27 -0
- package/dist/cjs/analytics/Pixel/hooks/usePixelProductClick.js +3 -7
- package/dist/cjs/analytics/Pixel/hooks/usePixelProductsImpression.js +42 -32
- package/dist/cjs/analytics/Pixel/hooks/usePixelViewBasket.js +24 -0
- package/dist/cjs/analytics/Pixel/hooks/usePixelViewCategory.js +29 -0
- package/dist/cjs/analytics/Pixel/mainScript.js +197 -14
- package/dist/cjs/analytics/Pixel/minifiedPixel.js +1 -1
- package/dist/cjs/analytics/Pixel/usePixel.js +3 -0
- package/dist/cjs/analytics/Pixel/utils.js +17 -0
- package/dist/cjs/hooks/ui-hooks/useAccordion/index.js +0 -1
- package/dist/cjs/listing/api/queries/useListingQuery.js +4 -2
- package/dist/cjs/listing/ssr/prefetchListing.js +2 -1
- package/dist/cjs/ui/components/GridStyles.js +36 -0
- package/dist/cjs/ui/components/index.js +12 -0
- package/dist/esm/analytics/Pixel/hooks/index.js +3 -0
- package/dist/esm/analytics/Pixel/hooks/usePixelFinishOrder.js +22 -0
- package/dist/esm/analytics/Pixel/hooks/usePixelProductClick.js +4 -8
- package/dist/esm/analytics/Pixel/hooks/usePixelProductsImpression.js +42 -32
- package/dist/esm/analytics/Pixel/hooks/usePixelViewBasket.js +19 -0
- package/dist/esm/analytics/Pixel/hooks/usePixelViewCategory.js +24 -0
- package/dist/esm/analytics/Pixel/mainScript.js +199 -14
- package/dist/esm/analytics/Pixel/minifiedPixel.js +1 -1
- package/dist/esm/analytics/Pixel/usePixel.js +3 -0
- package/dist/esm/analytics/Pixel/utils.js +12 -0
- package/dist/esm/hooks/ui-hooks/useAccordion/index.js +0 -1
- package/dist/esm/listing/api/queries/useListingQuery.js +4 -2
- package/dist/esm/listing/ssr/prefetchListing.js +2 -1
- package/dist/esm/ui/components/GridStyles.js +26 -0
- package/dist/esm/ui/components/index.js +1 -0
- package/dist/types/analytics/Pixel/hooks/index.d.ts +3 -0
- package/dist/types/analytics/Pixel/hooks/usePixelFinishOrder.d.ts +4 -0
- package/dist/types/analytics/Pixel/hooks/usePixelViewBasket.d.ts +4 -0
- package/dist/types/analytics/Pixel/hooks/usePixelViewCategory.d.ts +7 -0
- package/dist/types/analytics/Pixel/types.d.ts +9 -0
- package/dist/types/analytics/Pixel/utils.d.ts +3 -0
- package/dist/types/listing/api/queries/useListingQuery.d.ts +2 -1
- package/dist/types/listing/types.d.ts +3 -2
- package/dist/types/ui/components/GridStyles.d.ts +10 -0
- package/dist/types/ui/components/index.d.ts +1 -0
- package/package.json +4 -4
@@ -38,6 +38,42 @@ Object.keys(_usePixelProductClick).forEach(function(key) {
|
|
38
38
|
}
|
39
39
|
});
|
40
40
|
});
|
41
|
+
var _usePixelViewBasket = _interopRequireWildcard(require("./usePixelViewBasket"));
|
42
|
+
Object.keys(_usePixelViewBasket).forEach(function(key) {
|
43
|
+
if (key === "default" || key === "__esModule") return;
|
44
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
45
|
+
if (key in exports && exports[key] === _usePixelViewBasket[key]) return;
|
46
|
+
Object.defineProperty(exports, key, {
|
47
|
+
enumerable: true,
|
48
|
+
get: function() {
|
49
|
+
return _usePixelViewBasket[key];
|
50
|
+
}
|
51
|
+
});
|
52
|
+
});
|
53
|
+
var _usePixelViewCategory = _interopRequireWildcard(require("./usePixelViewCategory"));
|
54
|
+
Object.keys(_usePixelViewCategory).forEach(function(key) {
|
55
|
+
if (key === "default" || key === "__esModule") return;
|
56
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
57
|
+
if (key in exports && exports[key] === _usePixelViewCategory[key]) return;
|
58
|
+
Object.defineProperty(exports, key, {
|
59
|
+
enumerable: true,
|
60
|
+
get: function() {
|
61
|
+
return _usePixelViewCategory[key];
|
62
|
+
}
|
63
|
+
});
|
64
|
+
});
|
65
|
+
var _usePixelFinishOrder = _interopRequireWildcard(require("./usePixelFinishOrder"));
|
66
|
+
Object.keys(_usePixelFinishOrder).forEach(function(key) {
|
67
|
+
if (key === "default" || key === "__esModule") return;
|
68
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
69
|
+
if (key in exports && exports[key] === _usePixelFinishOrder[key]) return;
|
70
|
+
Object.defineProperty(exports, key, {
|
71
|
+
enumerable: true,
|
72
|
+
get: function() {
|
73
|
+
return _usePixelFinishOrder[key];
|
74
|
+
}
|
75
|
+
});
|
76
|
+
});
|
41
77
|
var _useDistrictMeta = _interopRequireWildcard(require("./useDistrictMeta"));
|
42
78
|
Object.keys(_useDistrictMeta).forEach(function(key) {
|
43
79
|
if (key === "default" || key === "__esModule") return;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
2
|
+
value: true
|
3
|
+
});
|
4
|
+
exports.usePixelFinishOrder = void 0;
|
5
|
+
var _utils = require("../utils");
|
6
|
+
var _typeof = function(obj) {
|
7
|
+
"@swc/helpers - typeof";
|
8
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
9
|
+
};
|
10
|
+
var usePixelFinishOrder = function() {
|
11
|
+
var sendFinishOrderEvent = function(order) {
|
12
|
+
var payload = {
|
13
|
+
orderId: order.orderRefNumber,
|
14
|
+
productsData: (0, _utils).mapProducts(order.lineItems)
|
15
|
+
};
|
16
|
+
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
|
17
|
+
var pixel = window.pixel;
|
18
|
+
if (payload) {
|
19
|
+
pixel === null || pixel === void 0 ? void 0 : pixel.finishOrder(payload);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
};
|
23
|
+
return {
|
24
|
+
sendFinishOrderEvent: sendFinishOrderEvent
|
25
|
+
};
|
26
|
+
};
|
27
|
+
exports.usePixelFinishOrder = usePixelFinishOrder;
|
@@ -37,18 +37,14 @@ function _objectSpread(target) {
|
|
37
37
|
}
|
38
38
|
return target;
|
39
39
|
}
|
40
|
-
var _typeof = function(obj) {
|
41
|
-
"@swc/helpers - typeof";
|
42
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
43
|
-
};
|
44
40
|
var usePixelProductClick = function() {
|
45
41
|
var defaultMerchant = (0, _index).useConfigState().defaultMerchant;
|
46
42
|
var sendClickEvent = function(param) {
|
47
43
|
var product = param.product, info = param.info;
|
48
|
-
if ((
|
44
|
+
if ((0, _index).canUseDOM() && defaultMerchant) {
|
49
45
|
var pixel = window.pixel;
|
50
|
-
pixel.productClick(product, _objectSpread({}, info, {
|
51
|
-
merchantKey: defaultMerchant
|
46
|
+
pixel === null || pixel === void 0 ? void 0 : pixel.productClick(product, _objectSpread({}, info, {
|
47
|
+
merchantKey: defaultMerchant
|
52
48
|
}));
|
53
49
|
}
|
54
50
|
};
|
@@ -6,6 +6,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
6
6
|
var _router = require("next/router");
|
7
7
|
var _index = require("../../../index");
|
8
8
|
var _releva = require("../../Releva");
|
9
|
+
var _utils = require("../../../utils");
|
9
10
|
function _arrayLikeToArray(arr, len) {
|
10
11
|
if (len == null || len > arr.length) len = arr.length;
|
11
12
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
@@ -49,10 +50,6 @@ function _nonIterableRest() {
|
|
49
50
|
function _slicedToArray(arr, i) {
|
50
51
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
51
52
|
}
|
52
|
-
var _typeof = function(obj) {
|
53
|
-
"@swc/helpers - typeof";
|
54
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
55
|
-
};
|
56
53
|
function _unsupportedIterableToArray(o, minLen) {
|
57
54
|
if (!o) return;
|
58
55
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
@@ -63,43 +60,56 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
63
60
|
}
|
64
61
|
var usePixelProductsImpression = function(param) {
|
65
62
|
var productsData = param.productsData, isCarousel = param.isCarousel;
|
66
|
-
var
|
63
|
+
var ref5;
|
64
|
+
var ref1 = _slicedToArray((0, _index).useBoolean(false), 2), sentAlready = ref1[0], setSentAlready = ref1[1];
|
67
65
|
var defaultMerchant = (0, _index).useConfigState().defaultMerchant;
|
68
66
|
var router = (0, _router).useRouter();
|
69
67
|
var products = [];
|
70
68
|
if (!isCarousel) {
|
71
|
-
products = (0, _releva).createMappedProducts(productsData.products);
|
69
|
+
products = (0, _releva).createMappedProducts(productsData === null || productsData === void 0 ? void 0 : productsData.products);
|
72
70
|
}
|
73
71
|
_react.default.useEffect(function() {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
72
|
+
setSentAlready.off();
|
73
|
+
}, [
|
74
|
+
router.asPath,
|
75
|
+
productsData === null || productsData === void 0 ? void 0 : (ref5 = productsData.products) === null || ref5 === void 0 ? void 0 : ref5.length,
|
76
|
+
setSentAlready
|
77
|
+
]);
|
78
|
+
_react.default.useEffect(function() {
|
79
|
+
var ref, ref2, ref3;
|
80
|
+
if (sentAlready || !(products === null || products === void 0 ? void 0 : products.length)) return;
|
81
|
+
if ((0, _utils).canUseDOM() && !((ref = productsData.products) === null || ref === void 0 ? void 0 : (ref2 = ref[0]) === null || ref2 === void 0 ? void 0 : ref2.isPlaceholder) && (productsData === null || productsData === void 0 ? void 0 : (ref3 = productsData.products) === null || ref3 === void 0 ? void 0 : ref3.length) > 0) {
|
82
|
+
var ref4;
|
83
|
+
var pixel = window.pixel;
|
84
|
+
var title = window === null || window === void 0 ? void 0 : (ref4 = window.document) === null || ref4 === void 0 ? void 0 : ref4.title;
|
85
|
+
var sendImpressions = function() {
|
86
|
+
if (!title || title === 'за') {
|
87
|
+
setTimeout(function() {
|
88
|
+
return sendImpressions();
|
89
|
+
}, 20);
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
pixel === null || pixel === void 0 ? void 0 : pixel.productsImpression(!isCarousel ? [
|
93
|
+
{
|
94
|
+
listName: title,
|
95
|
+
products: products
|
87
96
|
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
products: products
|
92
|
-
}
|
93
|
-
] : productsData, {
|
94
|
-
merchantKey: defaultMerchant || ''
|
95
|
-
});
|
96
|
-
};
|
97
|
-
sendImpressions();
|
97
|
+
] : productsData, {
|
98
|
+
merchantKey: defaultMerchant || ''
|
99
|
+
});
|
98
100
|
setSentAlready.on();
|
99
|
-
}
|
100
|
-
|
101
|
+
};
|
102
|
+
sendImpressions();
|
103
|
+
}
|
101
104
|
}, [
|
102
|
-
router.route
|
105
|
+
router.route,
|
106
|
+
defaultMerchant,
|
107
|
+
sentAlready,
|
108
|
+
products,
|
109
|
+
router.events,
|
110
|
+
productsData,
|
111
|
+
setSentAlready,
|
112
|
+
isCarousel,
|
103
113
|
]);
|
104
114
|
};
|
105
115
|
exports.usePixelProductsImpression = usePixelProductsImpression;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
2
|
+
value: true
|
3
|
+
});
|
4
|
+
exports.usePixelViewBasket = void 0;
|
5
|
+
var _utils = require("../utils");
|
6
|
+
var _typeof = function(obj) {
|
7
|
+
"@swc/helpers - typeof";
|
8
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
9
|
+
};
|
10
|
+
var usePixelViewBasket = function() {
|
11
|
+
var sendViewBasketEvent = function(data) {
|
12
|
+
var payload = (0, _utils).mapProducts(data);
|
13
|
+
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
|
14
|
+
var pixel = window.pixel;
|
15
|
+
if (payload) {
|
16
|
+
pixel === null || pixel === void 0 ? void 0 : pixel.viewBasket(payload);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
};
|
20
|
+
return {
|
21
|
+
sendViewBasketEvent: sendViewBasketEvent
|
22
|
+
};
|
23
|
+
};
|
24
|
+
exports.usePixelViewBasket = usePixelViewBasket;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
2
|
+
value: true
|
3
|
+
});
|
4
|
+
exports.usePixelViewCategory = void 0;
|
5
|
+
var _typeof = function(obj) {
|
6
|
+
"@swc/helpers - typeof";
|
7
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
8
|
+
};
|
9
|
+
var usePixelViewCategory = function() {
|
10
|
+
var sendViewCategoryEvent = function(breadcrumbData) {
|
11
|
+
var breadcrumbString = breadcrumbData.reduce(function(res, curr, index) {
|
12
|
+
res += curr.name;
|
13
|
+
if (index !== breadcrumbData.length - 1) {
|
14
|
+
res += '/';
|
15
|
+
}
|
16
|
+
return res;
|
17
|
+
}, '');
|
18
|
+
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
|
19
|
+
var pixel = window.pixel;
|
20
|
+
if (breadcrumbString) {
|
21
|
+
pixel === null || pixel === void 0 ? void 0 : pixel.viewCategory(breadcrumbString);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
};
|
25
|
+
return {
|
26
|
+
sendViewCategoryEvent: sendViewCategoryEvent
|
27
|
+
};
|
28
|
+
};
|
29
|
+
exports.usePixelViewCategory = usePixelViewCategory;
|
@@ -88,16 +88,6 @@ function _objectSpread(target) {
|
|
88
88
|
}
|
89
89
|
});
|
90
90
|
}
|
91
|
-
function ensureStringValuesMayExist() {
|
92
|
-
var params = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, keys = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
93
|
-
keys.forEach(function(k) {
|
94
|
-
if (params[k]) {
|
95
|
-
if (typeof params[k] !== 'string') {
|
96
|
-
err("".concat(k, " is empty or contains invalid string value"));
|
97
|
-
}
|
98
|
-
}
|
99
|
-
});
|
100
|
-
}
|
101
91
|
function ensureStringValuesExist() {
|
102
92
|
var params = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, keys = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
103
93
|
keys.forEach(function(k) {
|
@@ -115,18 +105,20 @@ function _objectSpread(target) {
|
|
115
105
|
//check the config
|
116
106
|
if (typeof global.pixel_cfg !== 'object') {
|
117
107
|
err('Pixel is missing config');
|
118
|
-
} else if (!global.pixel_cfg.initialUserId || !global.pixel_cfg.appName) {
|
119
|
-
err('Missing required pixel config fields. Please check if appName and initialUserId are present.');
|
108
|
+
} else if (!global.pixel_cfg.hubUrl || !global.pixel_cfg.initialUserId || !global.pixel_cfg.appName) {
|
109
|
+
err('Missing required pixel config fields. Please check if appName, hubUrl and initialUserId are present.');
|
120
110
|
}
|
121
111
|
/**
|
112
|
+
* hubUrl = the url of the integration hub
|
122
113
|
* source = name of the client interface eg: app, website
|
123
114
|
* debug = either or not to print logs
|
124
115
|
* initialUserId = the initial id of the user/visitor
|
125
|
-
*/ var _pixel_cfg = global.pixel_cfg, appName = _pixel_cfg.appName, _source = _pixel_cfg.source, source = _source === void 0 ? 'web-client' : _source, _debug = _pixel_cfg.debug, debug = _debug === void 0 ? false : _debug, initialUserId = _pixel_cfg.initialUserId;
|
116
|
+
*/ var _pixel_cfg = global.pixel_cfg, hubUrl = _pixel_cfg.hubUrl, appName = _pixel_cfg.appName, _source = _pixel_cfg.source, source = _source === void 0 ? 'web-client' : _source, _debug = _pixel_cfg.debug, debug = _debug === void 0 ? false : _debug, _criteoPartnerId = _pixel_cfg.criteoPartnerId, criteoPartnerId = _criteoPartnerId === void 0 ? false : _criteoPartnerId, _rtbHouseHash = _pixel_cfg.rtbHouseHash, rtbHouseHash = _rtbHouseHash === void 0 ? false : _rtbHouseHash, initialUserId = _pixel_cfg.initialUserId;
|
126
117
|
var Q = [] //events queue
|
127
118
|
;
|
128
119
|
var userId = initialUserId //is modified upon setUserId
|
129
120
|
;
|
121
|
+
var userEmail = '';
|
130
122
|
var title = undefined;
|
131
123
|
var allowTracking = false //should explicity state positive intention
|
132
124
|
;
|
@@ -161,8 +153,9 @@ function _objectSpread(target) {
|
|
161
153
|
log("sending.. payload=".concat(JSON.stringify(payload)));
|
162
154
|
_ctx.prev = 1;
|
163
155
|
_ctx.next = 4;
|
164
|
-
return fetch("/
|
156
|
+
return fetch("".concat(hubUrl, "/analytics/collect"), {
|
165
157
|
method: 'POST',
|
158
|
+
mode: 'cors',
|
166
159
|
cache: 'no-cache',
|
167
160
|
headers: {
|
168
161
|
'Content-Type': 'application/json'
|
@@ -199,6 +192,54 @@ function _objectSpread(target) {
|
|
199
192
|
log("adding new event to queue ".concat(JSON.stringify(enrichedPayload)));
|
200
193
|
Q.push(enrichedPayload);
|
201
194
|
}
|
195
|
+
function dispatchCriteoEvents(events) {
|
196
|
+
if (criteoPartnerId) {
|
197
|
+
window.criteo_q = window.criteo_q || [];
|
198
|
+
window.criteo_q.push(events);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
function sendRtbRequest(tag) {
|
202
|
+
if (rtbHouseHash) {
|
203
|
+
try {
|
204
|
+
var rtbTags = [
|
205
|
+
"pr_".concat(rtbHouseHash, "_").concat(tag)
|
206
|
+
];
|
207
|
+
rtbTags.push("pr_".concat(rtbHouseHash, "_lid_").concat(getLid()));
|
208
|
+
var ifr = document.createElement('iframe'), sr = encodeURIComponent(document.referrer ? document.referrer : ''), su = encodeURIComponent(document.location.href ? document.location.href : ''), tmstmp = encodeURIComponent('' + Date.now());
|
209
|
+
var ifrSrc = 'https://creativecdn.com/tags?type=iframe';
|
210
|
+
for(var i = 0; i < rtbTags.length; i++){
|
211
|
+
ifrSrc += '&id=' + encodeURIComponent(rtbTags[i]);
|
212
|
+
}
|
213
|
+
ifrSrc += "&su=".concat(su, "&sr=").concat(sr, "&ts=").concat(tmstmp);
|
214
|
+
ifr.setAttribute('src', ifrSrc);
|
215
|
+
ifr.setAttribute('width', '1');
|
216
|
+
ifr.setAttribute('height', '1');
|
217
|
+
ifr.setAttribute('scrolling', 'no');
|
218
|
+
ifr.setAttribute('frameBorder', '0');
|
219
|
+
ifr.setAttribute('style', 'display:none');
|
220
|
+
ifr.setAttribute('referrerpolicy', 'no-referrer-when-downgrade');
|
221
|
+
if (document.body) {
|
222
|
+
document.body.appendChild(ifr);
|
223
|
+
} else {
|
224
|
+
window.addEventListener('DOMContentLoaded', function() {
|
225
|
+
document.body.appendChild(ifr);
|
226
|
+
});
|
227
|
+
}
|
228
|
+
} catch (e) {
|
229
|
+
log(e);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
function getLid() {
|
234
|
+
var key = '__rtbhouse.lid', lid = window.localStorage.getItem(key);
|
235
|
+
if (!lid) {
|
236
|
+
lid = '';
|
237
|
+
var pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
238
|
+
for(var i = 0; i < 20; i++)lid += pool.charAt(Math.floor(Math.random() * pool.length));
|
239
|
+
window.localStorage.setItem(key, lid);
|
240
|
+
}
|
241
|
+
return lid;
|
242
|
+
}
|
202
243
|
function loop() {
|
203
244
|
var iid = global.setTimeout(_asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
|
204
245
|
var ev;
|
@@ -236,6 +277,113 @@ function _objectSpread(target) {
|
|
236
277
|
]);
|
237
278
|
})), 500);
|
238
279
|
}
|
280
|
+
var criteoAPI = {
|
281
|
+
loadCriteo: function loadCriteo() {
|
282
|
+
if (criteoPartnerId) {
|
283
|
+
log('Loading criteo');
|
284
|
+
var criteo = document.createElement('script');
|
285
|
+
criteo.setAttribute('src', "//dynamic.criteo.com/js/ld/ld.js?a=".concat(criteoPartnerId));
|
286
|
+
document.head.appendChild(criteo);
|
287
|
+
dispatchCriteoEvents([
|
288
|
+
{
|
289
|
+
event: 'setAccount',
|
290
|
+
account: criteoPartnerId
|
291
|
+
},
|
292
|
+
{
|
293
|
+
event: 'setEmail',
|
294
|
+
email: userEmail
|
295
|
+
},
|
296
|
+
{
|
297
|
+
event: 'setSiteType',
|
298
|
+
type: isTouchDevice() ? 'm' : 'd'
|
299
|
+
},
|
300
|
+
]);
|
301
|
+
}
|
302
|
+
log('criteo partner id not set');
|
303
|
+
},
|
304
|
+
criteoViewHome: function criteoViewHome() {
|
305
|
+
console.log('criteoViewHome');
|
306
|
+
dispatchCriteoEvents({
|
307
|
+
event: 'viewHome'
|
308
|
+
});
|
309
|
+
},
|
310
|
+
//productData: [{ id: sku, price, quantity}]
|
311
|
+
criteoViewBasket: function criteoViewBasket(productsData) {
|
312
|
+
dispatchCriteoEvents({
|
313
|
+
event: 'viewBasket',
|
314
|
+
item: productsData
|
315
|
+
});
|
316
|
+
},
|
317
|
+
//productData: { sku }
|
318
|
+
criteoViewItem: function criteoViewItem(productData) {
|
319
|
+
dispatchCriteoEvents({
|
320
|
+
event: 'viewItem',
|
321
|
+
item: productData.sku
|
322
|
+
});
|
323
|
+
},
|
324
|
+
//products: [{ sku }]
|
325
|
+
criteoViewList: function criteoViewList(products) {
|
326
|
+
var items = products.map(function(product) {
|
327
|
+
return product.sku;
|
328
|
+
});
|
329
|
+
dispatchCriteoEvents({
|
330
|
+
event: 'viewList',
|
331
|
+
item: items
|
332
|
+
});
|
333
|
+
},
|
334
|
+
//orderId: Order ref number
|
335
|
+
//productData: [{ id: sku, price, quantity}]
|
336
|
+
criteoFinishOrder: function criteoFinishOrder(orderId, productsData) {
|
337
|
+
dispatchCriteoEvents({
|
338
|
+
event: 'trackTransaction',
|
339
|
+
id: orderId,
|
340
|
+
item: productsData
|
341
|
+
});
|
342
|
+
},
|
343
|
+
criteoChangeEmail: function criteoChangeEmail(email) {
|
344
|
+
dispatchCriteoEvents({
|
345
|
+
event: 'setEmail',
|
346
|
+
email: email
|
347
|
+
});
|
348
|
+
}
|
349
|
+
};
|
350
|
+
var rtbAPI = {
|
351
|
+
rtbViewHome: function rtbViewHome() {
|
352
|
+
sendRtbRequest("home");
|
353
|
+
},
|
354
|
+
//productData: [{ id: sku}]
|
355
|
+
rtbViewBasket: function rtbViewBasket(productsData) {
|
356
|
+
sendRtbRequest("basketstatus_".concat(productsData.map(function(product) {
|
357
|
+
return product.sku;
|
358
|
+
}).join(',')));
|
359
|
+
},
|
360
|
+
//productData: { sku }
|
361
|
+
rtbViewItem: function rtbViewItem(productData) {
|
362
|
+
sendRtbRequest("offer_".concat(productData.sku));
|
363
|
+
},
|
364
|
+
//products: [{ sku }]
|
365
|
+
rtbViewList: function rtbViewList(products) {
|
366
|
+
var items = products.map(function(product) {
|
367
|
+
return product.sku;
|
368
|
+
});
|
369
|
+
sendRtbRequest("listing_".concat(items[0], ",").concat(items[1], ",").concat(items[2], ",").concat(items[3], ",").concat(items[4]));
|
370
|
+
},
|
371
|
+
//categoryBreadcrumb: string
|
372
|
+
rtbViewCategory: function rtbViewCategory(categoryBreadcrumb) {
|
373
|
+
sendRtbRequest("category2_".concat(categoryBreadcrumb));
|
374
|
+
},
|
375
|
+
rtbStartOrder: function rtbStartOrder() {
|
376
|
+
sendRtbRequest("startorder");
|
377
|
+
},
|
378
|
+
//orderId: Order ref number
|
379
|
+
//productData: [{ id: sku, price, quantity}]
|
380
|
+
rtbFinishOrder: function rtbFinishOrder(orderId, productsData, orderPrice) {
|
381
|
+
var productIds = productsData.map(function(product) {
|
382
|
+
return product.sku;
|
383
|
+
}).join(',');
|
384
|
+
sendRtbRequest("orderstatus2_".concat(orderPrice, "_").concat(orderId, "_").concat(productIds));
|
385
|
+
}
|
386
|
+
};
|
239
387
|
function buildProductPayload(productData) {
|
240
388
|
var payload = {};
|
241
389
|
ensureStringValuesExist(productData, [
|
@@ -279,9 +427,33 @@ function _objectSpread(target) {
|
|
279
427
|
addEventToQueue('land', eventPayload);
|
280
428
|
}
|
281
429
|
},
|
430
|
+
viewHome: function viewHome() {
|
431
|
+
console.log('viewHome');
|
432
|
+
criteoAPI.criteoViewHome();
|
433
|
+
rtbAPI.rtbViewHome();
|
434
|
+
},
|
435
|
+
//productsData: [{ id: sku, price, quantity}]
|
436
|
+
viewBasket: function viewBasket(productDetails) {
|
437
|
+
criteoAPI.criteoViewBasket(productDetails);
|
438
|
+
rtbAPI.rtbViewBasket(productDetails);
|
439
|
+
},
|
440
|
+
//categoryBreadcrumb
|
441
|
+
viewCategory: function(categoryBreadcrumb) {
|
442
|
+
rtbAPI.rtbViewCategory(categoryBreadcrumb);
|
443
|
+
},
|
444
|
+
//orderId: Order ref number
|
445
|
+
//productsData: [{ id: sku, price, quantity}]
|
446
|
+
//orderPrice: total price of order
|
447
|
+
finishOrder: function finishOrder(orderId, productsData, orderPrice) {
|
448
|
+
criteoAPI.criteoFinishOrder(orderId, productsData);
|
449
|
+
rtbAPI.rtbFinishOrder(orderId, productsData, orderPrice);
|
450
|
+
},
|
282
451
|
//used when user logs in or other occasion on which the id in cookie changes
|
283
452
|
changeUser: function changeUser(newUserId) {
|
453
|
+
var newUserEmail = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '';
|
284
454
|
userId = newUserId;
|
455
|
+
userEmail = newUserEmail;
|
456
|
+
criteoAPI.criteoChangeEmail(userEmail);
|
285
457
|
},
|
286
458
|
//Should be set on each app start/refresh. Marks if IP & other user data can be tracked
|
287
459
|
agreeTracking: function agreeTracking() {
|
@@ -318,6 +490,8 @@ function _objectSpread(target) {
|
|
318
490
|
var eventPayload = productLists.map(function(list) {
|
319
491
|
var name = list.listName;
|
320
492
|
var merchantKey = priceData.merchantKey;
|
493
|
+
criteoAPI.criteoViewList(list.products);
|
494
|
+
rtbAPI.rtbViewList(list.products);
|
321
495
|
var products = list.products.map(function(product) {
|
322
496
|
return buildProductPayload(product);
|
323
497
|
});
|
@@ -334,6 +508,8 @@ function _objectSpread(target) {
|
|
334
508
|
ensureStringValuesExist(priceData, [
|
335
509
|
'merchantKey'
|
336
510
|
]);
|
511
|
+
criteoAPI.criteoViewItem(productData);
|
512
|
+
rtbAPI.rtbViewItem(productData);
|
337
513
|
var product = buildProductPayload(productData);
|
338
514
|
addEventToQueue('productDetails', _objectSpread({
|
339
515
|
product: product
|
@@ -362,6 +538,9 @@ function _objectSpread(target) {
|
|
362
538
|
}, priceData));
|
363
539
|
},
|
364
540
|
checkoutStep: function checkoutStep(orderId, stepNumber) {
|
541
|
+
if (stepNumber === 1) {
|
542
|
+
rtbAPI.rtbStartOrder(orderId);
|
543
|
+
}
|
365
544
|
ensureIsStringValue('orderId', orderId);
|
366
545
|
addEventToQueue('checkoutStep', {
|
367
546
|
orderId: orderId,
|
@@ -377,7 +556,11 @@ function _objectSpread(target) {
|
|
377
556
|
});
|
378
557
|
}
|
379
558
|
};
|
559
|
+
criteoAPI.loadCriteo();
|
380
560
|
API.__system__.land();
|
381
561
|
global.pixel = API;
|
562
|
+
function isTouchDevice() {
|
563
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
564
|
+
}
|
382
565
|
loop();
|
383
566
|
})(window);
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
});
|
4
4
|
exports.PixelScript = void 0;
|
5
5
|
var PixelScript = function() {
|
6
|
-
return '!function(
|
6
|
+
return '!function(n){function a(e){t&&console.info(e)}function o(e){throw new Error(e)}function r(t={},e=[]){e.forEach(e=>{"string"!=typeof t[e]&&o(`${e} is empty or contains invalid string value`)})}function c(e="",t={}){"string"!=typeof t&&o(`${e} is empty or contains invalid string value`)}"object"!=typeof n.pixel_cfg?o("Pixel is missing config"):n.pixel_cfg.hubUrl&&n.pixel_cfg.initialUserId&&n.pixel_cfg.appName||o("Missing required pixel config fields. Please check if appName, hubUrl and initialUserId are present.");const{hubUrl:s,appName:i,source:u="web-client",debug:t=!1,criteoPartnerId:d=!1,rtbHouseHash:l=!1,initialUserId:m}=n.pixel_cfg,p=[];let f=m,h="",g=void 0,w=!1;function y(e,t={}){(t={name:e,data:t}).meta={userId:f,appName:i,allowTracking:w,source:u,userAgent:n.navigator.userAgent,location:n.location.href,language:n.navigator.language,charset:n.document.characterSet,title:g=g??n.document.title,referrer:n.document.referrer,screenResolution:`${n.screen.width}x${n.screen.height}`,viewportSize:`${n.innerWidth}x${n.innerHeight}`};a(`adding new event to queue ${JSON.stringify(t)}`),p.push(t)}function v(e){d&&(window.criteo_q=window.criteo_q||[],window.criteo_q.push(e))}function b(e){if(l)try{const i=[`pr_${l}_${e}`];i.push(`pr_${l}_lid_${function(){let e="__rtbhouse.lid",t=window.localStorage.getItem(e);if(!t){t="";var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let e=0;e<20;e++)t+=i.charAt(Math.floor(Math.random()*i.length));window.localStorage.setItem(e,t)}return t}()}`);const n=document.createElement("iframe"),o=encodeURIComponent(document.referrer||""),r=encodeURIComponent(document.location.href||""),c=encodeURIComponent(""+Date.now());let t="https://creativecdn.com/tags?type=iframe";for(let e=0;e<i.length;e++)t+="&id="+encodeURIComponent(i[e]);t+=`&su=${r}&sr=${o}&ts=${c}`,n.setAttribute("src",t),n.setAttribute("width","1"),n.setAttribute("height","1"),n.setAttribute("scrolling","no"),n.setAttribute("frameBorder","0"),n.setAttribute("style","display:none"),n.setAttribute("referrerpolicy","no-referrer-when-downgrade"),document.body?document.body.appendChild(n):window.addEventListener("DOMContentLoaded",function(){document.body.appendChild(n)})}catch(e){a(e)}}const $={loadCriteo:function(){if(d){a("Loading criteo");let e=document.createElement("script");e.setAttribute("src",`//dynamic.criteo.com/js/ld/ld.js?a=${d}`),document.head.appendChild(e),v([{event:"setAccount",account:d},{event:"setEmail",email:h},{event:"setSiteType",type:"ontouchstart"in window||0<navigator.maxTouchPoints||0<navigator.msMaxTouchPoints?"m":"d"}])}a("criteo partner id not set")},criteoViewHome:function(){console.log("criteoViewHome"),v({event:"viewHome"})},criteoViewBasket:function(e){v({event:"viewBasket",item:e})},criteoViewItem:function(e){v({event:"viewItem",item:e.sku})},criteoViewList:function(e){v({event:"viewList",item:e.map(e=>e.sku)})},criteoFinishOrder:function(e,t){v({event:"trackTransaction",id:e,item:t})},criteoChangeEmail:function(e){v({event:"setEmail",email:e})}},_={rtbViewHome:function(){b("home")},rtbViewBasket:function(e){b(`basketstatus_${e.map(e=>e.sku).join(",")}`)},rtbViewItem:function(e){b(`offer_${e.sku}`)},rtbViewList:function(e){e=e.map(e=>e.sku);b(`listing_${e[0]},${e[1]},${e[2]},${e[3]},${e[4]}`)},rtbViewCategory:function(e){b(`category2_${e}`)},rtbStartOrder:function(){b("startorder")},rtbFinishOrder:function(e,t,i){b(`orderstatus2_${i}_${e}_${t.map(e=>e.sku).join(",")}`)}};function k(e){let t={};var i,n;return r(e,["id","sku"]),[i={},n]=[e,["quantity"]],n.forEach(e=>{i[e]&&Number.isNaN(Number(i[e]))&&o(`${e} is empty or contains invalid numeric value`)}),t.id=e.id,t.sku=e.sku,t.quantity&&(t.quantity=e.quantity),t}function I(e){let t={};var i,n;return r(e,["listName","merchantKey"]),[i={},n]=[e,["position"]],n.forEach(e=>{Number.isNaN(Number(i[e]))&&o(`${e} is empty or contains invalid numeric value`)}),t.listName=e.listName,t.position=e.position,t.merchantKey=e.merchantKey,t}var e={__system__:{land:function(){y("land",{originalQuery:n.location.search})}},viewHome:function(){console.log("viewHome"),$.criteoViewHome(),_.rtbViewHome()},viewBasket:function(e){$.criteoViewBasket(e),_.rtbViewBasket(e)},viewCategory(e){_.rtbViewCategory(e)},finishOrder:function(e,t,i){$.criteoFinishOrder(e,t),_.rtbFinishOrder(e,t,i)},changeUser:function(e,t=""){f=e,h=t,$.criteoChangeEmail(h)},agreeTracking:function(){w=!0},changeRoute:function(e={}){let t={};r(e,["path","title","location"]),g=e.title,t.path=e.path,t.title=e.title,t.location=e.location,y("changeRoute",t)},productClick:function(e={},t={}){y("productClick",{product:k(e),click:I(t)})},productsImpression:function(e=[],n={}){r(n,["merchantKey"]),y("productsImpression",e.map(function(e){var t=e.listName,i=n.merchantKey;return $.criteoViewList(e.products),_.rtbViewList(e.products),{name:t,merchantKey:i,products:e.products.map(k)}}))},productDetails:function(e={},t={}){r(t,["merchantKey"]),$.criteoViewItem(e),_.rtbViewItem(e),y("productDetails",{product:k(e),...t})},addLineItem:function(e={},t={}){r(t,["currencyCode","merchantKey"]),y("addLineItem",{product:k(e),...t})},removeLineItem:function(e={},t={}){r(t,["currencyCode","merchantKey"]),y("removeLineItem",{product:k(e),...t})},checkoutStep:function(e,t){1===t&&_.rtbStartOrder(e),c("orderId",e),y("checkoutStep",{orderId:e,stepNumber:t})},checkoutStepOption:function(e,t,i){c("orderId",e),y("checkoutStepOption",{orderId:e,stepNumber:t,optionName:i})}};$.loadCriteo(),e.__system__.land(),n.pixel=e,function t(){let i=n.setTimeout(async function(){if(a("loop"),m&&p.length){var e=p.shift();try{await async function(e){a(`sending.. payload=${JSON.stringify(e)}`);try{await fetch(`${s}/analytics/collect`,{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){console.error(`Failed to send event.. ${e.message}`)}}(e)}catch(e){a(`Failed to send event.. ${e.message}`)}}n.clearInterval(i),t()},500)}()}(window);';
|
7
7
|
};
|
8
8
|
exports.PixelScript = PixelScript;
|
@@ -26,6 +26,9 @@ var pixelChangeRoute = function() {
|
|
26
26
|
}, 20);
|
27
27
|
return;
|
28
28
|
}
|
29
|
+
if (_router.default.router.asPath === '/') {
|
30
|
+
pixel === null || pixel === void 0 ? void 0 : pixel.viewHome();
|
31
|
+
}
|
29
32
|
return pixel === null || pixel === void 0 ? void 0 : pixel.changeRoute({
|
30
33
|
path: _router.default.router.asPath,
|
31
34
|
title: title || 'Error',
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
2
|
+
value: true
|
3
|
+
});
|
4
|
+
exports.mapProducts = void 0;
|
5
|
+
var mapProducts = function(data) {
|
6
|
+
var mapped = data === null || data === void 0 ? void 0 : data.reduce(function(res, cur) {
|
7
|
+
var ref, ref1;
|
8
|
+
res.push({
|
9
|
+
id: cur.variant.sku,
|
10
|
+
price: (Number((ref = cur.totalPrice) === null || ref === void 0 ? void 0 : ref.centAmount) / Math.pow(10, Number((ref1 = cur.totalPrice) === null || ref1 === void 0 ? void 0 : ref1.fractionDigits))).toFixed(2),
|
11
|
+
quantity: cur.quantity + ''
|
12
|
+
});
|
13
|
+
return res;
|
14
|
+
}, []);
|
15
|
+
return mapped;
|
16
|
+
};
|
17
|
+
exports.mapProducts = mapProducts;
|
@@ -179,11 +179,11 @@ function processListingQuery(_) {
|
|
179
179
|
}
|
180
180
|
function _processListingQuery() {
|
181
181
|
_processListingQuery = _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee(param) {
|
182
|
-
var predicate, router, limit, sort, postFilter, offset, config, slug, query, type, filter, _sort;
|
182
|
+
var predicate, router, limit, sort, postFilter, offset, config, slug, _includeVariants, includeVariants, query, type, filter, _sort;
|
183
183
|
return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
|
184
184
|
while(1)switch(_ctx.prev = _ctx.next){
|
185
185
|
case 0:
|
186
|
-
predicate = param.predicate, router = param.router, limit = param.limit, sort = param.sort, postFilter = param.postFilter, offset = param.offset, config = param.config, slug = param.slug;
|
186
|
+
predicate = param.predicate, router = param.router, limit = param.limit, sort = param.sort, postFilter = param.postFilter, offset = param.offset, config = param.config, slug = param.slug, _includeVariants = param.includeVariants, includeVariants = _includeVariants === void 0 ? false : _includeVariants;
|
187
187
|
query = router.query;
|
188
188
|
type = (0, _utils).getListingPageType(router, slug, config);
|
189
189
|
filter = generateFilter(type, query, slug, predicate);
|
@@ -201,6 +201,8 @@ function _processListingQuery() {
|
|
201
201
|
postFilter: postFilter
|
202
202
|
}, (config === null || config === void 0 ? void 0 : config.collapseMode) && type !== _types.ListingTypesEnum.Collection && {
|
203
203
|
collapseMode: config === null || config === void 0 ? void 0 : config.collapseMode
|
204
|
+
}, {
|
205
|
+
includeVariants: includeVariants
|
204
206
|
})));
|
205
207
|
case 6:
|
206
208
|
case "end":
|