@searchspring/snap-controller 0.39.3 → 0.41.0
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/Abstract/AbstractController.d.ts.map +1 -1
- package/dist/cjs/Abstract/AbstractController.js +1 -0
- package/dist/cjs/Autocomplete/AutocompleteController.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteController.js +35 -22
- package/dist/cjs/Recommendation/RecommendationController.d.ts +3 -2
- package/dist/cjs/Recommendation/RecommendationController.d.ts.map +1 -1
- package/dist/cjs/Recommendation/RecommendationController.js +155 -129
- package/dist/cjs/Search/SearchController.d.ts.map +1 -1
- package/dist/cjs/Search/SearchController.js +78 -74
- package/dist/cjs/types.d.ts +2 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Abstract/AbstractController.d.ts.map +1 -1
- package/dist/esm/Abstract/AbstractController.js +1 -0
- package/dist/esm/Autocomplete/AutocompleteController.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteController.js +16 -11
- package/dist/esm/Recommendation/RecommendationController.d.ts +3 -2
- package/dist/esm/Recommendation/RecommendationController.d.ts.map +1 -1
- package/dist/esm/Recommendation/RecommendationController.js +153 -128
- package/dist/esm/Search/SearchController.d.ts.map +1 -1
- package/dist/esm/Search/SearchController.js +44 -42
- package/dist/esm/types.d.ts +2 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractController.d.ts","sourceRoot":"","sources":["../../../src/Abstract/AbstractController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,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AE,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS;IAIhG,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS;IASnD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgD3B,QAAQ,IAAI,IAAI;aAMP,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAE1B,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAIpD,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;CAoC1C"}
|
|
@@ -89,6 +89,7 @@ var AbstractController = /** @class */ (function () {
|
|
|
89
89
|
errortimestamp: timeStamp,
|
|
90
90
|
};
|
|
91
91
|
_this.tracker.track.error(beaconPayload);
|
|
92
|
+
_this.eventManager.fire('error', { controller: _this, error: err });
|
|
92
93
|
}
|
|
93
94
|
};
|
|
94
95
|
if (typeof config != 'object' || typeof config.id != 'string' || !config.id.match(/^[a-zA-Z0-9_-]*$/)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteController.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteController.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"AutocompleteController.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteController.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA8C,MAAM,+BAA+B,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+B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wE3B,cAAc,QAAa,QAAQ,IAAI,CAAC,CAwBtC;IAEF,MAAM,QAAa,QAAQ,IAAI,CAAC,CAiH9B;CACF"}
|
|
@@ -91,6 +91,9 @@ var defaultConfig = {
|
|
|
91
91
|
trim: true,
|
|
92
92
|
pinFiltered: true,
|
|
93
93
|
},
|
|
94
|
+
redirects: {
|
|
95
|
+
merchandising: true,
|
|
96
|
+
},
|
|
94
97
|
},
|
|
95
98
|
};
|
|
96
99
|
var AutocompleteController = /** @class */ (function (_super) {
|
|
@@ -275,7 +278,7 @@ var AutocompleteController = /** @class */ (function (_super) {
|
|
|
275
278
|
}
|
|
276
279
|
},
|
|
277
280
|
keyUp: function (e) {
|
|
278
|
-
var _a, _b, _c, _d, _e;
|
|
281
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
279
282
|
// ignore enter and escape keys
|
|
280
283
|
if ((e === null || e === void 0 ? void 0 : e.keyCode) == KEY_ENTER || (e === null || e === void 0 ? void 0 : e.keyCode) == KEY_ESCAPE)
|
|
281
284
|
return;
|
|
@@ -303,8 +306,12 @@ var AutocompleteController = /** @class */ (function (_super) {
|
|
|
303
306
|
if (((_c = _this.store.trending) === null || _c === void 0 ? void 0 : _c.length) && ((_e = (_d = _this.config.settings) === null || _d === void 0 ? void 0 : _d.trending) === null || _e === void 0 ? void 0 : _e.showResults)) {
|
|
304
307
|
_this.store.trending[0].preview();
|
|
305
308
|
}
|
|
309
|
+
else if (((_f = _this.store.history) === null || _f === void 0 ? void 0 : _f.length) && ((_h = (_g = _this.config.settings) === null || _g === void 0 ? void 0 : _g.history) === null || _h === void 0 ? void 0 : _h.showResults)) {
|
|
310
|
+
_this.store.history[0].preview();
|
|
311
|
+
}
|
|
306
312
|
}
|
|
307
313
|
else {
|
|
314
|
+
_this.store.resetTerms();
|
|
308
315
|
_this.handlers.input.timeoutDelay = setTimeout(function () {
|
|
309
316
|
_this.store.state.locks.terms.unlock();
|
|
310
317
|
_this.store.state.locks.facets.unlock();
|
|
@@ -553,6 +560,23 @@ var AutocompleteController = /** @class */ (function (_super) {
|
|
|
553
560
|
}
|
|
554
561
|
});
|
|
555
562
|
}); });
|
|
563
|
+
_this.eventManager.on('beforeSubmit', function (ac, next) { return __awaiter(_this, void 0, void 0, function () {
|
|
564
|
+
var redirectURL;
|
|
565
|
+
var _a, _b, _c, _d;
|
|
566
|
+
return __generator(this, function (_e) {
|
|
567
|
+
switch (_e.label) {
|
|
568
|
+
case 0: return [4 /*yield*/, next()];
|
|
569
|
+
case 1:
|
|
570
|
+
_e.sent();
|
|
571
|
+
redirectURL = (_a = ac.controller.store.merchandising) === null || _a === void 0 ? void 0 : _a.redirect;
|
|
572
|
+
if (redirectURL && ((_d = (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.settings) === null || _c === void 0 ? void 0 : _c.redirects) === null || _d === void 0 ? void 0 : _d.merchandising)) {
|
|
573
|
+
window.location.href = redirectURL;
|
|
574
|
+
return [2 /*return*/, false];
|
|
575
|
+
}
|
|
576
|
+
return [2 /*return*/];
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
}); });
|
|
556
580
|
// attach config plugins and event middleware
|
|
557
581
|
_this.use(_this.config);
|
|
558
582
|
return _this;
|
|
@@ -599,28 +623,27 @@ var AutocompleteController = /** @class */ (function (_super) {
|
|
|
599
623
|
configurable: true
|
|
600
624
|
});
|
|
601
625
|
AutocompleteController.prototype.setFocused = function (inputElement) {
|
|
602
|
-
var _a, _b, _c, _d, _e;
|
|
603
626
|
return __awaiter(this, void 0, void 0, function () {
|
|
604
627
|
var err_7, err_8;
|
|
605
|
-
return __generator(this, function (
|
|
606
|
-
switch (
|
|
628
|
+
return __generator(this, function (_a) {
|
|
629
|
+
switch (_a.label) {
|
|
607
630
|
case 0:
|
|
608
631
|
if (!(this.store.state.focusedInput !== inputElement)) return [3 /*break*/, 7];
|
|
609
632
|
this.store.state.focusedInput = inputElement;
|
|
610
|
-
|
|
633
|
+
_a.label = 1;
|
|
611
634
|
case 1:
|
|
612
|
-
|
|
613
|
-
|
|
635
|
+
_a.trys.push([1, 6, , 7]);
|
|
636
|
+
_a.label = 2;
|
|
614
637
|
case 2:
|
|
615
|
-
|
|
638
|
+
_a.trys.push([2, 4, , 5]);
|
|
616
639
|
return [4 /*yield*/, this.eventManager.fire('focusChange', {
|
|
617
640
|
controller: this,
|
|
618
641
|
})];
|
|
619
642
|
case 3:
|
|
620
|
-
|
|
643
|
+
_a.sent();
|
|
621
644
|
return [3 /*break*/, 5];
|
|
622
645
|
case 4:
|
|
623
|
-
err_7 =
|
|
646
|
+
err_7 = _a.sent();
|
|
624
647
|
if ((err_7 === null || err_7 === void 0 ? void 0 : err_7.message) == 'cancelled') {
|
|
625
648
|
this.log.warn("'focusChange' middleware cancelled");
|
|
626
649
|
}
|
|
@@ -631,23 +654,13 @@ var AutocompleteController = /** @class */ (function (_super) {
|
|
|
631
654
|
return [3 /*break*/, 5];
|
|
632
655
|
case 5: return [3 /*break*/, 7];
|
|
633
656
|
case 6:
|
|
634
|
-
err_8 =
|
|
657
|
+
err_8 = _a.sent();
|
|
635
658
|
if (err_8) {
|
|
636
659
|
console.error(err_8);
|
|
637
660
|
}
|
|
638
661
|
return [3 /*break*/, 7];
|
|
639
662
|
case 7:
|
|
640
|
-
|
|
641
|
-
if (inputElement &&
|
|
642
|
-
!((_a = this.store.state) === null || _a === void 0 ? void 0 : _a.input) &&
|
|
643
|
-
((_b = this.store.trending) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
644
|
-
!((_c = this.store.terms) === null || _c === void 0 ? void 0 : _c.length) &&
|
|
645
|
-
((_e = (_d = this.config.settings) === null || _d === void 0 ? void 0 : _d.trending) === null || _e === void 0 ? void 0 : _e.showResults)) {
|
|
646
|
-
this.store.trending[0].preview();
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
inputElement === null || inputElement === void 0 ? void 0 : inputElement.dispatchEvent(new Event('keyup'));
|
|
650
|
-
}
|
|
663
|
+
inputElement === null || inputElement === void 0 ? void 0 : inputElement.dispatchEvent(new Event('keyup'));
|
|
651
664
|
return [2 /*return*/];
|
|
652
665
|
}
|
|
653
666
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Product } from '@searchspring/snap-store-mobx';
|
|
2
|
+
import { BeaconEvent } from '@searchspring/snap-tracker';
|
|
1
3
|
import { AbstractController } from '../Abstract/AbstractController';
|
|
2
4
|
import { ControllerTypes } from '../types';
|
|
3
|
-
import { BeaconEvent } from '@searchspring/snap-tracker';
|
|
4
5
|
import type { RecommendationStore } from '@searchspring/snap-store-mobx';
|
|
5
6
|
import type { RecommendationControllerConfig, ControllerServices, ContextVariables } from '../types';
|
|
6
7
|
declare type RecommendationTrackMethods = {
|
|
@@ -11,7 +12,7 @@ declare type RecommendationTrackMethods = {
|
|
|
11
12
|
};
|
|
12
13
|
click: (e: MouseEvent) => BeaconEvent | undefined;
|
|
13
14
|
impression: () => BeaconEvent | undefined;
|
|
14
|
-
render: () => BeaconEvent | undefined;
|
|
15
|
+
render: (results?: Product[]) => BeaconEvent | undefined;
|
|
15
16
|
};
|
|
16
17
|
declare type RecommendCombinedRequestModel = {
|
|
17
18
|
tag: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecommendationController.d.ts","sourceRoot":"","sources":["../../../src/Recommendation/RecommendationController.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RecommendationController.d.ts","sourceRoot":"","sources":["../../../src/Recommendation/RecommendationController.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE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,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,UAAU,CAAC,EAAE,WAAW,CAAC;YAAC,MAAM,CAAC,EAAE,WAAW,CAAA;SAAE,CAAC,CAAC;KAC7E,CAKC;gBAGD,MAAM,EAAE,8BAA8B,EACtC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,CAAC,EAAE,gBAAgB;IA8B3B,KAAK,EAAE,0BAA0B,CAiM5B;IAEL,IAAI,MAAM,IAAI,6BAA6B,CA0B1C;IAED,MAAM,QAAa,QAAQ,IAAI,CAAC,CAsG9B;CACF"}
|
|
@@ -68,9 +68,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
68
68
|
exports.RecommendationController = void 0;
|
|
69
69
|
var deepmerge_1 = __importDefault(require("deepmerge"));
|
|
70
70
|
var snap_tracker_1 = require("@searchspring/snap-tracker");
|
|
71
|
+
var snap_store_mobx_1 = require("@searchspring/snap-store-mobx");
|
|
71
72
|
var AbstractController_1 = require("../Abstract/AbstractController");
|
|
72
73
|
var types_1 = require("../types");
|
|
73
|
-
var snap_store_mobx_1 = require("@searchspring/snap-store-mobx");
|
|
74
74
|
var defaultConfig = {
|
|
75
75
|
id: 'recommend',
|
|
76
76
|
tag: '',
|
|
@@ -90,13 +90,124 @@ var RecommendationController = /** @class */ (function (_super) {
|
|
|
90
90
|
render: undefined,
|
|
91
91
|
product: {},
|
|
92
92
|
};
|
|
93
|
-
_this.track = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
_this.track = (function () {
|
|
94
|
+
var getSeed = function () {
|
|
95
|
+
var skus = [];
|
|
96
|
+
switch (_this.store.profile.placement) {
|
|
97
|
+
case snap_tracker_1.ProfilePlacement.PRODUCTPAGE:
|
|
98
|
+
if (_this.config.globals.product) {
|
|
99
|
+
skus = [_this.config.globals.product];
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case snap_tracker_1.ProfilePlacement.BASKETPAGE:
|
|
103
|
+
skus = _this.tracker.cookies.cart.get(); // this is an array
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (skus.length) {
|
|
109
|
+
return skus.map(function (sku) { return ({
|
|
110
|
+
sku: sku,
|
|
111
|
+
}); });
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
product: {
|
|
116
|
+
click: function (e, result) {
|
|
117
|
+
var _a;
|
|
118
|
+
if (!_this.store.profile.tag || !result)
|
|
119
|
+
return;
|
|
120
|
+
//set the profile click every time
|
|
121
|
+
_this.track.click(e);
|
|
122
|
+
var payload = {
|
|
123
|
+
type: snap_tracker_1.BeaconType.PROFILE_PRODUCT_CLICK,
|
|
124
|
+
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
125
|
+
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
126
|
+
event: {
|
|
127
|
+
context: {
|
|
128
|
+
action: 'navigate',
|
|
129
|
+
placement: _this.store.profile.placement,
|
|
130
|
+
tag: _this.store.profile.tag,
|
|
131
|
+
type: 'product-recommendation',
|
|
132
|
+
},
|
|
133
|
+
product: {
|
|
134
|
+
id: result.id,
|
|
135
|
+
mappings: {
|
|
136
|
+
core: result.mappings.core,
|
|
137
|
+
},
|
|
138
|
+
seed: getSeed(),
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
pid: (_a = _this.events.click) === null || _a === void 0 ? void 0 : _a.id,
|
|
142
|
+
};
|
|
143
|
+
var event = _this.tracker.track.event(payload);
|
|
144
|
+
_this.eventManager.fire('track.product.click', { controller: _this, event: e, result: result, trackEvent: event });
|
|
145
|
+
return event;
|
|
146
|
+
},
|
|
147
|
+
impression: function (result) {
|
|
148
|
+
var _a;
|
|
149
|
+
if (!_this.store.profile.tag || !result || !_this.events.impression || (_this.events.product && ((_a = _this.events.product[result.id]) === null || _a === void 0 ? void 0 : _a.impression)))
|
|
150
|
+
return;
|
|
151
|
+
var payload = {
|
|
152
|
+
type: snap_tracker_1.BeaconType.PROFILE_PRODUCT_IMPRESSION,
|
|
153
|
+
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
154
|
+
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
155
|
+
event: {
|
|
156
|
+
context: {
|
|
157
|
+
placement: _this.store.profile.placement,
|
|
158
|
+
tag: _this.store.profile.tag,
|
|
159
|
+
type: 'product-recommendation',
|
|
160
|
+
},
|
|
161
|
+
product: {
|
|
162
|
+
id: result.id,
|
|
163
|
+
mappings: {
|
|
164
|
+
core: result.mappings.core,
|
|
165
|
+
},
|
|
166
|
+
seed: getSeed(),
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
pid: _this.events.impression.id,
|
|
170
|
+
};
|
|
171
|
+
_this.events.product[result.id] = _this.events.product[result.id] || {};
|
|
172
|
+
var event = (_this.events.product[result.id].impression = _this.tracker.track.event(payload));
|
|
173
|
+
_this.eventManager.fire('track.product.impression', { controller: _this, result: result, trackEvent: event });
|
|
174
|
+
return event;
|
|
175
|
+
},
|
|
176
|
+
render: function (result) {
|
|
177
|
+
var _a;
|
|
178
|
+
if (!_this.store.profile.tag || !result || !_this.events.render || ((_a = _this.events.product[result.id]) === null || _a === void 0 ? void 0 : _a.render))
|
|
179
|
+
return;
|
|
180
|
+
var payload = {
|
|
181
|
+
type: snap_tracker_1.BeaconType.PROFILE_PRODUCT_RENDER,
|
|
182
|
+
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
183
|
+
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
184
|
+
event: {
|
|
185
|
+
context: {
|
|
186
|
+
placement: _this.store.profile.placement,
|
|
187
|
+
tag: _this.store.profile.tag,
|
|
188
|
+
type: 'product-recommendation',
|
|
189
|
+
},
|
|
190
|
+
product: {
|
|
191
|
+
id: result.id,
|
|
192
|
+
mappings: {
|
|
193
|
+
core: result.mappings.core,
|
|
194
|
+
},
|
|
195
|
+
seed: getSeed(),
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
pid: _this.events.render.id,
|
|
199
|
+
};
|
|
200
|
+
_this.events.product[result.id] = _this.events.product[result.id] || {};
|
|
201
|
+
var event = (_this.events.product[result.id].render = _this.tracker.track.event(payload));
|
|
202
|
+
_this.eventManager.fire('track.product.render', { controller: _this, result: result, trackEvent: event });
|
|
203
|
+
return event;
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
click: function (e) {
|
|
207
|
+
if (!_this.store.profile.tag)
|
|
97
208
|
return;
|
|
98
|
-
var
|
|
99
|
-
type: snap_tracker_1.BeaconType.
|
|
209
|
+
var event = _this.tracker.track.event({
|
|
210
|
+
type: snap_tracker_1.BeaconType.PROFILE_CLICK,
|
|
100
211
|
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
101
212
|
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
102
213
|
event: {
|
|
@@ -106,26 +217,24 @@ var RecommendationController = /** @class */ (function (_super) {
|
|
|
106
217
|
tag: _this.store.profile.tag,
|
|
107
218
|
type: 'product-recommendation',
|
|
108
219
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
seed:
|
|
220
|
+
profile: {
|
|
221
|
+
tag: _this.store.profile.tag,
|
|
222
|
+
placement: _this.store.profile.placement,
|
|
223
|
+
threshold: _this.store.profile.display.threshold,
|
|
224
|
+
templateId: _this.store.profile.display.template.uuid,
|
|
225
|
+
seed: getSeed(),
|
|
115
226
|
},
|
|
116
227
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
_this.eventManager.fire('track.product.click', { controller: _this, event: e, result: result, trackEvent: event });
|
|
228
|
+
});
|
|
229
|
+
_this.events.click = event;
|
|
230
|
+
_this.eventManager.fire('track.click', { controller: _this, event: e, trackEvent: event });
|
|
121
231
|
return event;
|
|
122
232
|
},
|
|
123
|
-
impression: function (
|
|
124
|
-
|
|
125
|
-
if (!_this.store.profile.tag || !result || !_this.events.impression || (_this.events.product && ((_a = _this.events.product[result.id]) === null || _a === void 0 ? void 0 : _a.impression)))
|
|
233
|
+
impression: function () {
|
|
234
|
+
if (!_this.store.profile.tag || _this.events.impression)
|
|
126
235
|
return;
|
|
127
|
-
var
|
|
128
|
-
type: snap_tracker_1.BeaconType.
|
|
236
|
+
var event = _this.tracker.track.event({
|
|
237
|
+
type: snap_tracker_1.BeaconType.PROFILE_IMPRESSION,
|
|
129
238
|
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
130
239
|
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
131
240
|
event: {
|
|
@@ -134,27 +243,24 @@ var RecommendationController = /** @class */ (function (_super) {
|
|
|
134
243
|
tag: _this.store.profile.tag,
|
|
135
244
|
type: 'product-recommendation',
|
|
136
245
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
seed:
|
|
246
|
+
profile: {
|
|
247
|
+
tag: _this.store.profile.tag,
|
|
248
|
+
placement: _this.store.profile.placement,
|
|
249
|
+
threshold: _this.store.profile.display.threshold,
|
|
250
|
+
templateId: _this.store.profile.display.template.uuid,
|
|
251
|
+
seed: getSeed(),
|
|
143
252
|
},
|
|
144
253
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
_this.
|
|
148
|
-
var event = (_this.events.product[result.id].impression = _this.tracker.track.event(payload));
|
|
149
|
-
_this.eventManager.fire('track.product.impression', { controller: _this, result: result, trackEvent: event });
|
|
254
|
+
});
|
|
255
|
+
_this.events.impression = event;
|
|
256
|
+
_this.eventManager.fire('track.impression', { controller: _this, trackEvent: event });
|
|
150
257
|
return event;
|
|
151
258
|
},
|
|
152
|
-
render: function (
|
|
153
|
-
|
|
154
|
-
if (!_this.store.profile.tag || !result || !_this.events.render || ((_a = _this.events.product[result.id]) === null || _a === void 0 ? void 0 : _a.render))
|
|
259
|
+
render: function () {
|
|
260
|
+
if (!_this.store.profile.tag || _this.events.render)
|
|
155
261
|
return;
|
|
156
|
-
var
|
|
157
|
-
type: snap_tracker_1.BeaconType.
|
|
262
|
+
var event = _this.tracker.track.event({
|
|
263
|
+
type: snap_tracker_1.BeaconType.PROFILE_RENDER,
|
|
158
264
|
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
159
265
|
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
160
266
|
event: {
|
|
@@ -163,101 +269,21 @@ var RecommendationController = /** @class */ (function (_super) {
|
|
|
163
269
|
tag: _this.store.profile.tag,
|
|
164
270
|
type: 'product-recommendation',
|
|
165
271
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
seed:
|
|
272
|
+
profile: {
|
|
273
|
+
tag: _this.store.profile.tag,
|
|
274
|
+
placement: _this.store.profile.placement,
|
|
275
|
+
threshold: _this.store.profile.display.threshold,
|
|
276
|
+
templateId: _this.store.profile.display.template.uuid,
|
|
277
|
+
seed: getSeed(),
|
|
172
278
|
},
|
|
173
279
|
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
_this.
|
|
177
|
-
var event = (_this.events.product[result.id].render = _this.tracker.track.event(payload));
|
|
178
|
-
_this.eventManager.fire('track.product.render', { controller: _this, result: result, trackEvent: event });
|
|
280
|
+
});
|
|
281
|
+
_this.events.render = event;
|
|
282
|
+
_this.eventManager.fire('track.render', { controller: _this, trackEvent: event });
|
|
179
283
|
return event;
|
|
180
284
|
},
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!_this.store.profile.tag)
|
|
184
|
-
return;
|
|
185
|
-
var event = _this.tracker.track.event({
|
|
186
|
-
type: snap_tracker_1.BeaconType.PROFILE_CLICK,
|
|
187
|
-
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
188
|
-
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
189
|
-
event: {
|
|
190
|
-
context: {
|
|
191
|
-
action: 'navigate',
|
|
192
|
-
placement: _this.store.profile.placement,
|
|
193
|
-
tag: _this.store.profile.tag,
|
|
194
|
-
type: 'product-recommendation',
|
|
195
|
-
},
|
|
196
|
-
profile: {
|
|
197
|
-
tag: _this.store.profile.tag,
|
|
198
|
-
placement: _this.store.profile.placement,
|
|
199
|
-
threshold: _this.store.profile.display.threshold,
|
|
200
|
-
templateId: _this.store.profile.display.template.uuid,
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
_this.events.click = event;
|
|
205
|
-
_this.eventManager.fire('track.click', { controller: _this, event: e, trackEvent: event });
|
|
206
|
-
return event;
|
|
207
|
-
},
|
|
208
|
-
impression: function () {
|
|
209
|
-
if (!_this.store.profile.tag || _this.events.impression)
|
|
210
|
-
return;
|
|
211
|
-
var event = _this.tracker.track.event({
|
|
212
|
-
type: snap_tracker_1.BeaconType.PROFILE_IMPRESSION,
|
|
213
|
-
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
214
|
-
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
215
|
-
event: {
|
|
216
|
-
context: {
|
|
217
|
-
placement: _this.store.profile.placement,
|
|
218
|
-
tag: _this.store.profile.tag,
|
|
219
|
-
type: 'product-recommendation',
|
|
220
|
-
},
|
|
221
|
-
profile: {
|
|
222
|
-
tag: _this.store.profile.tag,
|
|
223
|
-
placement: _this.store.profile.placement,
|
|
224
|
-
threshold: _this.store.profile.display.threshold,
|
|
225
|
-
templateId: _this.store.profile.display.template.uuid,
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
_this.events.impression = event;
|
|
230
|
-
_this.eventManager.fire('track.impression', { controller: _this, trackEvent: event });
|
|
231
|
-
return event;
|
|
232
|
-
},
|
|
233
|
-
render: function () {
|
|
234
|
-
if (!_this.store.profile.tag || _this.events.render)
|
|
235
|
-
return;
|
|
236
|
-
var event = _this.tracker.track.event({
|
|
237
|
-
type: snap_tracker_1.BeaconType.PROFILE_RENDER,
|
|
238
|
-
category: snap_tracker_1.BeaconCategory.RECOMMENDATIONS,
|
|
239
|
-
context: _this.config.globals.siteId ? { website: { trackingCode: _this.config.globals.siteId } } : undefined,
|
|
240
|
-
event: {
|
|
241
|
-
context: {
|
|
242
|
-
placement: _this.store.profile.placement,
|
|
243
|
-
tag: _this.store.profile.tag,
|
|
244
|
-
type: 'product-recommendation',
|
|
245
|
-
},
|
|
246
|
-
profile: {
|
|
247
|
-
tag: _this.store.profile.tag,
|
|
248
|
-
placement: _this.store.profile.placement,
|
|
249
|
-
threshold: _this.store.profile.display.threshold,
|
|
250
|
-
templateId: _this.store.profile.display.template.uuid,
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
});
|
|
254
|
-
_this.events.render = event;
|
|
255
|
-
// track results render
|
|
256
|
-
_this.store.results.forEach(function (result) { return _this.track.product.render(result); });
|
|
257
|
-
_this.eventManager.fire('track.render', { controller: _this, trackEvent: event });
|
|
258
|
-
return event;
|
|
259
|
-
},
|
|
260
|
-
};
|
|
285
|
+
};
|
|
286
|
+
})();
|
|
261
287
|
_this.search = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
262
288
|
var params, err_1, searchProfile, response, afterSearchProfile, err_2, afterStoreProfile, err_3, err_4;
|
|
263
289
|
return __generator(this, function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchController.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,M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