@artisan-commerce/analytics-rn 0.3.0-canary.64 → 0.3.0-canary.66

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.
@@ -40,7 +40,7 @@ const getState$2 = () => {
40
40
 
41
41
  var name = "@artisan-commerce/analytics-rn";
42
42
  var description = "Artisn commerce analytics react native library";
43
- var version = "0.3.0-canary.64";
43
+ var version = "0.3.0-canary.66";
44
44
  var main = "./dist/bundle.esm.js";
45
45
  var module = "./dist/bundle.esm.js";
46
46
  var types = "./dist/bundle.d.ts";
@@ -82,9 +82,9 @@ var dependencies = {
82
82
  "snake-case": "^3.0.4"
83
83
  };
84
84
  var devDependencies = {
85
- "@artisan-commerce/products": "0.9.0-canary.40",
86
- "@artisan-commerce/shopping-cart": "0.12.0-canary.60",
87
- "@artisan-commerce/types": "0.14.0-canary.31",
85
+ "@artisan-commerce/products": "0.9.0-canary.41",
86
+ "@artisan-commerce/shopping-cart": "0.12.0-canary.62",
87
+ "@artisan-commerce/types": "0.14.0-canary.32",
88
88
  "@babel/core": "^7.13.15",
89
89
  "@babel/preset-env": "^7.10.4",
90
90
  "@babel/preset-react": "^7.10.4",
@@ -103,7 +103,7 @@ var peerDependencies = {
103
103
  react: ">=16.8.6",
104
104
  "react-native-fbsdk-next": "*"
105
105
  };
106
- var gitHead = "de13038c82f26138ab893018f60d3d3bd2a37c1f";
106
+ var gitHead = "d1db871e73166816ef42b1c0e191abd80ccc69df";
107
107
  var packageJSON = {
108
108
  name: name,
109
109
  description: description,
@@ -474,7 +474,7 @@ var __objRest$3V = (source, exclude) => {
474
474
  let initialized = false;
475
475
  const initAnalytics = (config) => {
476
476
  if (initialized) {
477
- 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.", "warn");
477
+ 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");
478
478
  return;
479
479
  }
480
480
  initialized = true;
@@ -786,18 +786,19 @@ var __spreadValues$k$1 = (a, b) => {
786
786
  }
787
787
  return a;
788
788
  };
789
- const { DEFAULT_SHOPPING_CART_NAME: DEFAULT_SHOPPING_CART_NAME$3, DEFAULT_MAX_SHOPPING_CARTS } = CONSTANTS;
789
+ const { DEFAULT_SHOPPING_CART_NAME: DEFAULT_SHOPPING_CART_NAME$2, DEFAULT_MAX_SHOPPING_CARTS } = CONSTANTS;
790
790
  const initialState = {
791
791
  artisnApp: void 0,
792
792
  accountId: void 0,
793
793
  customerId: void 0,
794
- activeShoppingCart: DEFAULT_SHOPPING_CART_NAME$3,
794
+ activeShoppingCart: DEFAULT_SHOPPING_CART_NAME$2,
795
795
  maxShoppingCarts: DEFAULT_MAX_SHOPPING_CARTS,
796
796
  wallets: {},
797
797
  anonymous: false,
798
798
  initialized: false,
799
799
  queue: new ActionQueue(),
800
- eventLoop: new EventLoop()
800
+ eventLoop: new EventLoop(),
801
+ debug: false
801
802
  };
802
803
  Object.freeze(initialState);
803
804
  let state = __spreadValues$k$1({}, initialState);
@@ -1508,13 +1509,16 @@ const applyBenefits = (additionalInfo, benefits, shoppingCartTotals) => {
1508
1509
  }
1509
1510
  const benefitsValues = Object.values(benefits);
1510
1511
  return benefitsValues.reduce((acc, benefit) => {
1511
- if (benefit.type === "DISCOUNT") {
1512
- return applyBenefitByDiscount(benefit, acc, additionalInfo);
1512
+ if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
1513
+ return applyBenefitByDiscountPercentage(benefit, acc, additionalInfo);
1514
+ }
1515
+ if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
1516
+ return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
1513
1517
  }
1514
1518
  return acc;
1515
1519
  }, shoppingCartTotals);
1516
1520
  };
1517
- const applyBenefitByDiscount = (benefit, shoppingCartTotals, additionalInfo) => {
1521
+ const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additionalInfo) => {
1518
1522
  const { subtotal, total: prevTotal } = shoppingCartTotals;
1519
1523
  const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
1520
1524
  const discountPercentage = benefit.discountPercentage * 0.01;
@@ -1537,6 +1541,26 @@ const applyBenefitByDiscount = (benefit, shoppingCartTotals, additionalInfo) =>
1537
1541
  total: newTotal
1538
1542
  });
1539
1543
  };
1544
+ const applyBenefitByDiscountFixed = (benefit, shoppingCartTotals, additionalInfo) => {
1545
+ const { total: prevTotal } = shoppingCartTotals;
1546
+ const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
1547
+ const discountFixed = Number(benefit.discountFixed);
1548
+ if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
1549
+ const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
1550
+ const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
1551
+ const newTotal2 = (copayment - discountFixed).toFixed(4);
1552
+ return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
1553
+ totalDiscounts: newTotalDiscounts2,
1554
+ total: Number(newTotal2)
1555
+ });
1556
+ }
1557
+ const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
1558
+ const newTotal = prevTotal - discountFixed;
1559
+ return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
1560
+ totalDiscounts: newTotalDiscounts,
1561
+ total: newTotal
1562
+ });
1563
+ };
1540
1564
 
1541
1565
  const isBaseProduct = (product) => {
1542
1566
  const { attributes, description, name } = product;