Skip to content

Commit

Permalink
fix: sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-kalachikov committed Dec 12, 2024
1 parent fe632c0 commit 924ae94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions client-app/modules/google-analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import type { TackerType } from "@/core/types/analytics";
const { currencyCode } = globals;

export const analytics: TackerType = {
viewItemList(items = [], params) {
viewItemList(items, params) {
sendEvent("view_item_list", {
...params,
items_skus: items
items_skus: (items ?? [])
.map((el) => el.code)
.join(", ")
.trim(),
items_count: items.length,
items_count: items?.length ?? 0,
});
},

Expand Down Expand Up @@ -45,13 +45,13 @@ export const analytics: TackerType = {
});
},

addItemToCart(item, quantity = 1, params) {
addItemToCart(item, quantity, params) {
const inputItem = productToGtagItem(item);
inputItem.quantity = quantity;
sendEvent("add_to_cart", {
...params,
currency: currencyCode,
value: (item.price?.actual?.amount || 0) * quantity,
value: (item.price?.actual?.amount || 0) * (quantity ?? 1),
items: [inputItem],
});
},
Expand Down
2 changes: 1 addition & 1 deletion client-app/modules/google-analytics/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function lineItemToGtagItem(
index,
item_id: item.sku,
item_name: item.name,
affiliation: item.vendor?.name || "?",
affiliation: item.vendor?.name ?? "?",
currency: item.placedPrice.currency.code,
discount: item.discountAmount?.amount || item.discountTotal?.amount,
price: "price" in item ? item.price.amount : item.listPrice.amount,
Expand Down

0 comments on commit 924ae94

Please sign in to comment.