@nuskin/ns-shop 7.0.5-cx1-13272.12 → 7.0.5-cx1-13272.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-shop",
3
- "version": "7.0.5-cx1-13272.12",
3
+ "version": "7.0.5-cx1-13272.14",
4
4
  "description": "The description that will amaze and astound your audience when they read it",
5
5
  "main": "src/shop.js",
6
6
  "scripts": {
@@ -531,7 +531,7 @@ async function _getRemoteTicket(eventTicketInfo) {
531
531
  response = await axios({
532
532
  method: method,
533
533
  url: `${_getAwsUrl(eventName, ticketId)}${seParams}`,
534
- headers: _getHeaders(),
534
+ headers: _getHeaders(method === 'GET' ? true : false),
535
535
  timeout: 7000
536
536
  });
537
537
 
@@ -646,19 +646,23 @@ function _getAwsUrl(eventName, ticketId) {
646
646
  * @returns {{Accept: string, "Content-Type": string, client_id: *}}
647
647
  * @private
648
648
  */
649
- function _getHeaders() {
649
+ function _getHeaders(noCache = false) {
650
650
  return {
651
651
  'Accept': 'application/json',
652
652
  'Content-Type': 'application/json',
653
- 'client_id': RunConfigService.getRunConfig().clientId
653
+ 'client_id': RunConfigService.getRunConfig().clientId,
654
+ ...(noCache && {'Cache-Control': 'no-cache'}),
655
+ ...(noCache && {'Pragma': 'no-cache'}),
656
+ ...(noCache && {'Expires': '0'})
654
657
  };
655
658
  }
656
659
 
657
660
  async function _getActiveEvents() {
661
+ myAlert(`headers, ${JSON.stringify(_getHeaders(true))}`)
658
662
  let response = await axios({
659
663
  method: 'GET',
660
664
  url: `${_getAwsUrl()}?activeWithin=${ACTIVE_EVENT_WITHIN}`,
661
- headers: _getHeaders()
665
+ headers: _getHeaders(true)
662
666
  });
663
667
  return response.data.salesEventResponse
664
668
  }
@@ -739,7 +743,7 @@ async function _loadMarketEventConfig(force, country=undefined) {
739
743
  const response = await axios({
740
744
  method: 'GET',
741
745
  url: `${_getAwsUrl()}`,
742
- headers: _getHeaders()
746
+ headers: _getHeaders(true)
743
747
  });
744
748
  const salesEvents = response.data.salesEventResponse || [];
745
749
  mktEventConfigMap = {};
@@ -783,6 +787,7 @@ function getStorageItem(key) {
783
787
 
784
788
  async function _checkForMissingTicket(eventName) {
785
789
  if (mktEventConfigMap[eventName] && !eventTicketInfoMap[eventName]) {
790
+ myAlert(`missing ticket for ${eventName}`)
786
791
  await _initEventTicketInfo(eventName);
787
792
  }
788
793
  }
@@ -798,9 +803,7 @@ function myAlert(msg) {
798
803
  * went to sleep. It's intention is to update the wait timer if it has.
799
804
  */
800
805
  async function _initializePolling() {
801
- myAlert('_initializePolling');
802
806
  if (!intervalId) {
803
- myAlert('_initializePolling - no intervalId');
804
807
  const TIMEOUT = 10000;
805
808
  let lastTime = Date.now(),
806
809
  intervalCnt = 1;
@@ -809,8 +812,6 @@ async function _initializePolling() {
809
812
  const now = Date.now();
810
813
  const slept = now > (lastTime + TIMEOUT + 3000)
811
814
 
812
- myAlert('polling triggered');
813
-
814
815
  // if polling market config, only reload it every 30 seconds
815
816
  if (slept || pollMarketConfig && intervalCnt % 6 === 0) {
816
817
  await _loadMarketEventConfig(true);
@@ -835,7 +836,7 @@ async function _initializePolling() {
835
836
  if (window.location.pathname === '/static/checkout/checkout.html') {
836
837
  // check for missing tickets. Only perform on checkout s
837
838
  const activeEvents = await _getActiveEvents();
838
- myAlert(`Active Event check, ${activeEventMap}`);
839
+ myAlert(`Active Event check, ${JSON.stringify(activeEvents)}`);
839
840
 
840
841
  for (const eventInfo of activeEvents) {
841
842
  await _checkForMissingTicket(eventInfo.eventName);
@@ -967,7 +968,7 @@ function _removeWaitCheck(value) {
967
968
  */
968
969
  async function _loadAwsActiveEvents(country) {
969
970
  let activeEventsName = `${ACTIVE_EVENTS}-${country? country: RunConfigService.getRunConfig().country}`,
970
- storageObj = getStorageItem(activeEventsName),
971
+ storageObj = null, // getStorageItem(activeEventsName),
971
972
  ttl = storageObj ? storageObj.ttl - Date.now() : ACTIVE_EVENT_TTL,
972
973
  eventInfos = {},
973
974
  ok = true;
@@ -1120,7 +1121,6 @@ const csConfigCallback = async (configs) => {
1120
1121
  if (configs != null && isSubset(configs, neededConfigMaps)) {
1121
1122
  events.unsubscribe(events.global.CS_CONFIG_SET, csConfigCallback);
1122
1123
  isGuest = CheckoutModeService.isGuestCheckout();
1123
- if (isGuest) alert(`isGuest ${isGuest}`)
1124
1124
  _init(false).then(() => console.log('salesEventService initialized'));
1125
1125
  }
1126
1126
  }