pb-sxp-ui 1.15.33 → 1.15.34

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/dist/index.js CHANGED
@@ -715,7 +715,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
715
715
  }, [bffDataSource]);
716
716
  // bff API 请求方法
717
717
  const bffFetch = useCallback((path, options) => {
718
- var _a, _b;
718
+ var _a;
719
719
  if (!bffDataSource)
720
720
  return;
721
721
  const url = bffDataSource.url;
@@ -723,49 +723,17 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
723
723
  const queryString = qs.stringify(options.query);
724
724
  path = `${path}?${queryString}`;
725
725
  }
726
- let isTikTokChannel = false;
727
- const params = {};
728
726
  const queryString = location.search.slice(1);
729
727
  (_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
730
- const key = val.split('=')[0];
731
- const value = val.split('=')[1];
732
- params[key] = value;
728
+ val.split('=')[0];
729
+ val.split('=')[1];
733
730
  });
734
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
735
- if (cl_source &&
736
- ((_b = [
737
- '40A-SPRK--DRESS_EYEWEAR-',
738
- '41A-SPRK--MADRAGUE-',
739
- '42A-SPRK--MOOD-',
740
- '43A-SPRK--SUMMER-',
741
- '44A-SPRK--DRESS_EYEWEAR-',
742
- '45A-SPRK--MADRAGUE-',
743
- '46A-SPRK--MOOD-',
744
- '47A-SPRK--SUMMER-',
745
- '48A-SPRK--DRESS_EYEWEAR-',
746
- '49A-SPRK--MADRAGUE-',
747
- '50A-SPRK--MOOD-',
748
- '51A-SPRK--SUMMER-'
749
- ]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
750
- isTikTokChannel = true;
751
- }
752
- // 事件上报优化
753
- // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
754
- if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
755
- return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
756
- JSON.stringify({
757
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
758
- })
759
- ], {
760
- type: 'application/json;charset=UTF-8'
761
- }));
762
- }
763
731
  return window
764
- .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
732
+ .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: options.type === 'beacon'
765
733
  ? JSON.stringify({
766
734
  body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
767
735
  })
768
- : JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
736
+ : JSON.stringify(options.body) }, (options.type === 'beacon' && { keepalive: true })))
769
737
  .then((res) => res.json())
770
738
  .catch((err) => Promise.reject(err));
771
739
  }, [bffDataSource, fakeUserId]);