@sentecacommerce-theme/lib 0.13.3 → 0.13.4

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.
@@ -64,6 +64,7 @@ var LineItemType;
64
64
  })(LineItemType || (LineItemType = {}));
65
65
  var MyCartApiFactory = function() {
66
66
  var instance;
67
+ var hasAnalytics = !process.env.NO_ANALYTICS;
67
68
  function initialise() {
68
69
  var myCartApi1 = new _sdk.MyCartAPI((0, _getSDKConfig).getSDKConfig());
69
70
  var myOrdersApi = new _sdk.MyOrdersAPI((0, _getSDKConfig).getSDKConfig());
@@ -262,7 +263,9 @@ var MyCartApiFactory = function() {
262
263
  var product = data.lineItems.find(function(p) {
263
264
  return p.productId === params.productId;
264
265
  });
265
- product && (0, _addToCart).addToCart(product.variant.sku, params.quantity, product.offer.price || product.offer.originalPrice);
266
+ if (hasAnalytics) {
267
+ product && (0, _addToCart).addToCart(product.variant.sku, params.quantity, product.offer.price || product.offer.originalPrice);
268
+ }
266
269
  queryCache.setQueryData([
267
270
  myCartCacheKeys.useIsExisting,
268
271
  params.productId,
@@ -80,6 +80,7 @@ function _unsupportedIterableToArray(o, minLen) {
80
80
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
81
81
  }
82
82
  var isProduction = process.env.NODE_ENV === 'production';
83
+ var hasAnalytics = !process.env.NO_ANALYTICS;
83
84
  function AnalyticsScripts() {
84
85
  var ref11, ref1, ref2, ref3, ref4;
85
86
  var timeout = (0, _react).useRef(null);
@@ -117,7 +118,7 @@ function AnalyticsScripts() {
117
118
  }
118
119
  };
119
120
  (0, _react).useEffect(function() {
120
- if (!isProduction) return;
121
+ if (!isProduction && !hasAnalytics) return;
121
122
  if (document) {
122
123
  timeout.current = setTimeout(initAnalytics, 3500);
123
124
  document.addEventListener('scroll', initAnalyticsOnEvent);
@@ -129,7 +130,7 @@ function AnalyticsScripts() {
129
130
  ]);
130
131
  var pageView = (0, _pageView).getPageView(config);
131
132
  (0, _react).useEffect(function() {
132
- if (!isProduction) return;
133
+ if (!isProduction && !hasAnalytics) return;
133
134
  var handleRouteChange = function(url) {
134
135
  if ('browser' in process) {
135
136
  setTimeout(function() {
@@ -91,6 +91,7 @@ var useCheckoutSubmit = function(param) {
91
91
  var onSuccess = param.onSuccess, onBeforeBoricaRedirect = param.onBeforeBoricaRedirect, onBeforePaypalRedirect = param.onBeforePaypalRedirect, onBeforeUniCreditRedirect = param.onBeforeUniCreditRedirect, onError = param.onError, withMeta = param.withMeta, disablePaymentRedirects = param.disablePaymentRedirects;
92
92
  var Config = (0, _useConfig).useConfigState();
93
93
  var districtMeta = (0, _).useDistrictMeta();
94
+ var hasAnalytics = !process.env.NO_ANALYTICS;
94
95
  var ref = _slicedToArray(_.myOrdersApi.useCreate(withMeta ? districtMeta : {}, function() {
95
96
  var _ref = _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee(result) {
96
97
  var paypalPayment, boricaPayment, uniCreditPayment, boricaResult, paypalResponse, uniCreditStartSessionResponse;
@@ -98,7 +99,9 @@ var useCheckoutSubmit = function(param) {
98
99
  while(1)switch(_ctx.prev = _ctx.next){
99
100
  case 0:
100
101
  // Analytics
101
- (0, _purchase).purchase(result, Config);
102
+ if (hasAnalytics) {
103
+ (0, _purchase).purchase(result, Config);
104
+ }
102
105
  paypalPayment = result.payments.find(function(payment) {
103
106
  return payment.type === _sdk.PaymentDTOTypeEnum.PaymentServiceProvider && payment.moduleKey === 'Paypal';
104
107
  });
@@ -250,7 +250,9 @@ export var MyCartApiFactory = function() {
250
250
  var product = data.lineItems.find(function(p) {
251
251
  return p.productId === params.productId;
252
252
  });
253
- product && addToCart(product.variant.sku, params.quantity, product.offer.price || product.offer.originalPrice);
253
+ if (hasAnalytics) {
254
+ product && addToCart(product.variant.sku, params.quantity, product.offer.price || product.offer.originalPrice);
255
+ }
254
256
  queryCache.setQueryData([
255
257
  myCartCacheKeys.useIsExisting,
256
258
  params.productId,
@@ -543,6 +545,7 @@ export var MyCartApiFactory = function() {
543
545
  });
544
546
  };
545
547
  var instance;
548
+ var hasAnalytics = !process.env.NO_ANALYTICS;
546
549
  return {
547
550
  getInstance: function getInstance() {
548
551
  if (!instance) {
@@ -50,6 +50,7 @@ function _unsupportedIterableToArray(o, minLen) {
50
50
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
51
51
  }
52
52
  var isProduction = process.env.NODE_ENV === 'production';
53
+ var hasAnalytics = !process.env.NO_ANALYTICS;
53
54
  export function AnalyticsScripts() {
54
55
  var ref11, ref1, ref2, ref3, ref4;
55
56
  var timeout = useRef(null);
@@ -87,7 +88,7 @@ export function AnalyticsScripts() {
87
88
  }
88
89
  };
89
90
  useEffect(function() {
90
- if (!isProduction) return;
91
+ if (!isProduction && !hasAnalytics) return;
91
92
  if (document) {
92
93
  timeout.current = setTimeout(initAnalytics, 3500);
93
94
  document.addEventListener('scroll', initAnalyticsOnEvent);
@@ -99,7 +100,7 @@ export function AnalyticsScripts() {
99
100
  ]);
100
101
  var pageView = getPageView(config);
101
102
  useEffect(function() {
102
- if (!isProduction) return;
103
+ if (!isProduction && !hasAnalytics) return;
103
104
  var handleRouteChange = function(url) {
104
105
  if ('browser' in process) {
105
106
  setTimeout(function() {
@@ -82,6 +82,7 @@ export var useCheckoutSubmit = function(param) {
82
82
  var onSuccess = param.onSuccess, onBeforeBoricaRedirect = param.onBeforeBoricaRedirect, onBeforePaypalRedirect = param.onBeforePaypalRedirect, onBeforeUniCreditRedirect = param.onBeforeUniCreditRedirect, onError = param.onError, withMeta = param.withMeta, disablePaymentRedirects = param.disablePaymentRedirects;
83
83
  var Config = useConfigState();
84
84
  var districtMeta = useDistrictMeta();
85
+ var hasAnalytics = !process.env.NO_ANALYTICS;
85
86
  var ref = _slicedToArray(myOrdersApi.useCreate(withMeta ? districtMeta : {}, function() {
86
87
  var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(result) {
87
88
  var paypalPayment, boricaPayment, uniCreditPayment, boricaResult, paypalResponse, uniCreditStartSessionResponse;
@@ -89,7 +90,9 @@ export var useCheckoutSubmit = function(param) {
89
90
  while(1)switch(_ctx.prev = _ctx.next){
90
91
  case 0:
91
92
  // Analytics
92
- purchase(result, Config);
93
+ if (hasAnalytics) {
94
+ purchase(result, Config);
95
+ }
93
96
  paypalPayment = result.payments.find(function(payment) {
94
97
  return payment.type === PaymentDTOTypeEnum.PaymentServiceProvider && payment.moduleKey === 'Paypal';
95
98
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.13.3",
4
+ "version": "0.13.4",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "watch:cjs": "swc src --out-dir dist/cjs -w",
32
32
  "watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
33
33
  },
34
- "gitHead": "3f7ef1f62b26764823980283fd8c545c0e9aae0e",
34
+ "gitHead": "d71c467b1cdeaeb44df668af9354f57824df1230",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.13.3",
40
- "@sentecacommerce-theme/cms": "^0.13.3",
39
+ "@sentecacommerce-theme/base": "^0.13.4",
40
+ "@sentecacommerce-theme/cms": "^0.13.4",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",