@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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.2.0-canary.65](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/analytics-web@0.2.0-canary.64...@artisan-commerce/analytics-web@0.2.0-canary.65) (2022-02-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **global:** make initialization console warns be only available on debug mode ([afcd6a3](https://bitbucket.org/tradesystem/artisn_sdk/commit/afcd6a3ada69a93e5fbf6e0fe8b887d2f82cc9d2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [0.2.0-canary.64](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/analytics-web@0.2.0-canary.63...@artisan-commerce/analytics-web@0.2.0-canary.64) (2022-02-03)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @artisan-commerce/analytics-web
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [0.2.0-canary.63](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/analytics-web@0.2.0-canary.62...@artisan-commerce/analytics-web@0.2.0-canary.63) (2022-01-29)
|
|
7
24
|
|
|
8
25
|
**Note:** Version bump only for package @artisan-commerce/analytics-web
|
package/dist/bundle.cjs.js
CHANGED
|
@@ -39,7 +39,7 @@ const getState$2 = () => {
|
|
|
39
39
|
|
|
40
40
|
var name = "@artisan-commerce/analytics-web";
|
|
41
41
|
var description = "Artisn commerce analytics web library";
|
|
42
|
-
var version = "0.2.0-canary.
|
|
42
|
+
var version = "0.2.0-canary.64";
|
|
43
43
|
var main = "./dist/bundle.cjs.js";
|
|
44
44
|
var module$1 = "./dist/bundle.esm.js";
|
|
45
45
|
var types = "./dist/bundle.d.ts";
|
|
@@ -80,9 +80,9 @@ var dependencies = {
|
|
|
80
80
|
"snake-case": "^3.0.4"
|
|
81
81
|
};
|
|
82
82
|
var devDependencies = {
|
|
83
|
-
"@artisan-commerce/products": "0.9.0-canary.
|
|
84
|
-
"@artisan-commerce/shopping-cart": "0.12.0-canary.
|
|
85
|
-
"@artisan-commerce/types": "0.14.0-canary.
|
|
83
|
+
"@artisan-commerce/products": "0.9.0-canary.41",
|
|
84
|
+
"@artisan-commerce/shopping-cart": "0.12.0-canary.61",
|
|
85
|
+
"@artisan-commerce/types": "0.14.0-canary.32"
|
|
86
86
|
};
|
|
87
87
|
var peerDependencies = {
|
|
88
88
|
"@artisan-commerce/products": "*",
|
|
@@ -586,7 +586,7 @@ const initAnalytics = (config) => {
|
|
|
586
586
|
setInitialState();
|
|
587
587
|
const { initialized } = getState$1();
|
|
588
588
|
if (initialized) {
|
|
589
|
-
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.", "
|
|
589
|
+
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");
|
|
590
590
|
return;
|
|
591
591
|
}
|
|
592
592
|
const { providers, shareArtisnAnalytics } = config;
|
|
@@ -927,18 +927,19 @@ var __spreadValues$k$1 = (a, b) => {
|
|
|
927
927
|
}
|
|
928
928
|
return a;
|
|
929
929
|
};
|
|
930
|
-
const { DEFAULT_SHOPPING_CART_NAME: DEFAULT_SHOPPING_CART_NAME$
|
|
930
|
+
const { DEFAULT_SHOPPING_CART_NAME: DEFAULT_SHOPPING_CART_NAME$2, DEFAULT_MAX_SHOPPING_CARTS } = CONSTANTS;
|
|
931
931
|
const initialState = {
|
|
932
932
|
artisnApp: void 0,
|
|
933
933
|
accountId: void 0,
|
|
934
934
|
customerId: void 0,
|
|
935
|
-
activeShoppingCart: DEFAULT_SHOPPING_CART_NAME$
|
|
935
|
+
activeShoppingCart: DEFAULT_SHOPPING_CART_NAME$2,
|
|
936
936
|
maxShoppingCarts: DEFAULT_MAX_SHOPPING_CARTS,
|
|
937
937
|
wallets: {},
|
|
938
938
|
anonymous: false,
|
|
939
939
|
initialized: false,
|
|
940
940
|
queue: new ActionQueue(),
|
|
941
|
-
eventLoop: new EventLoop()
|
|
941
|
+
eventLoop: new EventLoop(),
|
|
942
|
+
debug: false
|
|
942
943
|
};
|
|
943
944
|
Object.freeze(initialState);
|
|
944
945
|
let state = __spreadValues$k$1({}, initialState);
|
|
@@ -1649,13 +1650,16 @@ const applyBenefits = (additionalInfo, benefits, shoppingCartTotals) => {
|
|
|
1649
1650
|
}
|
|
1650
1651
|
const benefitsValues = Object.values(benefits);
|
|
1651
1652
|
return benefitsValues.reduce((acc, benefit) => {
|
|
1652
|
-
if (benefit.type === "
|
|
1653
|
-
return
|
|
1653
|
+
if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
|
|
1654
|
+
return applyBenefitByDiscountPercentage(benefit, acc, additionalInfo);
|
|
1655
|
+
}
|
|
1656
|
+
if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
|
|
1657
|
+
return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
|
|
1654
1658
|
}
|
|
1655
1659
|
return acc;
|
|
1656
1660
|
}, shoppingCartTotals);
|
|
1657
1661
|
};
|
|
1658
|
-
const
|
|
1662
|
+
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1659
1663
|
const { subtotal, total: prevTotal } = shoppingCartTotals;
|
|
1660
1664
|
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1661
1665
|
const discountPercentage = benefit.discountPercentage * 0.01;
|
|
@@ -1678,6 +1682,26 @@ const applyBenefitByDiscount = (benefit, shoppingCartTotals, additionalInfo) =>
|
|
|
1678
1682
|
total: newTotal
|
|
1679
1683
|
});
|
|
1680
1684
|
};
|
|
1685
|
+
const applyBenefitByDiscountFixed = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1686
|
+
const { total: prevTotal } = shoppingCartTotals;
|
|
1687
|
+
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1688
|
+
const discountFixed = Number(benefit.discountFixed);
|
|
1689
|
+
if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
|
|
1690
|
+
const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
|
|
1691
|
+
const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1692
|
+
const newTotal2 = (copayment - discountFixed).toFixed(4);
|
|
1693
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1694
|
+
totalDiscounts: newTotalDiscounts2,
|
|
1695
|
+
total: Number(newTotal2)
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1699
|
+
const newTotal = prevTotal - discountFixed;
|
|
1700
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1701
|
+
totalDiscounts: newTotalDiscounts,
|
|
1702
|
+
total: newTotal
|
|
1703
|
+
});
|
|
1704
|
+
};
|
|
1681
1705
|
|
|
1682
1706
|
const isBaseProduct = (product) => {
|
|
1683
1707
|
const { attributes, description, name } = product;
|