pb-sxp-ui 1.19.0-alpha.1 → 1.19.0-alpha.3

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/pb-ui.js CHANGED
@@ -704,7 +704,6 @@
704
704
  const [chatlabsId, setChatlabsId] = React.useState();
705
705
  const finalPageData = React.useMemo(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
706
706
  const pixelPvStatusRef = React.useRef(false);
707
- const fbcRef = React.useRef('');
708
707
  const isShowConsent = React.useMemo(() => {
709
708
  var _a, _b, _c, _d;
710
709
  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) &&
@@ -765,23 +764,7 @@
765
764
  var _a;
766
765
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
767
766
  }, [bffDataSource]);
768
- React.useEffect(() => {
769
- if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
770
- return;
771
- fbcRef.current = getCookie('_fbc');
772
- window.OptanonWrapper = function () {
773
- const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
774
- if (!activeGroups)
775
- return;
776
- if (!(activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4'))) {
777
- deleteCookie('_fbc');
778
- }
779
- else if (fbcRef.current) {
780
- setCookie('_fbc', fbcRef.current, 90);
781
- }
782
- };
783
- }, [globalConfig]);
784
- const isActiveTargetingCookie = React.useMemo(() => {
767
+ const getTargetingCookie = () => {
785
768
  var _a;
786
769
  function getCookie(name) {
787
770
  var _a;
@@ -792,11 +775,12 @@
792
775
  return '';
793
776
  }
794
777
  decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
795
- if (((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
778
+ console.log('OptanonConsent:', window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups);
779
+ if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
796
780
  return true;
797
781
  }
798
782
  return false;
799
- }, [globalConfig]);
783
+ };
800
784
  // bff API 请求方法
801
785
  const bffFetch = React.useCallback((path, options, isBota = true) => {
802
786
  var _a;
@@ -823,7 +807,7 @@
823
807
  }, [bffDataSource, fakeUserId]);
824
808
  const bffCollectEvent = React.useCallback((params) => {
825
809
  var _a;
826
- if (isActiveTargetingCookie)
810
+ if (getTargetingCookie())
827
811
  return Promise.resolve();
828
812
  const body = {
829
813
  eventName: params === null || params === void 0 ? void 0 : params.eventName,
@@ -835,7 +819,7 @@
835
819
  body,
836
820
  type: 'beacon'
837
821
  }, false);
838
- }, [bffFetch, bffDataSource, isActiveTargetingCookie]);
822
+ }, [bffFetch, bffDataSource]);
839
823
  React.useEffect(() => {
840
824
  // if (typeof (window as any)?.fbq === 'function') {
841
825
  const OriginalImage = window.Image;
@@ -845,7 +829,7 @@
845
829
  const originalSrcDescriptor = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'src');
846
830
  Object.defineProperty(img, 'src', {
847
831
  set(value) {
848
- if (isActiveTargetingCookie && (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/') || value.includes('https://www.facebook.com/tr'))) {
832
+ if (getTargetingCookie() && (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/') || value.includes('https://www.facebook.com/tr'))) {
849
833
  return;
850
834
  }
851
835
  // 继续正常设置 src
@@ -870,7 +854,7 @@
870
854
  return img;
871
855
  };
872
856
  // }
873
- }, [bffCollectEvent, isActiveTargetingCookie]);
857
+ }, [bffCollectEvent]);
874
858
  React.useEffect(() => {
875
859
  // 类型安全声明
876
860
  const navigatorWithBeacon = navigator;
@@ -883,7 +867,7 @@
883
867
  // 覆盖方法
884
868
  navigatorWithBeacon.sendBeacon = function (url, data) {
885
869
  const urlString = url instanceof URL ? url.href : url.toString();
886
- if (isActiveTargetingCookie && (urlString.includes('https://tr.snapchat.com/p') || urlString.includes('https://analytics.tiktok.com/api/v2/pixel'))) {
870
+ if (getTargetingCookie() && (urlString.includes('https://tr.snapchat.com/p') || urlString.includes('https://analytics.tiktok.com/api/v2/pixel'))) {
887
871
  return true;
888
872
  }
889
873
  const success = originalSendBeacon(url, data);
@@ -935,7 +919,7 @@
935
919
  return () => {
936
920
  navigatorWithBeacon.sendBeacon = originalSendBeacon;
937
921
  };
938
- }, [bffCollectEvent, isActiveTargetingCookie]);
922
+ }, [bffCollectEvent]);
939
923
  React.useEffect(() => {
940
924
  const _originalFetch = window.fetch;
941
925
  // 覆盖 fetch 方法
@@ -957,7 +941,7 @@
957
941
  return _originalFetch.apply(this, arguments_1);
958
942
  }
959
943
  try {
960
- if (isActiveTargetingCookie && (url.includes('https://www.google-analytics.com/g/collect') || url.includes('https://arms-retcode.aliyuncs.com/r.png'))) {
944
+ if (getTargetingCookie() && (url.includes('https://www.google-analytics.com/g/collect') || url.includes('https://arms-retcode.aliyuncs.com/r.png'))) {
961
945
  return Promise.resolve(new Response(''));
962
946
  }
963
947
  // 1. 先执行原始请求
@@ -1003,7 +987,7 @@
1003
987
  }
1004
988
  });
1005
989
  };
1006
- }, [bffCollectEvent, isActiveTargetingCookie]);
990
+ }, [bffCollectEvent]);
1007
991
  React.useEffect(() => {
1008
992
  const originalOpen = XMLHttpRequest.prototype.open;
1009
993
  const originalSend = XMLHttpRequest.prototype.send;
@@ -1013,7 +997,7 @@
1013
997
  };
1014
998
  XMLHttpRequest.prototype.send = function (body) {
1015
999
  var _a;
1016
- if (isActiveTargetingCookie && this._url && typeof this._url === 'string' && (this._url.includes('https://rumcollector.uptime.com') || this._url.includes('https://arms-retcode.aliyuncs.com/r.png') || this._url.includes('https://i.giesswein.com/nb-collector'))) {
1000
+ if (getTargetingCookie() && this._url && typeof this._url === 'string' && (this._url.includes('https://rumcollector.uptime.com') || this._url.includes('https://arms-retcode.aliyuncs.com/r.png') || this._url.includes('https://i.giesswein.com/nb-collector'))) {
1017
1001
  return;
1018
1002
  }
1019
1003
  if (this._url && typeof this._url === 'string' && this._url.includes('https://i.giesswein.com/nb-collector')) {
@@ -1041,7 +1025,7 @@
1041
1025
  XMLHttpRequest.prototype.open = originalOpen;
1042
1026
  XMLHttpRequest.prototype.send = originalSend;
1043
1027
  };
1044
- }, [bffCollectEvent, isActiveTargetingCookie]);
1028
+ }, [bffCollectEvent]);
1045
1029
  React.useEffect(() => {
1046
1030
  if (typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
1047
1031
  window === null || window === void 0 ? void 0 : window.fbq('track', 'PageView');
@@ -1168,10 +1152,10 @@
1168
1152
  }
1169
1153
  return expire;
1170
1154
  }, [data]);
1171
- const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
1155
+ const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true, isActiveTargetingCookie = true }) => {
1172
1156
  var _a, _b;
1173
1157
  // 关闭 BFF 事件上报
1174
- if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isActiveTargetingCookie) {
1158
+ if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || (isActiveTargetingCookie && getTargetingCookie())) {
1175
1159
  return;
1176
1160
  }
1177
1161
  // 用户信息都是公共的
@@ -1212,8 +1196,7 @@
1212
1196
  layoutVariantId,
1213
1197
  globalConfig,
1214
1198
  playbookType,
1215
- bffDataSource,
1216
- isActiveTargetingCookie
1199
+ bffDataSource
1217
1200
  ]);
1218
1201
  const getEventParamsByJson = React.useCallback((json, product) => {
1219
1202
  var _a, _b, _c;
@@ -1278,7 +1261,7 @@
1278
1261
  }, [fakeUserId]);
1279
1262
  const bffFbReport = React.useCallback(({ eventName, product }) => {
1280
1263
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1281
- if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isActiveTargetingCookie) {
1264
+ if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || getTargetingCookie()) {
1282
1265
  return;
1283
1266
  }
1284
1267
  let isPushState = false;
@@ -1344,7 +1327,7 @@
1344
1327
  type: 'beacon'
1345
1328
  });
1346
1329
  }
1347
- }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson, isActiveTargetingCookie]);
1330
+ }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
1348
1331
  const bffMutateLike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
1349
1332
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
1350
1333
  return res === null || res === void 0 ? void 0 : res.success;
@@ -19035,6 +19018,7 @@ Made in Italy` })));
19035
19018
  const skipLinkRef = React.useRef(false);
19036
19019
  const [pageNum, setPageNum] = React.useState(2);
19037
19020
  const videoWidgetRef = React.useRef(null);
19021
+ const fbcRef = React.useRef('');
19038
19022
  const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession, isDiyH5 } = useSxpDataSource();
19039
19023
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
19040
19024
  const isShowFingerTip = React.useMemo(() => {
@@ -19478,6 +19462,35 @@ Made in Italy` })));
19478
19462
  viewTime.current = new Date();
19479
19463
  }
19480
19464
  }, [openHashtag, data, activeIndex]);
19465
+ React.useEffect(() => {
19466
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
19467
+ return;
19468
+ window.OptanonWrapper = function () {
19469
+ var _a, _b;
19470
+ const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19471
+ if (!activeGroups)
19472
+ return;
19473
+ if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19474
+ if (fbcRef.current) {
19475
+ setCookie('_fbc', fbcRef.current, 90);
19476
+ }
19477
+ }
19478
+ else {
19479
+ fbcRef.current = getCookie('_fbc');
19480
+ deleteCookie('_fbc');
19481
+ const item = data[activeIndex];
19482
+ const traceInfo = ((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.traceInfo) || ((_b = item === null || item === void 0 ? void 0 : item.product) === null || _b === void 0 ? void 0 : _b.traceInfo) || '';
19483
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19484
+ eventInfo: {
19485
+ eventSubject: 'refuseCookie',
19486
+ eventDescription: 'refuseCookie',
19487
+ traceInfo
19488
+ },
19489
+ isActiveTargetingCookie: false
19490
+ });
19491
+ }
19492
+ };
19493
+ }, [globalConfig, bffEventReport, data, activeIndex]);
19481
19494
  const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
19482
19495
  var _a, _b, _c, _d, _e, _f, _g, _h;
19483
19496
  const item = data[activeIndex];