pb-sxp-ui 1.15.32 → 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.cjs CHANGED
@@ -674,6 +674,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
674
674
  const [playbookType, setPlaybookType] = React.useState();
675
675
  const [chatlabsId, setChatlabsId] = React.useState();
676
676
  const finalPageData = React.useMemo(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
677
+ const pixelPvStatusRef = React.useRef(false);
677
678
  const isShowConsent = React.useMemo(() => {
678
679
  var _a, _b, _c, _d;
679
680
  return (((((_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.privacy_necessity) && !isAgreePolicy && !isEditor) || isOpenConsent) &&
@@ -736,7 +737,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
736
737
  }, [bffDataSource]);
737
738
  // bff API 请求方法
738
739
  const bffFetch = React.useCallback((path, options) => {
739
- var _a, _b;
740
+ var _a;
740
741
  if (!bffDataSource)
741
742
  return;
742
743
  const url = bffDataSource.url;
@@ -744,49 +745,17 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
744
745
  const queryString = qs.stringify(options.query);
745
746
  path = `${path}?${queryString}`;
746
747
  }
747
- let isTikTokChannel = false;
748
- const params = {};
749
748
  const queryString = location.search.slice(1);
750
749
  (_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
751
- const key = val.split('=')[0];
752
- const value = val.split('=')[1];
753
- params[key] = value;
750
+ val.split('=')[0];
751
+ val.split('=')[1];
754
752
  });
755
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
756
- if (cl_source &&
757
- ((_b = [
758
- '40A-SPRK--DRESS_EYEWEAR-',
759
- '41A-SPRK--MADRAGUE-',
760
- '42A-SPRK--MOOD-',
761
- '43A-SPRK--SUMMER-',
762
- '44A-SPRK--DRESS_EYEWEAR-',
763
- '45A-SPRK--MADRAGUE-',
764
- '46A-SPRK--MOOD-',
765
- '47A-SPRK--SUMMER-',
766
- '48A-SPRK--DRESS_EYEWEAR-',
767
- '49A-SPRK--MADRAGUE-',
768
- '50A-SPRK--MOOD-',
769
- '51A-SPRK--SUMMER-'
770
- ]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
771
- isTikTokChannel = true;
772
- }
773
- // 事件上报优化
774
- // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
775
- if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
776
- return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
777
- JSON.stringify({
778
- body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
779
- })
780
- ], {
781
- type: 'application/json;charset=UTF-8'
782
- }));
783
- }
784
753
  return window
785
- .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
754
+ .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'
786
755
  ? JSON.stringify({
787
756
  body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
788
757
  })
789
- : JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
758
+ : JSON.stringify(options.body) }, (options.type === 'beacon' && { keepalive: true })))
790
759
  .then((res) => res.json())
791
760
  .catch((err) => Promise.reject(err));
792
761
  }, [bffDataSource, fakeUserId]);
@@ -1037,6 +1006,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1037
1006
  }
1038
1007
  }
1039
1008
  if (eventName === 'PageView' && (pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) === 'PageView') {
1009
+ if (!pixelPvStatusRef.current) {
1010
+ pixelPvStatusRef.current = true;
1011
+ return;
1012
+ }
1040
1013
  const currentUrl = window.location.href;
1041
1014
  const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
1042
1015
  history.pushState({ path: newUrl }, '', newUrl);