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/index.cjs +49 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -36
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +49 -36
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/index.js +31 -0
- package/es/core/context/SxpDataSourceProvider.d.ts +2 -0
- package/es/core/context/SxpDataSourceProvider.js +20 -37
- package/lib/core/components/SxpPageRender/index.js +31 -0
- package/lib/core/context/SxpDataSourceProvider.d.ts +2 -0
- package/lib/core/context/SxpDataSourceProvider.js +19 -36
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -711,7 +711,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
711
711
|
const [chatlabsId, setChatlabsId] = React.useState();
|
|
712
712
|
const finalPageData = React.useMemo(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
|
|
713
713
|
const pixelPvStatusRef = React.useRef(false);
|
|
714
|
-
const fbcRef = React.useRef('');
|
|
715
714
|
const isShowConsent = React.useMemo(() => {
|
|
716
715
|
var _a, _b, _c, _d;
|
|
717
716
|
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) &&
|
|
@@ -772,23 +771,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
772
771
|
var _a;
|
|
773
772
|
return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
|
|
774
773
|
}, [bffDataSource]);
|
|
775
|
-
|
|
776
|
-
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
|
|
777
|
-
return;
|
|
778
|
-
fbcRef.current = getCookie('_fbc');
|
|
779
|
-
window.OptanonWrapper = function () {
|
|
780
|
-
const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
|
|
781
|
-
if (!activeGroups)
|
|
782
|
-
return;
|
|
783
|
-
if (!(activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4'))) {
|
|
784
|
-
deleteCookie('_fbc');
|
|
785
|
-
}
|
|
786
|
-
else if (fbcRef.current) {
|
|
787
|
-
setCookie('_fbc', fbcRef.current, 90);
|
|
788
|
-
}
|
|
789
|
-
};
|
|
790
|
-
}, [globalConfig]);
|
|
791
|
-
const isActiveTargetingCookie = React.useMemo(() => {
|
|
774
|
+
const getTargetingCookie = () => {
|
|
792
775
|
var _a;
|
|
793
776
|
function getCookie(name) {
|
|
794
777
|
var _a;
|
|
@@ -799,11 +782,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
799
782
|
return '';
|
|
800
783
|
}
|
|
801
784
|
decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
|
|
802
|
-
|
|
785
|
+
console.log('OptanonConsent:', window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups);
|
|
786
|
+
if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
|
|
803
787
|
return true;
|
|
804
788
|
}
|
|
805
789
|
return false;
|
|
806
|
-
}
|
|
790
|
+
};
|
|
807
791
|
// bff API 请求方法
|
|
808
792
|
const bffFetch = React.useCallback((path, options, isBota = true) => {
|
|
809
793
|
var _a;
|
|
@@ -830,7 +814,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
830
814
|
}, [bffDataSource, fakeUserId]);
|
|
831
815
|
const bffCollectEvent = React.useCallback((params) => {
|
|
832
816
|
var _a;
|
|
833
|
-
if (
|
|
817
|
+
if (getTargetingCookie())
|
|
834
818
|
return Promise.resolve();
|
|
835
819
|
const body = {
|
|
836
820
|
eventName: params === null || params === void 0 ? void 0 : params.eventName,
|
|
@@ -842,7 +826,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
842
826
|
body,
|
|
843
827
|
type: 'beacon'
|
|
844
828
|
}, false);
|
|
845
|
-
}, [bffFetch, bffDataSource
|
|
829
|
+
}, [bffFetch, bffDataSource]);
|
|
846
830
|
React.useEffect(() => {
|
|
847
831
|
// if (typeof (window as any)?.fbq === 'function') {
|
|
848
832
|
const OriginalImage = window.Image;
|
|
@@ -852,7 +836,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
852
836
|
const originalSrcDescriptor = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'src');
|
|
853
837
|
Object.defineProperty(img, 'src', {
|
|
854
838
|
set(value) {
|
|
855
|
-
if (
|
|
839
|
+
if (getTargetingCookie() && (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/') || value.includes('https://www.facebook.com/tr'))) {
|
|
856
840
|
return;
|
|
857
841
|
}
|
|
858
842
|
// 继续正常设置 src
|
|
@@ -877,7 +861,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
877
861
|
return img;
|
|
878
862
|
};
|
|
879
863
|
// }
|
|
880
|
-
}, [bffCollectEvent
|
|
864
|
+
}, [bffCollectEvent]);
|
|
881
865
|
React.useEffect(() => {
|
|
882
866
|
// 类型安全声明
|
|
883
867
|
const navigatorWithBeacon = navigator;
|
|
@@ -890,7 +874,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
890
874
|
// 覆盖方法
|
|
891
875
|
navigatorWithBeacon.sendBeacon = function (url, data) {
|
|
892
876
|
const urlString = url instanceof URL ? url.href : url.toString();
|
|
893
|
-
if (
|
|
877
|
+
if (getTargetingCookie() && (urlString.includes('https://tr.snapchat.com/p') || urlString.includes('https://analytics.tiktok.com/api/v2/pixel'))) {
|
|
894
878
|
return true;
|
|
895
879
|
}
|
|
896
880
|
const success = originalSendBeacon(url, data);
|
|
@@ -942,7 +926,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
942
926
|
return () => {
|
|
943
927
|
navigatorWithBeacon.sendBeacon = originalSendBeacon;
|
|
944
928
|
};
|
|
945
|
-
}, [bffCollectEvent
|
|
929
|
+
}, [bffCollectEvent]);
|
|
946
930
|
React.useEffect(() => {
|
|
947
931
|
const _originalFetch = window.fetch;
|
|
948
932
|
// 覆盖 fetch 方法
|
|
@@ -964,7 +948,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
964
948
|
return _originalFetch.apply(this, arguments_1);
|
|
965
949
|
}
|
|
966
950
|
try {
|
|
967
|
-
if (
|
|
951
|
+
if (getTargetingCookie() && (url.includes('https://www.google-analytics.com/g/collect') || url.includes('https://arms-retcode.aliyuncs.com/r.png'))) {
|
|
968
952
|
return Promise.resolve(new Response(''));
|
|
969
953
|
}
|
|
970
954
|
// 1. 先执行原始请求
|
|
@@ -1010,7 +994,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
1010
994
|
}
|
|
1011
995
|
});
|
|
1012
996
|
};
|
|
1013
|
-
}, [bffCollectEvent
|
|
997
|
+
}, [bffCollectEvent]);
|
|
1014
998
|
React.useEffect(() => {
|
|
1015
999
|
const originalOpen = XMLHttpRequest.prototype.open;
|
|
1016
1000
|
const originalSend = XMLHttpRequest.prototype.send;
|
|
@@ -1020,7 +1004,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
1020
1004
|
};
|
|
1021
1005
|
XMLHttpRequest.prototype.send = function (body) {
|
|
1022
1006
|
var _a;
|
|
1023
|
-
if (
|
|
1007
|
+
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'))) {
|
|
1024
1008
|
return;
|
|
1025
1009
|
}
|
|
1026
1010
|
if (this._url && typeof this._url === 'string' && this._url.includes('https://i.giesswein.com/nb-collector')) {
|
|
@@ -1048,7 +1032,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
1048
1032
|
XMLHttpRequest.prototype.open = originalOpen;
|
|
1049
1033
|
XMLHttpRequest.prototype.send = originalSend;
|
|
1050
1034
|
};
|
|
1051
|
-
}, [bffCollectEvent
|
|
1035
|
+
}, [bffCollectEvent]);
|
|
1052
1036
|
React.useEffect(() => {
|
|
1053
1037
|
if (typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
|
|
1054
1038
|
window === null || window === void 0 ? void 0 : window.fbq('track', 'PageView');
|
|
@@ -1175,10 +1159,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
1175
1159
|
}
|
|
1176
1160
|
return expire;
|
|
1177
1161
|
}, [data]);
|
|
1178
|
-
const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
|
|
1162
|
+
const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true, isActiveTargetingCookie = true }) => {
|
|
1179
1163
|
var _a, _b;
|
|
1180
1164
|
// 关闭 BFF 事件上报
|
|
1181
|
-
if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isActiveTargetingCookie) {
|
|
1165
|
+
if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || (isActiveTargetingCookie && getTargetingCookie())) {
|
|
1182
1166
|
return;
|
|
1183
1167
|
}
|
|
1184
1168
|
// 用户信息都是公共的
|
|
@@ -1219,8 +1203,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
1219
1203
|
layoutVariantId,
|
|
1220
1204
|
globalConfig,
|
|
1221
1205
|
playbookType,
|
|
1222
|
-
bffDataSource
|
|
1223
|
-
isActiveTargetingCookie
|
|
1206
|
+
bffDataSource
|
|
1224
1207
|
]);
|
|
1225
1208
|
const getEventParamsByJson = React.useCallback((json, product) => {
|
|
1226
1209
|
var _a, _b, _c;
|
|
@@ -1285,7 +1268,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
1285
1268
|
}, [fakeUserId]);
|
|
1286
1269
|
const bffFbReport = React.useCallback(({ eventName, product }) => {
|
|
1287
1270
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1288
|
-
if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
|
|
1271
|
+
if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || getTargetingCookie()) {
|
|
1289
1272
|
return;
|
|
1290
1273
|
}
|
|
1291
1274
|
let isPushState = false;
|
|
@@ -1351,7 +1334,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
1351
1334
|
type: 'beacon'
|
|
1352
1335
|
});
|
|
1353
1336
|
}
|
|
1354
|
-
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson
|
|
1337
|
+
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
|
|
1355
1338
|
const bffMutateLike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1356
1339
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
|
|
1357
1340
|
return res === null || res === void 0 ? void 0 : res.success;
|
|
@@ -19042,6 +19025,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19042
19025
|
const skipLinkRef = React.useRef(false);
|
|
19043
19026
|
const [pageNum, setPageNum] = React.useState(2);
|
|
19044
19027
|
const videoWidgetRef = React.useRef(null);
|
|
19028
|
+
const fbcRef = React.useRef('');
|
|
19045
19029
|
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();
|
|
19046
19030
|
const { backMainFeed, productView, jumpToWeb } = useEventReport();
|
|
19047
19031
|
const isShowFingerTip = React.useMemo(() => {
|
|
@@ -19485,6 +19469,35 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19485
19469
|
viewTime.current = new Date();
|
|
19486
19470
|
}
|
|
19487
19471
|
}, [openHashtag, data, activeIndex]);
|
|
19472
|
+
React.useEffect(() => {
|
|
19473
|
+
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
|
|
19474
|
+
return;
|
|
19475
|
+
window.OptanonWrapper = function () {
|
|
19476
|
+
var _a, _b;
|
|
19477
|
+
const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
|
|
19478
|
+
if (!activeGroups)
|
|
19479
|
+
return;
|
|
19480
|
+
if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
|
|
19481
|
+
if (fbcRef.current) {
|
|
19482
|
+
setCookie('_fbc', fbcRef.current, 90);
|
|
19483
|
+
}
|
|
19484
|
+
}
|
|
19485
|
+
else {
|
|
19486
|
+
fbcRef.current = getCookie('_fbc');
|
|
19487
|
+
deleteCookie('_fbc');
|
|
19488
|
+
const item = data[activeIndex];
|
|
19489
|
+
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) || '';
|
|
19490
|
+
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
|
19491
|
+
eventInfo: {
|
|
19492
|
+
eventSubject: 'refuseCookie',
|
|
19493
|
+
eventDescription: 'refuseCookie',
|
|
19494
|
+
traceInfo
|
|
19495
|
+
},
|
|
19496
|
+
isActiveTargetingCookie: false
|
|
19497
|
+
});
|
|
19498
|
+
}
|
|
19499
|
+
};
|
|
19500
|
+
}, [globalConfig, bffEventReport, data, activeIndex]);
|
|
19488
19501
|
const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
|
|
19489
19502
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19490
19503
|
const item = data[activeIndex];
|