@getlupa/client 0.14.3 → 0.14.4

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.
@@ -3,6 +3,7 @@ import { ProductGrid, SearchResultsDidYouMeanLabels, SearchResultsOptions, Searc
3
3
  import { FilterGroup, PublicQuery, SearchQueryResult } from "@getlupa/client-sdk/Types";
4
4
  import Vue from "vue";
5
5
  import { AnalyticsEventType } from "@/types/AnalyticsOptions";
6
+ import { TrackableEventData } from "@/types/search-box/Common";
6
7
  export default class SearchResults extends Vue {
7
8
  options: SearchResultsOptions;
8
9
  initialFilters: FilterGroup;
@@ -24,6 +25,10 @@ export default class SearchResults extends Vue {
24
25
  queryKey: string;
25
26
  results: SearchQueryResult;
26
27
  }) => void;
28
+ trackEvent: ({ queryKey, data, }: {
29
+ queryKey: string;
30
+ data: TrackableEventData;
31
+ }) => void;
27
32
  enhanceData: ({ result, }: {
28
33
  result: SearchQueryResult;
29
34
  }) => Promise<void>;
@@ -53,6 +58,7 @@ export default class SearchResults extends Vue {
53
58
  }) => void;
54
59
  mounted(): void;
55
60
  beforeDestroy(): void;
61
+ trackItemListView(title: string): void;
56
62
  handleMounted(): void;
57
63
  handleParamsChange(): void;
58
64
  addSearchResult: (searchResult: SearchQueryResult) => SearchQueryResult;
@@ -35682,9 +35682,10 @@ let SearchResultsProductCard = class SearchResultsProductCard extends Vue$1 {
35682
35682
  searchQuery: this.query,
35683
35683
  type: "itemClick",
35684
35684
  analytics: {
35685
- type: "search_product_click",
35685
+ type: this.query ? "search_product_click" : "select_item",
35686
35686
  label: this.title || this.id || this.link,
35687
35687
  },
35688
+ options: { allowEmptySearchQuery: true },
35688
35689
  },
35689
35690
  });
35690
35691
  (_b = (_a = this.searchResultOptions.callbacks) === null || _a === void 0 ? void 0 : _a.onProductClick) === null || _b === void 0 ? void 0 : _b.call(_a, {
@@ -36099,11 +36100,20 @@ const processDebugEvent = (data) => {
36099
36100
  console.debug("Analytics debug event:", params);
36100
36101
  };
36101
36102
  const track = (queryKey, data = {}, options) => {
36102
- if (!isTrackingEnabled() || !data.searchQuery) {
36103
+ var _a;
36104
+ if (!isTrackingEnabled()) {
36105
+ return;
36106
+ }
36107
+ const hasSearchQuery = data.searchQuery;
36108
+ if (!hasSearchQuery && !((_a = data.options) === null || _a === void 0 ? void 0 : _a.allowEmptySearchQuery)) {
36103
36109
  return;
36104
36110
  }
36105
- trackLupaEvent(queryKey, data, options);
36106
36111
  trackAnalyticsEvent(data);
36112
+ // Lupa events are only tracked if search query is set
36113
+ if (!hasSearchQuery) {
36114
+ return;
36115
+ }
36116
+ trackLupaEvent(queryKey, data, options);
36107
36117
  };
36108
36118
 
36109
36119
  const params$9 = namespace("params");
@@ -38456,13 +38466,27 @@ let SearchResults = class SearchResults extends Vue$1 {
38456
38466
  beforeDestroy() {
38457
38467
  window.removeEventListener("resize", this.handleResize);
38458
38468
  }
38469
+ trackItemListView(title) {
38470
+ this.trackEvent({
38471
+ queryKey: this.options.queryKey,
38472
+ data: {
38473
+ analytics: {
38474
+ type: "view_item_list",
38475
+ label: title,
38476
+ },
38477
+ options: { allowEmptySearchQuery: true },
38478
+ },
38479
+ });
38480
+ }
38459
38481
  handleMounted() {
38460
38482
  var _a;
38461
38483
  this.handleResize();
38462
38484
  if (this.isProductList) {
38463
- setDocumentTitle(this.options.labels.htmlTitleTemplate, "");
38485
+ const pageTitle = this.options.labels.htmlTitleTemplate;
38486
+ setDocumentTitle(pageTitle, "");
38464
38487
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38465
38488
  (_a = this.$refs.searchResultsFilters) === null || _a === void 0 ? void 0 : _a.fetch();
38489
+ this.trackItemListView(pageTitle);
38466
38490
  }
38467
38491
  const params = new URLSearchParams(window.location.search);
38468
38492
  if (!params.has(QUERY_PARAMS.QUERY)) {
@@ -38568,6 +38592,9 @@ __decorate([
38568
38592
  __decorate([
38569
38593
  tracking$2.Action("trackResults")
38570
38594
  ], SearchResults.prototype, "trackResults", void 0);
38595
+ __decorate([
38596
+ tracking$2.Action("track")
38597
+ ], SearchResults.prototype, "trackEvent", void 0);
38571
38598
  __decorate([
38572
38599
  dynamicData$1.Action("enhanceSearchResultsWithDynamicData")
38573
38600
  ], SearchResults.prototype, "enhanceData", void 0);
@@ -1,5 +1,5 @@
1
1
  export declare const PARENT_EVENT_NAME = "GetLupa";
2
- export declare type AnalyticsEventType = "search_query" | "search_form_submit" | "autocomplete_suggestion_click" | "autocomplete_product_click" | "search_product_click" | "search_zero_results" | "search_filters" | "search_add_to_cart";
2
+ export declare type AnalyticsEventType = "search_query" | "search_form_submit" | "autocomplete_suggestion_click" | "autocomplete_product_click" | "search_product_click" | "search_zero_results" | "search_filters" | "search_add_to_cart" | "view_item_list" | "select_item";
3
3
  export declare type AnalyticsOptions = {
4
4
  type: "ua" | "ga4" | "debug";
5
5
  enabled: boolean;
@@ -35,6 +35,9 @@ export declare type TrackableEventData = {
35
35
  type: AnalyticsEventType;
36
36
  label: string;
37
37
  };
38
+ options?: {
39
+ allowEmptySearchQuery: boolean;
40
+ };
38
41
  };
39
42
  export declare type HighlightedDocInfo = {
40
43
  doc?: Document;
@@ -3,6 +3,7 @@ import { ProductGrid, SearchResultsDidYouMeanLabels, SearchResultsOptions, Searc
3
3
  import { FilterGroup, PublicQuery, SearchQueryResult } from "@getlupa/client-sdk/Types";
4
4
  import Vue from "vue";
5
5
  import { AnalyticsEventType } from "@/types/AnalyticsOptions";
6
+ import { TrackableEventData } from "@/types/search-box/Common";
6
7
  export default class SearchResults extends Vue {
7
8
  options: SearchResultsOptions;
8
9
  initialFilters: FilterGroup;
@@ -24,6 +25,10 @@ export default class SearchResults extends Vue {
24
25
  queryKey: string;
25
26
  results: SearchQueryResult;
26
27
  }) => void;
28
+ trackEvent: ({ queryKey, data, }: {
29
+ queryKey: string;
30
+ data: TrackableEventData;
31
+ }) => void;
27
32
  enhanceData: ({ result, }: {
28
33
  result: SearchQueryResult;
29
34
  }) => Promise<void>;
@@ -53,6 +58,7 @@ export default class SearchResults extends Vue {
53
58
  }) => void;
54
59
  mounted(): void;
55
60
  beforeDestroy(): void;
61
+ trackItemListView(title: string): void;
56
62
  handleMounted(): void;
57
63
  handleParamsChange(): void;
58
64
  addSearchResult: (searchResult: SearchQueryResult) => SearchQueryResult;
@@ -35678,9 +35678,10 @@ let SearchResultsProductCard = class SearchResultsProductCard extends Vue$1 {
35678
35678
  searchQuery: this.query,
35679
35679
  type: "itemClick",
35680
35680
  analytics: {
35681
- type: "search_product_click",
35681
+ type: this.query ? "search_product_click" : "select_item",
35682
35682
  label: this.title || this.id || this.link,
35683
35683
  },
35684
+ options: { allowEmptySearchQuery: true },
35684
35685
  },
35685
35686
  });
35686
35687
  (_b = (_a = this.searchResultOptions.callbacks) === null || _a === void 0 ? void 0 : _a.onProductClick) === null || _b === void 0 ? void 0 : _b.call(_a, {
@@ -36095,11 +36096,20 @@ const processDebugEvent = (data) => {
36095
36096
  console.debug("Analytics debug event:", params);
36096
36097
  };
36097
36098
  const track = (queryKey, data = {}, options) => {
36098
- if (!isTrackingEnabled() || !data.searchQuery) {
36099
+ var _a;
36100
+ if (!isTrackingEnabled()) {
36101
+ return;
36102
+ }
36103
+ const hasSearchQuery = data.searchQuery;
36104
+ if (!hasSearchQuery && !((_a = data.options) === null || _a === void 0 ? void 0 : _a.allowEmptySearchQuery)) {
36099
36105
  return;
36100
36106
  }
36101
- trackLupaEvent(queryKey, data, options);
36102
36107
  trackAnalyticsEvent(data);
36108
+ // Lupa events are only tracked if search query is set
36109
+ if (!hasSearchQuery) {
36110
+ return;
36111
+ }
36112
+ trackLupaEvent(queryKey, data, options);
36103
36113
  };
36104
36114
 
36105
36115
  const params$9 = namespace("params");
@@ -38452,13 +38462,27 @@ let SearchResults = class SearchResults extends Vue$1 {
38452
38462
  beforeDestroy() {
38453
38463
  window.removeEventListener("resize", this.handleResize);
38454
38464
  }
38465
+ trackItemListView(title) {
38466
+ this.trackEvent({
38467
+ queryKey: this.options.queryKey,
38468
+ data: {
38469
+ analytics: {
38470
+ type: "view_item_list",
38471
+ label: title,
38472
+ },
38473
+ options: { allowEmptySearchQuery: true },
38474
+ },
38475
+ });
38476
+ }
38455
38477
  handleMounted() {
38456
38478
  var _a;
38457
38479
  this.handleResize();
38458
38480
  if (this.isProductList) {
38459
- setDocumentTitle(this.options.labels.htmlTitleTemplate, "");
38481
+ const pageTitle = this.options.labels.htmlTitleTemplate;
38482
+ setDocumentTitle(pageTitle, "");
38460
38483
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38461
38484
  (_a = this.$refs.searchResultsFilters) === null || _a === void 0 ? void 0 : _a.fetch();
38485
+ this.trackItemListView(pageTitle);
38462
38486
  }
38463
38487
  const params = new URLSearchParams(window.location.search);
38464
38488
  if (!params.has(QUERY_PARAMS.QUERY)) {
@@ -38564,6 +38588,9 @@ __decorate([
38564
38588
  __decorate([
38565
38589
  tracking$2.Action("trackResults")
38566
38590
  ], SearchResults.prototype, "trackResults", void 0);
38591
+ __decorate([
38592
+ tracking$2.Action("track")
38593
+ ], SearchResults.prototype, "trackEvent", void 0);
38567
38594
  __decorate([
38568
38595
  dynamicData$1.Action("enhanceSearchResultsWithDynamicData")
38569
38596
  ], SearchResults.prototype, "enhanceData", void 0);
@@ -1,5 +1,5 @@
1
1
  export declare const PARENT_EVENT_NAME = "GetLupa";
2
- export declare type AnalyticsEventType = "search_query" | "search_form_submit" | "autocomplete_suggestion_click" | "autocomplete_product_click" | "search_product_click" | "search_zero_results" | "search_filters" | "search_add_to_cart";
2
+ export declare type AnalyticsEventType = "search_query" | "search_form_submit" | "autocomplete_suggestion_click" | "autocomplete_product_click" | "search_product_click" | "search_zero_results" | "search_filters" | "search_add_to_cart" | "view_item_list" | "select_item";
3
3
  export declare type AnalyticsOptions = {
4
4
  type: "ua" | "ga4" | "debug";
5
5
  enabled: boolean;
@@ -35,6 +35,9 @@ export declare type TrackableEventData = {
35
35
  type: AnalyticsEventType;
36
36
  label: string;
37
37
  };
38
+ options?: {
39
+ allowEmptySearchQuery: boolean;
40
+ };
38
41
  };
39
42
  export declare type HighlightedDocInfo = {
40
43
  doc?: Document;
@@ -3,6 +3,7 @@ import { ProductGrid, SearchResultsDidYouMeanLabels, SearchResultsOptions, Searc
3
3
  import { FilterGroup, PublicQuery, SearchQueryResult } from "@getlupa/client-sdk/Types";
4
4
  import Vue from "vue";
5
5
  import { AnalyticsEventType } from "@/types/AnalyticsOptions";
6
+ import { TrackableEventData } from "@/types/search-box/Common";
6
7
  export default class SearchResults extends Vue {
7
8
  options: SearchResultsOptions;
8
9
  initialFilters: FilterGroup;
@@ -24,6 +25,10 @@ export default class SearchResults extends Vue {
24
25
  queryKey: string;
25
26
  results: SearchQueryResult;
26
27
  }) => void;
28
+ trackEvent: ({ queryKey, data, }: {
29
+ queryKey: string;
30
+ data: TrackableEventData;
31
+ }) => void;
27
32
  enhanceData: ({ result, }: {
28
33
  result: SearchQueryResult;
29
34
  }) => Promise<void>;
@@ -53,6 +58,7 @@ export default class SearchResults extends Vue {
53
58
  }) => void;
54
59
  mounted(): void;
55
60
  beforeDestroy(): void;
61
+ trackItemListView(title: string): void;
56
62
  handleMounted(): void;
57
63
  handleParamsChange(): void;
58
64
  addSearchResult: (searchResult: SearchQueryResult) => SearchQueryResult;