@artisan-commerce/analytics-web 0.2.0-canary.154 → 0.2.0-canary.156
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/bundle.cjs +17 -3
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.mjs +17 -3
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.umd.js +17 -3
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +6 -6
package/dist/bundle.d.ts
CHANGED
|
@@ -52,8 +52,6 @@ interface GoogleAnalyticsCustomEventParams {
|
|
|
52
52
|
[key: string]: any;
|
|
53
53
|
}
|
|
54
54
|
interface CommonGoogleAnalyticsEventParams {
|
|
55
|
-
/** The item that the user is selecting */
|
|
56
|
-
item: Gtag.Item;
|
|
57
55
|
/** Param used to add `item_list_name` outside the items array */
|
|
58
56
|
list?: string;
|
|
59
57
|
}
|
package/dist/bundle.mjs
CHANGED
|
@@ -48,7 +48,7 @@ const _State = class {
|
|
|
48
48
|
let State$1 = _State;
|
|
49
49
|
State$1._instance = null;
|
|
50
50
|
|
|
51
|
-
var version = "0.2.0-canary.
|
|
51
|
+
var version = "0.2.0-canary.156";
|
|
52
52
|
var packageJSON = {
|
|
53
53
|
version: version};
|
|
54
54
|
|
|
@@ -909,6 +909,20 @@ const getModifiersNames = (product) => {
|
|
|
909
909
|
const variants = modifiers == null ? void 0 : modifiers.flatMap((question) => question.answers.filter((answer) => answer.amount > 0).map((answer) => answer.name));
|
|
910
910
|
return variants;
|
|
911
911
|
};
|
|
912
|
+
const getProductListName = (categoryName) => {
|
|
913
|
+
if (categoryName == null ? void 0 : categoryName.includes("COUPON"))
|
|
914
|
+
return "coupon_menu";
|
|
915
|
+
if (categoryName == null ? void 0 : categoryName.includes("HOME"))
|
|
916
|
+
return "home_product";
|
|
917
|
+
return "product_menu";
|
|
918
|
+
};
|
|
919
|
+
const getProductAddedFrom = (addedFrom) => {
|
|
920
|
+
if (addedFrom === "up_sell_modal")
|
|
921
|
+
return "upsell_recommendation";
|
|
922
|
+
if (addedFrom == null ? void 0 : addedFrom.includes("add_prod"))
|
|
923
|
+
return "menu";
|
|
924
|
+
return addedFrom != null ? addedFrom : "";
|
|
925
|
+
};
|
|
912
926
|
const toItemProduct = (product, cart, item_category2) => {
|
|
913
927
|
var _a, _b, _c;
|
|
914
928
|
const { categories, addedFrom, additionalInfo } = product;
|
|
@@ -917,7 +931,7 @@ const toItemProduct = (product, cart, item_category2) => {
|
|
|
917
931
|
const { netPrice } = getProductTotals(product);
|
|
918
932
|
const productModifiers = getModifiersNames(product);
|
|
919
933
|
const benefits = (_a = cart == null ? void 0 : cart.benefits) != null ? _a : [];
|
|
920
|
-
const source = addedFrom
|
|
934
|
+
const source = getProductAddedFrom(addedFrom);
|
|
921
935
|
const benefit = benefits == null ? void 0 : benefits.find((benefit2) => {
|
|
922
936
|
var _a2, _b2, _c2, _d;
|
|
923
937
|
return ((_b2 = (_a2 = benefit2 == null ? void 0 : benefit2.reward) == null ? void 0 : _a2.attributes) == null ? void 0 : _b2.new_product_id) || ((_d = (_c2 = benefit2 == null ? void 0 : benefit2.reward) == null ? void 0 : _c2.attributes) == null ? void 0 : _d.item_id) === (additionalInfo == null ? void 0 : additionalInfo.externalId);
|
|
@@ -933,7 +947,7 @@ const toItemProduct = (product, cart, item_category2) => {
|
|
|
933
947
|
quantity: product.amount,
|
|
934
948
|
item_revenue_in_usd: netPrice,
|
|
935
949
|
item_revenue: netPrice,
|
|
936
|
-
item_list_name: (categoryName
|
|
950
|
+
item_list_name: getProductListName(categoryName)
|
|
937
951
|
};
|
|
938
952
|
if (categoryId)
|
|
939
953
|
item.item_list_id = categoryId;
|