@artisan-commerce/analytics-web 0.2.0-canary.63 → 0.2.0-canary.65
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/CHANGELOG.md +17 -0
- package/dist/bundle.cjs.js +35 -11
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +35 -11
- package/dist/bundle.esm.js.map +1 -1
- package/dist/bundle.umd.js +35 -11
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/bundle.esm.js
CHANGED
|
@@ -35,7 +35,7 @@ const getState$2 = () => {
|
|
|
35
35
|
|
|
36
36
|
var name = "@artisan-commerce/analytics-web";
|
|
37
37
|
var description = "Artisn commerce analytics web library";
|
|
38
|
-
var version = "0.2.0-canary.
|
|
38
|
+
var version = "0.2.0-canary.64";
|
|
39
39
|
var main = "./dist/bundle.cjs.js";
|
|
40
40
|
var module = "./dist/bundle.esm.js";
|
|
41
41
|
var types = "./dist/bundle.d.ts";
|
|
@@ -76,9 +76,9 @@ var dependencies = {
|
|
|
76
76
|
"snake-case": "^3.0.4"
|
|
77
77
|
};
|
|
78
78
|
var devDependencies = {
|
|
79
|
-
"@artisan-commerce/products": "0.9.0-canary.
|
|
80
|
-
"@artisan-commerce/shopping-cart": "0.12.0-canary.
|
|
81
|
-
"@artisan-commerce/types": "0.14.0-canary.
|
|
79
|
+
"@artisan-commerce/products": "0.9.0-canary.41",
|
|
80
|
+
"@artisan-commerce/shopping-cart": "0.12.0-canary.61",
|
|
81
|
+
"@artisan-commerce/types": "0.14.0-canary.32"
|
|
82
82
|
};
|
|
83
83
|
var peerDependencies = {
|
|
84
84
|
"@artisan-commerce/products": "*",
|
|
@@ -582,7 +582,7 @@ const initAnalytics = (config) => {
|
|
|
582
582
|
setInitialState();
|
|
583
583
|
const { initialized } = getState$1();
|
|
584
584
|
if (initialized) {
|
|
585
|
-
logMessage("initAnalytics has been called more than once. This behaviour will very likely result in unexpected outcomes so its call was skipped. Please make sure initAnalytics is only called once.", "
|
|
585
|
+
logMessage("initAnalytics has been called more than once. This behaviour will very likely result in unexpected outcomes so its call was skipped. Please make sure initAnalytics is only called once.", "debug");
|
|
586
586
|
return;
|
|
587
587
|
}
|
|
588
588
|
const { providers, shareArtisnAnalytics } = config;
|
|
@@ -923,18 +923,19 @@ var __spreadValues$k$1 = (a, b) => {
|
|
|
923
923
|
}
|
|
924
924
|
return a;
|
|
925
925
|
};
|
|
926
|
-
const { DEFAULT_SHOPPING_CART_NAME: DEFAULT_SHOPPING_CART_NAME$
|
|
926
|
+
const { DEFAULT_SHOPPING_CART_NAME: DEFAULT_SHOPPING_CART_NAME$2, DEFAULT_MAX_SHOPPING_CARTS } = CONSTANTS;
|
|
927
927
|
const initialState = {
|
|
928
928
|
artisnApp: void 0,
|
|
929
929
|
accountId: void 0,
|
|
930
930
|
customerId: void 0,
|
|
931
|
-
activeShoppingCart: DEFAULT_SHOPPING_CART_NAME$
|
|
931
|
+
activeShoppingCart: DEFAULT_SHOPPING_CART_NAME$2,
|
|
932
932
|
maxShoppingCarts: DEFAULT_MAX_SHOPPING_CARTS,
|
|
933
933
|
wallets: {},
|
|
934
934
|
anonymous: false,
|
|
935
935
|
initialized: false,
|
|
936
936
|
queue: new ActionQueue(),
|
|
937
|
-
eventLoop: new EventLoop()
|
|
937
|
+
eventLoop: new EventLoop(),
|
|
938
|
+
debug: false
|
|
938
939
|
};
|
|
939
940
|
Object.freeze(initialState);
|
|
940
941
|
let state = __spreadValues$k$1({}, initialState);
|
|
@@ -1645,13 +1646,16 @@ const applyBenefits = (additionalInfo, benefits, shoppingCartTotals) => {
|
|
|
1645
1646
|
}
|
|
1646
1647
|
const benefitsValues = Object.values(benefits);
|
|
1647
1648
|
return benefitsValues.reduce((acc, benefit) => {
|
|
1648
|
-
if (benefit.type === "
|
|
1649
|
-
return
|
|
1649
|
+
if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
|
|
1650
|
+
return applyBenefitByDiscountPercentage(benefit, acc, additionalInfo);
|
|
1651
|
+
}
|
|
1652
|
+
if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
|
|
1653
|
+
return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
|
|
1650
1654
|
}
|
|
1651
1655
|
return acc;
|
|
1652
1656
|
}, shoppingCartTotals);
|
|
1653
1657
|
};
|
|
1654
|
-
const
|
|
1658
|
+
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1655
1659
|
const { subtotal, total: prevTotal } = shoppingCartTotals;
|
|
1656
1660
|
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1657
1661
|
const discountPercentage = benefit.discountPercentage * 0.01;
|
|
@@ -1674,6 +1678,26 @@ const applyBenefitByDiscount = (benefit, shoppingCartTotals, additionalInfo) =>
|
|
|
1674
1678
|
total: newTotal
|
|
1675
1679
|
});
|
|
1676
1680
|
};
|
|
1681
|
+
const applyBenefitByDiscountFixed = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1682
|
+
const { total: prevTotal } = shoppingCartTotals;
|
|
1683
|
+
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1684
|
+
const discountFixed = Number(benefit.discountFixed);
|
|
1685
|
+
if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
|
|
1686
|
+
const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
|
|
1687
|
+
const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1688
|
+
const newTotal2 = (copayment - discountFixed).toFixed(4);
|
|
1689
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1690
|
+
totalDiscounts: newTotalDiscounts2,
|
|
1691
|
+
total: Number(newTotal2)
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1695
|
+
const newTotal = prevTotal - discountFixed;
|
|
1696
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1697
|
+
totalDiscounts: newTotalDiscounts,
|
|
1698
|
+
total: newTotal
|
|
1699
|
+
});
|
|
1700
|
+
};
|
|
1677
1701
|
|
|
1678
1702
|
const isBaseProduct = (product) => {
|
|
1679
1703
|
const { attributes, description, name } = product;
|