@getlupa/client 0.14.4 → 0.15.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.
@@ -58,7 +58,7 @@ export default class SearchResults extends Vue {
58
58
  }) => void;
59
59
  mounted(): void;
60
60
  beforeDestroy(): void;
61
- trackItemListView(title: string): void;
61
+ trackItemListView(title: string, items?: Record<string, unknown>[]): void;
62
62
  handleMounted(): void;
63
63
  handleParamsChange(): void;
64
64
  addSearchResult: (searchResult: SearchQueryResult) => SearchQueryResult;
@@ -1,4 +1,5 @@
1
1
  import { DocumentElement } from "@/types/DocumentElement";
2
+ import { TrackingOptions } from "@/types/General";
2
3
  import { TrackableEventData } from "@/types/search-box/Common";
3
4
  import { BadgeOptions } from "@/types/search-results/BadgeOptions";
4
5
  import { ResultsLayout } from "@/types/search-results/ResultsLayout";
@@ -15,6 +16,7 @@ export default class SearchResultsProductCard extends Vue {
15
16
  layout: ResultsLayout;
16
17
  searchResultsRoutingBehavior: RoutingBehavior;
17
18
  searchResultOptions: SearchResultsOptions;
19
+ trackingOptions: TrackingOptions;
18
20
  query: string;
19
21
  trackClick: ({ queryKey, data, }: {
20
22
  queryKey: string;
@@ -12429,6 +12429,7 @@ let SearchBoxProduct = class SearchBoxProduct extends Vue$1 {
12429
12429
  analytics: {
12430
12430
  type: "autocomplete_product_click",
12431
12431
  label: (_a = this.title) !== null && _a !== void 0 ? _a : this.link,
12432
+ items: [this.item],
12432
12433
  },
12433
12434
  },
12434
12435
  });
@@ -31119,6 +31120,7 @@ let SearchBox = class SearchBox extends Vue$1 {
31119
31120
  analytics: {
31120
31121
  type: "autocomplete_product_click",
31121
31122
  label: doc.title || doc.id,
31123
+ items: [doc],
31122
31124
  },
31123
31125
  },
31124
31126
  });
@@ -31257,7 +31259,7 @@ __vue_render__$V._withStripped = true;
31257
31259
  /* style */
31258
31260
  const __vue_inject_styles__$V = function (inject) {
31259
31261
  if (!inject) return
31260
- inject("data-v-39831122_0", { source: "\n#lupa-search-box {\n width: 100%;\n}\n.lupa-search-box-wrapper {\n position: relative;\n}\n", map: undefined, media: undefined });
31262
+ inject("data-v-1d0dc04c_0", { source: "\n#lupa-search-box {\n width: 100%;\n}\n.lupa-search-box-wrapper {\n position: relative;\n}\n", map: undefined, media: undefined });
31261
31263
 
31262
31264
  };
31263
31265
  /* scoped */
@@ -35684,6 +35686,7 @@ let SearchResultsProductCard = class SearchResultsProductCard extends Vue$1 {
35684
35686
  analytics: {
35685
35687
  type: this.query ? "search_product_click" : "select_item",
35686
35688
  label: this.title || this.id || this.link,
35689
+ items: [this.product],
35687
35690
  },
35688
35691
  options: { allowEmptySearchQuery: true },
35689
35692
  },
@@ -35731,6 +35734,9 @@ __decorate([
35731
35734
  __decorate([
35732
35735
  options$7.State((o) => o.searchResultOptions)
35733
35736
  ], SearchResultsProductCard.prototype, "searchResultOptions", void 0);
35737
+ __decorate([
35738
+ options$7.State((o) => o.trackingOptions)
35739
+ ], SearchResultsProductCard.prototype, "trackingOptions", void 0);
35734
35740
  __decorate([
35735
35741
  params$a.Getter("query")
35736
35742
  ], SearchResultsProductCard.prototype, "query", void 0);
@@ -36067,6 +36073,15 @@ const trackAnalyticsEvent = (data) => {
36067
36073
  console.error("Unable to send an event to google analytics");
36068
36074
  }
36069
36075
  };
36076
+ const parseEcommerceData = (data, title) => {
36077
+ var _a, _b;
36078
+ return ((_a = data.analytics) === null || _a === void 0 ? void 0 : _a.items)
36079
+ ? {
36080
+ item_list_name: title,
36081
+ items: (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.items,
36082
+ }
36083
+ : undefined;
36084
+ };
36070
36085
  const sendUaAnalyticsEvent = (data, options) => {
36071
36086
  var _a, _b, _c, _d;
36072
36087
  const ga = window.ga;
@@ -36077,25 +36092,29 @@ const sendUaAnalyticsEvent = (data, options) => {
36077
36092
  sendGa("send", "event", options.parentEventName, (_b = (_a = data.analytics) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : "", (_d = (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : "");
36078
36093
  };
36079
36094
  const sendGa4AnalyticsEvent = (data, options) => {
36080
- var _a, _b, _c, _d;
36095
+ var _a, _b, _c, _d, _e;
36081
36096
  if (!window || !window.dataLayer) {
36082
36097
  console.error("dataLayer object not found.");
36083
36098
  return;
36084
36099
  }
36085
36100
  const sendItemTitle = data.searchQuery !== ((_a = data.analytics) === null || _a === void 0 ? void 0 : _a.label);
36101
+ const title = sendItemTitle ? (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.label : undefined;
36086
36102
  const params = {
36087
36103
  search_text: data.searchQuery,
36088
- item_title: sendItemTitle ? (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.label : undefined,
36104
+ item_title: sendItemTitle ? (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.label : undefined,
36105
+ ecommerce: parseEcommerceData(data, title),
36089
36106
  };
36090
- window.dataLayer.push(Object.assign({ event: (_d = (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : options.parentEventName }, params));
36107
+ window.dataLayer.push(Object.assign({ event: (_e = (_d = data.analytics) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : options.parentEventName }, params));
36091
36108
  };
36092
36109
  const processDebugEvent = (data) => {
36093
36110
  var _a, _b, _c;
36094
36111
  const sendItemTitle = data.searchQuery !== ((_a = data.analytics) === null || _a === void 0 ? void 0 : _a.label);
36112
+ const title = sendItemTitle ? (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.label : undefined;
36095
36113
  const params = {
36096
- event: (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.type,
36114
+ event: (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.type,
36097
36115
  search_text: data.searchQuery,
36098
- item_title: sendItemTitle ? (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.label : undefined,
36116
+ item_title: title,
36117
+ ecommerce: parseEcommerceData(data, title),
36099
36118
  };
36100
36119
  console.debug("Analytics debug event:", params);
36101
36120
  };
@@ -38466,13 +38485,14 @@ let SearchResults = class SearchResults extends Vue$1 {
38466
38485
  beforeDestroy() {
38467
38486
  window.removeEventListener("resize", this.handleResize);
38468
38487
  }
38469
- trackItemListView(title) {
38488
+ trackItemListView(title, items = []) {
38470
38489
  this.trackEvent({
38471
38490
  queryKey: this.options.queryKey,
38472
38491
  data: {
38473
38492
  analytics: {
38474
38493
  type: "view_item_list",
38475
38494
  label: title,
38495
+ items,
38476
38496
  },
38477
38497
  options: { allowEmptySearchQuery: true },
38478
38498
  },
@@ -38486,7 +38506,6 @@ let SearchResults = class SearchResults extends Vue$1 {
38486
38506
  setDocumentTitle(pageTitle, "");
38487
38507
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38488
38508
  (_a = this.$refs.searchResultsFilters) === null || _a === void 0 ? void 0 : _a.fetch();
38489
- this.trackItemListView(pageTitle);
38490
38509
  }
38491
38510
  const params = new URLSearchParams(window.location.search);
38492
38511
  if (!params.has(QUERY_PARAMS.QUERY)) {
@@ -38555,6 +38574,7 @@ let SearchResults = class SearchResults extends Vue$1 {
38555
38574
  if (!hasResults) {
38556
38575
  return;
38557
38576
  }
38577
+ this.trackItemListView(this.options.labels.htmlTitleTemplate, results.items);
38558
38578
  yield this.enhanceData({ result: results });
38559
38579
  });
38560
38580
  }
@@ -40395,6 +40415,7 @@ let OptionsModule = class OptionsModule extends VuexModule {
40395
40415
  super(...arguments);
40396
40416
  this.searchBoxOptions = DEFAULT_SEARCH_BOX_OPTIONS;
40397
40417
  this.searchResultOptions = DEFAULT_OPTIONS_RESULTS;
40418
+ this.trackingOptions = {};
40398
40419
  this.searchResultInitialFilters = {};
40399
40420
  }
40400
40421
  get envOptions() {
@@ -40443,6 +40464,9 @@ let OptionsModule = class OptionsModule extends VuexModule {
40443
40464
  setSearchBoxOptions({ options }) {
40444
40465
  this.searchBoxOptions = options;
40445
40466
  }
40467
+ setTrackingOptions({ options }) {
40468
+ this.trackingOptions = options !== null && options !== void 0 ? options : {};
40469
+ }
40446
40470
  setSearchResultOptions({ options }) {
40447
40471
  this.searchResultOptions = options;
40448
40472
  }
@@ -40453,6 +40477,9 @@ let OptionsModule = class OptionsModule extends VuexModule {
40453
40477
  __decorate([
40454
40478
  Mutation
40455
40479
  ], OptionsModule.prototype, "setSearchBoxOptions", null);
40480
+ __decorate([
40481
+ Mutation
40482
+ ], OptionsModule.prototype, "setTrackingOptions", null);
40456
40483
  __decorate([
40457
40484
  Mutation
40458
40485
  ], OptionsModule.prototype, "setSearchResultOptions", null);
@@ -40497,9 +40524,15 @@ let TrackingModule = class TrackingModule extends VuexModule {
40497
40524
  }
40498
40525
  }
40499
40526
  track({ queryKey, data, }) {
40500
- var _a;
40527
+ var _a, _b, _c, _d, _e;
40501
40528
  const options = (_a = this.context.rootGetters["options/envOptions"]) !== null && _a !== void 0 ? _a : {};
40502
- track(queryKey, data, options);
40529
+ const trackingOptions = (_b = this.context.rootState["options"].trackingOptions) !== null && _b !== void 0 ? _b : {};
40530
+ const items = (_d = (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
40531
+ const mappedItems = ((_e = trackingOptions.analytics) === null || _e === void 0 ? void 0 : _e.itemMap)
40532
+ ? items.map(trackingOptions.analytics.itemMap)
40533
+ : items;
40534
+ track(queryKey, Object.assign(Object.assign({}, data), { analytics: data.analytics
40535
+ ? Object.assign(Object.assign({}, data.analytics), { items: mappedItems }) : undefined }), options);
40503
40536
  }
40504
40537
  };
40505
40538
  __decorate([
@@ -40674,6 +40707,7 @@ const app = {
40674
40707
  };
40675
40708
  const tracking = (options) => {
40676
40709
  initTracking(options);
40710
+ store.commit("options/setTrackingOptions", { options });
40677
40711
  };
40678
40712
  const applySearchBox = (options, mountOptions) => {
40679
40713
  const existingInstance = app.box[options.inputSelector];
@@ -1,3 +1,4 @@
1
+ import { TrackingOptions } from "@/types/General";
1
2
  import { SearchBoxOptions } from "@/types/search-box/SearchBoxOptions";
2
3
  import { RoutingBehavior } from "@/types/search-results/RoutingBehavior";
3
4
  import { SearchResultsOptions } from "@/types/search-results/SearchResultsOptions";
@@ -6,6 +7,7 @@ import { VuexModule } from "vuex-module-decorators";
6
7
  export default class OptionsModule extends VuexModule {
7
8
  searchBoxOptions: SearchBoxOptions;
8
9
  searchResultOptions: SearchResultsOptions;
10
+ trackingOptions: TrackingOptions;
9
11
  searchResultInitialFilters: FilterGroup;
10
12
  get envOptions(): Options;
11
13
  get classMap(): Record<string, string>;
@@ -17,6 +19,9 @@ export default class OptionsModule extends VuexModule {
17
19
  setSearchBoxOptions({ options }: {
18
20
  options: SearchBoxOptions;
19
21
  }): void;
22
+ setTrackingOptions({ options }: {
23
+ options: TrackingOptions;
24
+ }): void;
20
25
  setSearchResultOptions({ options }: {
21
26
  options: SearchResultsOptions;
22
27
  }): void;
@@ -5,4 +5,5 @@ export declare type AnalyticsOptions = {
5
5
  enabled: boolean;
6
6
  parentEventName: string;
7
7
  ignoreEvents?: AnalyticsEventType[];
8
+ itemMap?: (item: Record<string, unknown>) => Record<string, unknown>;
8
9
  };
@@ -34,6 +34,7 @@ export declare type TrackableEventData = {
34
34
  analytics?: {
35
35
  type: AnalyticsEventType;
36
36
  label: string;
37
+ items?: Record<string, unknown>[];
37
38
  };
38
39
  options?: {
39
40
  allowEmptySearchQuery: boolean;
@@ -58,7 +58,7 @@ export default class SearchResults extends Vue {
58
58
  }) => void;
59
59
  mounted(): void;
60
60
  beforeDestroy(): void;
61
- trackItemListView(title: string): void;
61
+ trackItemListView(title: string, items?: Record<string, unknown>[]): void;
62
62
  handleMounted(): void;
63
63
  handleParamsChange(): void;
64
64
  addSearchResult: (searchResult: SearchQueryResult) => SearchQueryResult;
@@ -1,4 +1,5 @@
1
1
  import { DocumentElement } from "@/types/DocumentElement";
2
+ import { TrackingOptions } from "@/types/General";
2
3
  import { TrackableEventData } from "@/types/search-box/Common";
3
4
  import { BadgeOptions } from "@/types/search-results/BadgeOptions";
4
5
  import { ResultsLayout } from "@/types/search-results/ResultsLayout";
@@ -15,6 +16,7 @@ export default class SearchResultsProductCard extends Vue {
15
16
  layout: ResultsLayout;
16
17
  searchResultsRoutingBehavior: RoutingBehavior;
17
18
  searchResultOptions: SearchResultsOptions;
19
+ trackingOptions: TrackingOptions;
18
20
  query: string;
19
21
  trackClick: ({ queryKey, data, }: {
20
22
  queryKey: string;
@@ -12425,6 +12425,7 @@ let SearchBoxProduct = class SearchBoxProduct extends Vue$1 {
12425
12425
  analytics: {
12426
12426
  type: "autocomplete_product_click",
12427
12427
  label: (_a = this.title) !== null && _a !== void 0 ? _a : this.link,
12428
+ items: [this.item],
12428
12429
  },
12429
12430
  },
12430
12431
  });
@@ -31115,6 +31116,7 @@ let SearchBox = class SearchBox extends Vue$1 {
31115
31116
  analytics: {
31116
31117
  type: "autocomplete_product_click",
31117
31118
  label: doc.title || doc.id,
31119
+ items: [doc],
31118
31120
  },
31119
31121
  },
31120
31122
  });
@@ -31253,7 +31255,7 @@ __vue_render__$V._withStripped = true;
31253
31255
  /* style */
31254
31256
  const __vue_inject_styles__$V = function (inject) {
31255
31257
  if (!inject) return
31256
- inject("data-v-39831122_0", { source: "\n#lupa-search-box {\n width: 100%;\n}\n.lupa-search-box-wrapper {\n position: relative;\n}\n", map: undefined, media: undefined });
31258
+ inject("data-v-1d0dc04c_0", { source: "\n#lupa-search-box {\n width: 100%;\n}\n.lupa-search-box-wrapper {\n position: relative;\n}\n", map: undefined, media: undefined });
31257
31259
 
31258
31260
  };
31259
31261
  /* scoped */
@@ -35680,6 +35682,7 @@ let SearchResultsProductCard = class SearchResultsProductCard extends Vue$1 {
35680
35682
  analytics: {
35681
35683
  type: this.query ? "search_product_click" : "select_item",
35682
35684
  label: this.title || this.id || this.link,
35685
+ items: [this.product],
35683
35686
  },
35684
35687
  options: { allowEmptySearchQuery: true },
35685
35688
  },
@@ -35727,6 +35730,9 @@ __decorate([
35727
35730
  __decorate([
35728
35731
  options$7.State((o) => o.searchResultOptions)
35729
35732
  ], SearchResultsProductCard.prototype, "searchResultOptions", void 0);
35733
+ __decorate([
35734
+ options$7.State((o) => o.trackingOptions)
35735
+ ], SearchResultsProductCard.prototype, "trackingOptions", void 0);
35730
35736
  __decorate([
35731
35737
  params$a.Getter("query")
35732
35738
  ], SearchResultsProductCard.prototype, "query", void 0);
@@ -36063,6 +36069,15 @@ const trackAnalyticsEvent = (data) => {
36063
36069
  console.error("Unable to send an event to google analytics");
36064
36070
  }
36065
36071
  };
36072
+ const parseEcommerceData = (data, title) => {
36073
+ var _a, _b;
36074
+ return ((_a = data.analytics) === null || _a === void 0 ? void 0 : _a.items)
36075
+ ? {
36076
+ item_list_name: title,
36077
+ items: (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.items,
36078
+ }
36079
+ : undefined;
36080
+ };
36066
36081
  const sendUaAnalyticsEvent = (data, options) => {
36067
36082
  var _a, _b, _c, _d;
36068
36083
  const ga = window.ga;
@@ -36073,25 +36088,29 @@ const sendUaAnalyticsEvent = (data, options) => {
36073
36088
  sendGa("send", "event", options.parentEventName, (_b = (_a = data.analytics) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : "", (_d = (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : "");
36074
36089
  };
36075
36090
  const sendGa4AnalyticsEvent = (data, options) => {
36076
- var _a, _b, _c, _d;
36091
+ var _a, _b, _c, _d, _e;
36077
36092
  if (!window || !window.dataLayer) {
36078
36093
  console.error("dataLayer object not found.");
36079
36094
  return;
36080
36095
  }
36081
36096
  const sendItemTitle = data.searchQuery !== ((_a = data.analytics) === null || _a === void 0 ? void 0 : _a.label);
36097
+ const title = sendItemTitle ? (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.label : undefined;
36082
36098
  const params = {
36083
36099
  search_text: data.searchQuery,
36084
- item_title: sendItemTitle ? (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.label : undefined,
36100
+ item_title: sendItemTitle ? (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.label : undefined,
36101
+ ecommerce: parseEcommerceData(data, title),
36085
36102
  };
36086
- window.dataLayer.push(Object.assign({ event: (_d = (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : options.parentEventName }, params));
36103
+ window.dataLayer.push(Object.assign({ event: (_e = (_d = data.analytics) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : options.parentEventName }, params));
36087
36104
  };
36088
36105
  const processDebugEvent = (data) => {
36089
36106
  var _a, _b, _c;
36090
36107
  const sendItemTitle = data.searchQuery !== ((_a = data.analytics) === null || _a === void 0 ? void 0 : _a.label);
36108
+ const title = sendItemTitle ? (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.label : undefined;
36091
36109
  const params = {
36092
- event: (_b = data.analytics) === null || _b === void 0 ? void 0 : _b.type,
36110
+ event: (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.type,
36093
36111
  search_text: data.searchQuery,
36094
- item_title: sendItemTitle ? (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.label : undefined,
36112
+ item_title: title,
36113
+ ecommerce: parseEcommerceData(data, title),
36095
36114
  };
36096
36115
  console.debug("Analytics debug event:", params);
36097
36116
  };
@@ -38462,13 +38481,14 @@ let SearchResults = class SearchResults extends Vue$1 {
38462
38481
  beforeDestroy() {
38463
38482
  window.removeEventListener("resize", this.handleResize);
38464
38483
  }
38465
- trackItemListView(title) {
38484
+ trackItemListView(title, items = []) {
38466
38485
  this.trackEvent({
38467
38486
  queryKey: this.options.queryKey,
38468
38487
  data: {
38469
38488
  analytics: {
38470
38489
  type: "view_item_list",
38471
38490
  label: title,
38491
+ items,
38472
38492
  },
38473
38493
  options: { allowEmptySearchQuery: true },
38474
38494
  },
@@ -38482,7 +38502,6 @@ let SearchResults = class SearchResults extends Vue$1 {
38482
38502
  setDocumentTitle(pageTitle, "");
38483
38503
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38484
38504
  (_a = this.$refs.searchResultsFilters) === null || _a === void 0 ? void 0 : _a.fetch();
38485
- this.trackItemListView(pageTitle);
38486
38505
  }
38487
38506
  const params = new URLSearchParams(window.location.search);
38488
38507
  if (!params.has(QUERY_PARAMS.QUERY)) {
@@ -38551,6 +38570,7 @@ let SearchResults = class SearchResults extends Vue$1 {
38551
38570
  if (!hasResults) {
38552
38571
  return;
38553
38572
  }
38573
+ this.trackItemListView(this.options.labels.htmlTitleTemplate, results.items);
38554
38574
  yield this.enhanceData({ result: results });
38555
38575
  });
38556
38576
  }
@@ -40391,6 +40411,7 @@ let OptionsModule = class OptionsModule extends VuexModule {
40391
40411
  super(...arguments);
40392
40412
  this.searchBoxOptions = DEFAULT_SEARCH_BOX_OPTIONS;
40393
40413
  this.searchResultOptions = DEFAULT_OPTIONS_RESULTS;
40414
+ this.trackingOptions = {};
40394
40415
  this.searchResultInitialFilters = {};
40395
40416
  }
40396
40417
  get envOptions() {
@@ -40439,6 +40460,9 @@ let OptionsModule = class OptionsModule extends VuexModule {
40439
40460
  setSearchBoxOptions({ options }) {
40440
40461
  this.searchBoxOptions = options;
40441
40462
  }
40463
+ setTrackingOptions({ options }) {
40464
+ this.trackingOptions = options !== null && options !== void 0 ? options : {};
40465
+ }
40442
40466
  setSearchResultOptions({ options }) {
40443
40467
  this.searchResultOptions = options;
40444
40468
  }
@@ -40449,6 +40473,9 @@ let OptionsModule = class OptionsModule extends VuexModule {
40449
40473
  __decorate([
40450
40474
  Mutation
40451
40475
  ], OptionsModule.prototype, "setSearchBoxOptions", null);
40476
+ __decorate([
40477
+ Mutation
40478
+ ], OptionsModule.prototype, "setTrackingOptions", null);
40452
40479
  __decorate([
40453
40480
  Mutation
40454
40481
  ], OptionsModule.prototype, "setSearchResultOptions", null);
@@ -40493,9 +40520,15 @@ let TrackingModule = class TrackingModule extends VuexModule {
40493
40520
  }
40494
40521
  }
40495
40522
  track({ queryKey, data, }) {
40496
- var _a;
40523
+ var _a, _b, _c, _d, _e;
40497
40524
  const options = (_a = this.context.rootGetters["options/envOptions"]) !== null && _a !== void 0 ? _a : {};
40498
- track(queryKey, data, options);
40525
+ const trackingOptions = (_b = this.context.rootState["options"].trackingOptions) !== null && _b !== void 0 ? _b : {};
40526
+ const items = (_d = (_c = data.analytics) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
40527
+ const mappedItems = ((_e = trackingOptions.analytics) === null || _e === void 0 ? void 0 : _e.itemMap)
40528
+ ? items.map(trackingOptions.analytics.itemMap)
40529
+ : items;
40530
+ track(queryKey, Object.assign(Object.assign({}, data), { analytics: data.analytics
40531
+ ? Object.assign(Object.assign({}, data.analytics), { items: mappedItems }) : undefined }), options);
40499
40532
  }
40500
40533
  };
40501
40534
  __decorate([
@@ -40670,6 +40703,7 @@ const app = {
40670
40703
  };
40671
40704
  const tracking = (options) => {
40672
40705
  initTracking(options);
40706
+ store.commit("options/setTrackingOptions", { options });
40673
40707
  };
40674
40708
  const applySearchBox = (options, mountOptions) => {
40675
40709
  const existingInstance = app.box[options.inputSelector];
@@ -1,3 +1,4 @@
1
+ import { TrackingOptions } from "@/types/General";
1
2
  import { SearchBoxOptions } from "@/types/search-box/SearchBoxOptions";
2
3
  import { RoutingBehavior } from "@/types/search-results/RoutingBehavior";
3
4
  import { SearchResultsOptions } from "@/types/search-results/SearchResultsOptions";
@@ -6,6 +7,7 @@ import { VuexModule } from "vuex-module-decorators";
6
7
  export default class OptionsModule extends VuexModule {
7
8
  searchBoxOptions: SearchBoxOptions;
8
9
  searchResultOptions: SearchResultsOptions;
10
+ trackingOptions: TrackingOptions;
9
11
  searchResultInitialFilters: FilterGroup;
10
12
  get envOptions(): Options;
11
13
  get classMap(): Record<string, string>;
@@ -17,6 +19,9 @@ export default class OptionsModule extends VuexModule {
17
19
  setSearchBoxOptions({ options }: {
18
20
  options: SearchBoxOptions;
19
21
  }): void;
22
+ setTrackingOptions({ options }: {
23
+ options: TrackingOptions;
24
+ }): void;
20
25
  setSearchResultOptions({ options }: {
21
26
  options: SearchResultsOptions;
22
27
  }): void;
@@ -5,4 +5,5 @@ export declare type AnalyticsOptions = {
5
5
  enabled: boolean;
6
6
  parentEventName: string;
7
7
  ignoreEvents?: AnalyticsEventType[];
8
+ itemMap?: (item: Record<string, unknown>) => Record<string, unknown>;
8
9
  };
@@ -34,6 +34,7 @@ export declare type TrackableEventData = {
34
34
  analytics?: {
35
35
  type: AnalyticsEventType;
36
36
  label: string;
37
+ items?: Record<string, unknown>[];
37
38
  };
38
39
  options?: {
39
40
  allowEmptySearchQuery: boolean;
@@ -58,7 +58,7 @@ export default class SearchResults extends Vue {
58
58
  }) => void;
59
59
  mounted(): void;
60
60
  beforeDestroy(): void;
61
- trackItemListView(title: string): void;
61
+ trackItemListView(title: string, items?: Record<string, unknown>[]): void;
62
62
  handleMounted(): void;
63
63
  handleParamsChange(): void;
64
64
  addSearchResult: (searchResult: SearchQueryResult) => SearchQueryResult;
@@ -1,4 +1,5 @@
1
1
  import { DocumentElement } from "@/types/DocumentElement";
2
+ import { TrackingOptions } from "@/types/General";
2
3
  import { TrackableEventData } from "@/types/search-box/Common";
3
4
  import { BadgeOptions } from "@/types/search-results/BadgeOptions";
4
5
  import { ResultsLayout } from "@/types/search-results/ResultsLayout";
@@ -15,6 +16,7 @@ export default class SearchResultsProductCard extends Vue {
15
16
  layout: ResultsLayout;
16
17
  searchResultsRoutingBehavior: RoutingBehavior;
17
18
  searchResultOptions: SearchResultsOptions;
19
+ trackingOptions: TrackingOptions;
18
20
  query: string;
19
21
  trackClick: ({ queryKey, data, }: {
20
22
  queryKey: string;