pb-sxp-ui 1.20.10 → 1.20.11
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 +248 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +248 -172
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +7 -7
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +7 -7
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +248 -172
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +7 -7
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/DiyPortalPreview/VideoWidget.js +10 -8
- package/es/core/components/SxpPageRender/LikeButton/index.js +20 -18
- package/es/core/components/SxpPageRender/PictureGroup/index.d.ts +5 -0
- package/es/core/components/SxpPageRender/PictureGroup/index.js +39 -13
- package/es/core/components/SxpPageRender/VideoWidget/index.js +33 -46
- package/es/core/components/SxpPageRender/WaterFall/index.js +4 -3
- package/es/core/components/SxpPageRender/index.js +56 -40
- package/es/core/context/SxpDataSourceProvider.d.ts +5 -12
- package/es/core/context/SxpDataSourceProvider.js +81 -38
- package/es/core/hooks/useEventReport.js +6 -5
- package/lib/core/components/DiyPortalPreview/VideoWidget.js +10 -8
- package/lib/core/components/SxpPageRender/LikeButton/index.js +20 -18
- package/lib/core/components/SxpPageRender/PictureGroup/index.d.ts +5 -0
- package/lib/core/components/SxpPageRender/PictureGroup/index.js +38 -12
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +33 -46
- package/lib/core/components/SxpPageRender/WaterFall/index.js +4 -3
- package/lib/core/components/SxpPageRender/index.js +56 -40
- package/lib/core/context/SxpDataSourceProvider.d.ts +5 -12
- package/lib/core/context/SxpDataSourceProvider.js +81 -38
- package/lib/core/hooks/useEventReport.js +6 -5
- package/package.json +1 -1
|
@@ -22,12 +22,8 @@ export interface ISxpDataSourceContext {
|
|
|
22
22
|
value: string;
|
|
23
23
|
}>;
|
|
24
24
|
}) => Promise<boolean | undefined>;
|
|
25
|
-
mutateUnlike?: (body:
|
|
26
|
-
|
|
27
|
-
}) => Promise<boolean>;
|
|
28
|
-
mutateLike?: (body: {
|
|
29
|
-
content: string;
|
|
30
|
-
}) => Promise<boolean>;
|
|
25
|
+
mutateUnlike?: (body: Record<string, any>) => Promise<boolean>;
|
|
26
|
+
mutateLike?: (body: Record<string, any>) => Promise<boolean>;
|
|
31
27
|
popupDetailData?: RecItemType;
|
|
32
28
|
setPopupDetailData?: React.Dispatch<React.SetStateAction<any | null>>;
|
|
33
29
|
loadVideos?: (page: number) => Promise<RecommendVideoResultType | undefined>;
|
|
@@ -100,6 +96,7 @@ export interface ISxpDataSourceContext {
|
|
|
100
96
|
getAccount?: () => Promise<any>;
|
|
101
97
|
accountSonsent?: (v: boolean) => Promise<boolean>;
|
|
102
98
|
isDiyH5?: boolean;
|
|
99
|
+
firstRtcList?: RecItemType[];
|
|
103
100
|
pixelPvStatusRef?: any;
|
|
104
101
|
}
|
|
105
102
|
export declare const SxpDataSourceContext: React.Context<ISxpDataSourceContext>;
|
|
@@ -114,12 +111,8 @@ export interface SxpDataSourceProviderProps {
|
|
|
114
111
|
value: string;
|
|
115
112
|
}>;
|
|
116
113
|
}) => Promise<boolean | undefined>;
|
|
117
|
-
mutateUnlike: (body:
|
|
118
|
-
|
|
119
|
-
}) => Promise<boolean>;
|
|
120
|
-
mutateLike: (body: {
|
|
121
|
-
content: string;
|
|
122
|
-
}) => Promise<boolean>;
|
|
114
|
+
mutateUnlike: (body: Record<string, any>) => Promise<boolean>;
|
|
115
|
+
mutateLike: (body: Record<string, any>) => Promise<boolean>;
|
|
123
116
|
pageData?: PageData;
|
|
124
117
|
}) => ReactNode;
|
|
125
118
|
utmVal?: string;
|
|
@@ -23,6 +23,7 @@ exports.DEFAULT_TAG = 'FOR U';
|
|
|
23
23
|
const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, consentHeight, consentWidth, isOpenConsent = false, isEditor = false, utmParameter, channelQueryList, data, dataList, isDiyH5, onUpdateSchema, onUpdateChannel }) => {
|
|
24
24
|
var _a, _b, _c, _d, _e;
|
|
25
25
|
const [rtcList, setRtcList] = (0, react_1.useState)([]);
|
|
26
|
+
const [firstRtcList, setFirstRtcList] = (0, react_1.useState)([]);
|
|
26
27
|
const [tagList, setTagList] = (0, react_1.useState)([]);
|
|
27
28
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
28
29
|
const [curReqInfo, setCurReqInfo] = (0, react_1.useState)({ rtc: '', requestId: '' });
|
|
@@ -53,6 +54,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
53
54
|
const [chatlabsId, setChatlabsId] = (0, react_1.useState)();
|
|
54
55
|
const finalPageData = (0, react_1.useMemo)(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
|
|
55
56
|
const pixelPvStatusRef = (0, react_1.useRef)(false);
|
|
57
|
+
const isDiyPage = (0, react_1.useMemo)(() => {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
return isDiyH5 && !((_c = (_b = (_a = finalPageData === null || finalPageData === void 0 ? void 0 : finalPageData.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf) === null || _b === void 0 ? void 0 : _b.globalConfig) === null || _c === void 0 ? void 0 : _c.enablePreview);
|
|
60
|
+
}, [isDiyH5, finalPageData]);
|
|
56
61
|
(0, react_1.useEffect)(() => {
|
|
57
62
|
var _a, _b;
|
|
58
63
|
setGlobalConfig((_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf) === null || _b === void 0 ? void 0 : _b.globalConfig);
|
|
@@ -147,7 +152,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
147
152
|
return false;
|
|
148
153
|
};
|
|
149
154
|
const bffFetch = (0, react_1.useCallback)((path, options, isBota = true) => {
|
|
150
|
-
var _a;
|
|
155
|
+
var _a, _b;
|
|
151
156
|
if (!bffDataSource)
|
|
152
157
|
return;
|
|
153
158
|
const url = bffDataSource.url;
|
|
@@ -162,8 +167,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
162
167
|
const value = val.split('=')[1];
|
|
163
168
|
params[key] = value;
|
|
164
169
|
});
|
|
170
|
+
options.body = Object.assign(Object.assign({}, options.body), { productUserId: fakeUserId });
|
|
165
171
|
return window
|
|
166
|
-
.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' && isBota
|
|
172
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId, 'tenant-id': (_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id'] }, bffDataSource.headers), method: options.method, body: options.type === 'beacon' && isBota
|
|
167
173
|
? JSON.stringify({
|
|
168
174
|
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
|
169
175
|
})
|
|
@@ -421,8 +427,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
421
427
|
.catch((err) => Promise.reject(err));
|
|
422
428
|
}, [bffDataSource]);
|
|
423
429
|
const getRecommendVideos = (0, react_1.useCallback)((query) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
424
|
-
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
425
|
-
query = Object.assign(Object.assign({ maxSize: (_f = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _f !== void 0 ? _f : maxSize, defaultSize: (_g = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _g !== void 0 ? _g : defaultSize, hashTag: query === null || query === void 0 ? void 0 : query.hashTag, traceInfo: query === null || query === void 0 ? void 0 : query.traceInfo, themeTag: query === null || query === void 0 ? void 0 : query.themeTag, pageNum: query === null || query === void 0 ? void 0 : query.pageNum, contentFilter: query === null || query === void 0 ? void 0 : query.contentFilter, productFilter: query === null || query === void 0 ? void 0 : query.productFilter }, (chatlabsId && { chatlabsId })), (
|
|
430
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
431
|
+
query = Object.assign(Object.assign({ maxSize: (_f = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _f !== void 0 ? _f : maxSize, defaultSize: (_g = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _g !== void 0 ? _g : defaultSize, hashTag: query === null || query === void 0 ? void 0 : query.hashTag, traceInfo: query === null || query === void 0 ? void 0 : query.traceInfo, themeTag: query === null || query === void 0 ? void 0 : query.themeTag, pageNum: query === null || query === void 0 ? void 0 : query.pageNum, contentFilter: query === null || query === void 0 ? void 0 : query.contentFilter, productFilter: query === null || query === void 0 ? void 0 : query.productFilter }, (chatlabsId && { chatlabsId })), (isDiyPage && { type: 'story' }));
|
|
426
432
|
if (channel) {
|
|
427
433
|
query = Object.assign(Object.assign({}, query), { channel: decodeURIComponent(channel) });
|
|
428
434
|
}
|
|
@@ -435,9 +441,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
435
441
|
if (val)
|
|
436
442
|
query = Object.assign(Object.assign({}, query), { channel: decodeURIComponent(val) });
|
|
437
443
|
}
|
|
444
|
+
const isDiy = isDiyH5 && ((_o = (_m = (_l = finalPageData === null || finalPageData === void 0 ? void 0 : finalPageData.data) === null || _l === void 0 ? void 0 : _l.sxpPageConf) === null || _m === void 0 ? void 0 : _m.globalConfig) === null || _o === void 0 ? void 0 : _o.enablePreview);
|
|
438
445
|
if (isEditor) {
|
|
439
446
|
let pageNum = 1;
|
|
440
|
-
query = Object.assign(Object.assign(Object.assign({}, query), { directPage: true, level: 1 }), (!utmVal && channelQueryList && (channelQueryList === null || channelQueryList === void 0 ? void 0 : channelQueryList.length) > 0 && { channel: channelQueryList === null || channelQueryList === void 0 ? void 0 : channelQueryList[0] }));
|
|
447
|
+
query = Object.assign(Object.assign(Object.assign(Object.assign({}, query), { directPage: true, level: 1 }), (!utmVal && channelQueryList && (channelQueryList === null || channelQueryList === void 0 ? void 0 : channelQueryList.length) > 0 && { channel: channelQueryList === null || channelQueryList === void 0 ? void 0 : channelQueryList[0] })), (isDiy && { maxRecs: query === null || query === void 0 ? void 0 : query.maxSize }));
|
|
441
448
|
if (!(query === null || query === void 0 ? void 0 : query.channel) || isInit.current) {
|
|
442
449
|
return undefined;
|
|
443
450
|
}
|
|
@@ -445,19 +452,24 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
445
452
|
let list = [];
|
|
446
453
|
let result = null;
|
|
447
454
|
const recurveRecList = (query) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
448
|
-
var
|
|
455
|
+
var _y, _z, _0, _1, _2, _3;
|
|
449
456
|
query.pageNum = pageNum;
|
|
450
|
-
result =
|
|
457
|
+
result = isDiyH5
|
|
458
|
+
? yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v3/recommend/direct/page/view', { method: 'POST', body: query }))
|
|
459
|
+
: yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('recommend/direct_page', { method: 'POST', body: query }));
|
|
451
460
|
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
|
452
461
|
return undefined;
|
|
453
462
|
}
|
|
454
463
|
setLoading(false);
|
|
455
|
-
list = list.concat((
|
|
464
|
+
list = list.concat((_1 = (_0 = (_z = (_y = result === null || result === void 0 ? void 0 : result.data) === null || _y === void 0 ? void 0 : _y.recList) === null || _z === void 0 ? void 0 : _z.filter) === null || _0 === void 0 ? void 0 : _0.call(_z, (item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video))) !== null && _1 !== void 0 ? _1 : []);
|
|
456
465
|
if ((rtcList === null || rtcList === void 0 ? void 0 : rtcList.length) === 0) {
|
|
457
466
|
setRtcList(getFilterRecList(Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list })));
|
|
458
467
|
setCacheRtcList(getFilterRecList(Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list })));
|
|
468
|
+
if (isDiyPage) {
|
|
469
|
+
setFirstRtcList(getFilterRecList(Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list })));
|
|
470
|
+
}
|
|
459
471
|
}
|
|
460
|
-
const isNotNullList = (
|
|
472
|
+
const isNotNullList = (_3 = (_2 = result === null || result === void 0 ? void 0 : result.data) === null || _2 === void 0 ? void 0 : _2.recList) === null || _3 === void 0 ? void 0 : _3.some((item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video));
|
|
461
473
|
if (isNotNullList) {
|
|
462
474
|
pageNum = pageNum + 1;
|
|
463
475
|
yield recurveRecList(query);
|
|
@@ -465,42 +477,61 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
465
477
|
});
|
|
466
478
|
yield recurveRecList(query);
|
|
467
479
|
if (!(query === null || query === void 0 ? void 0 : query.hashTag) && result)
|
|
468
|
-
setCurReqInfo({ rtc: (
|
|
480
|
+
setCurReqInfo({ rtc: (_p = result === null || result === void 0 ? void 0 : result.data) === null || _p === void 0 ? void 0 : _p.rtc, requestId: (_q = result === null || result === void 0 ? void 0 : result.data) === null || _q === void 0 ? void 0 : _q.requestId });
|
|
469
481
|
return Object.assign(Object.assign({}, result === null || result === void 0 ? void 0 : result.data), { recList: list });
|
|
470
482
|
}
|
|
471
483
|
if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
|
|
472
|
-
query = Object.assign(Object.assign({}, query), { directPage: true, level: 1, pageNum: (
|
|
484
|
+
query = Object.assign(Object.assign(Object.assign({}, query), { directPage: true, level: 1, pageNum: (_r = query === null || query === void 0 ? void 0 : query.pageNum) !== null && _r !== void 0 ? _r : 1 }), (isDiy && { maxRecs: query === null || query === void 0 ? void 0 : query.maxSize }));
|
|
473
485
|
}
|
|
474
|
-
const result =
|
|
475
|
-
method: 'POST',
|
|
476
|
-
|
|
477
|
-
|
|
486
|
+
const result = isDiy
|
|
487
|
+
? yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v3/recommend/direct/page/view', { method: 'POST', body: query }))
|
|
488
|
+
: yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', {
|
|
489
|
+
method: 'POST',
|
|
490
|
+
body: query
|
|
491
|
+
}));
|
|
478
492
|
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
|
479
493
|
return undefined;
|
|
480
494
|
}
|
|
481
495
|
if (!(query === null || query === void 0 ? void 0 : query.hashTag))
|
|
482
496
|
setCurReqInfo({ rtc: result.data.rtc, requestId: result.data.requestId });
|
|
483
497
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) && !isEditor) {
|
|
484
|
-
const isNotNullList = (
|
|
498
|
+
const isNotNullList = (_t = (_s = result === null || result === void 0 ? void 0 : result.data) === null || _s === void 0 ? void 0 : _s.recList) === null || _t === void 0 ? void 0 : _t.some((item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video));
|
|
485
499
|
if (!isNotNullList) {
|
|
486
500
|
setIsNoMoreData(true);
|
|
487
501
|
}
|
|
488
502
|
}
|
|
489
503
|
let list = [];
|
|
490
|
-
list = list.concat((
|
|
504
|
+
list = list.concat((_x = (_w = (_v = (_u = result === null || result === void 0 ? void 0 : result.data) === null || _u === void 0 ? void 0 : _u.recList) === null || _v === void 0 ? void 0 : _v.filter) === null || _w === void 0 ? void 0 : _w.call(_v, (item) => (item === null || item === void 0 ? void 0 : item.product) || (item === null || item === void 0 ? void 0 : item.video))) !== null && _x !== void 0 ? _x : []);
|
|
491
505
|
return Object.assign(Object.assign({}, result.data), { recList: list });
|
|
492
|
-
}), [
|
|
506
|
+
}), [
|
|
507
|
+
bffFetch,
|
|
508
|
+
utmVal,
|
|
509
|
+
maxSize,
|
|
510
|
+
defaultSize,
|
|
511
|
+
channelQueryList,
|
|
512
|
+
channel,
|
|
513
|
+
chatlabsId,
|
|
514
|
+
bffFetchAdmin,
|
|
515
|
+
isDiyPage,
|
|
516
|
+
finalPageData,
|
|
517
|
+
isDiyH5
|
|
518
|
+
]);
|
|
493
519
|
const loadVideos = (0, react_1.useCallback)((pageNum) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
494
|
-
var
|
|
520
|
+
var _4, _5, _6, _7;
|
|
495
521
|
if (rtcList.length <= 0) {
|
|
496
522
|
return;
|
|
497
523
|
}
|
|
524
|
+
if (isDiyPage && (firstRtcList === null || firstRtcList === void 0 ? void 0 : firstRtcList.length) > 0) {
|
|
525
|
+
setRtcList(rtcList.concat(firstRtcList));
|
|
526
|
+
setCacheRtcList(cacheRtcList.concat(firstRtcList));
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
498
529
|
const lastItem = rtcList === null || rtcList === void 0 ? void 0 : rtcList[(rtcList === null || rtcList === void 0 ? void 0 : rtcList.length) - 1];
|
|
499
|
-
const data = yield getRecommendVideos(Object.assign(Object.assign(Object.assign(Object.assign({ hashTag: waterFallData === null || waterFallData === void 0 ? void 0 : waterFallData.hashTag }, (((
|
|
530
|
+
const data = yield getRecommendVideos(Object.assign(Object.assign(Object.assign(Object.assign({ hashTag: waterFallData === null || waterFallData === void 0 ? void 0 : waterFallData.hashTag }, (((_4 = lastItem === null || lastItem === void 0 ? void 0 : lastItem.product) === null || _4 === void 0 ? void 0 : _4.itemId) && { productFilter: [(_5 = lastItem === null || lastItem === void 0 ? void 0 : lastItem.product) === null || _5 === void 0 ? void 0 : _5.itemId] })), (((_6 = lastItem === null || lastItem === void 0 ? void 0 : lastItem.video) === null || _6 === void 0 ? void 0 : _6.itemId) && { contentFilter: [(_7 = lastItem === null || lastItem === void 0 ? void 0 : lastItem.video) === null || _7 === void 0 ? void 0 : _7.itemId] })), { themeTag: themeTag.current }), ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) && !isEditor && { pageNum })));
|
|
500
531
|
setRtcList(rtcList.concat(getFilterRecList(data)));
|
|
501
532
|
setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
|
|
502
533
|
return data;
|
|
503
|
-
}), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
|
|
534
|
+
}), [getRecommendVideos, rtcList, waterFallData, cacheRtcList, isDiyPage, firstRtcList]);
|
|
504
535
|
const refreshFeSession = (0, react_1.useCallback)((enableReSid, event) => {
|
|
505
536
|
var _a, _b, _c, _d, _e;
|
|
506
537
|
let expire = false;
|
|
@@ -528,7 +559,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
528
559
|
return;
|
|
529
560
|
}
|
|
530
561
|
if (!userInfo) {
|
|
531
|
-
userInfo = {
|
|
562
|
+
userInfo = {
|
|
563
|
+
productUserId: fakeUserId
|
|
564
|
+
};
|
|
532
565
|
}
|
|
533
566
|
const sessionID = (0, sessionStore_1.storeAndLoadFeSessionId)();
|
|
534
567
|
const params = {};
|
|
@@ -561,7 +594,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
561
594
|
layoutVariantId,
|
|
562
595
|
globalConfig,
|
|
563
596
|
playbookType,
|
|
564
|
-
bffDataSource
|
|
597
|
+
bffDataSource,
|
|
598
|
+
fakeUserId
|
|
565
599
|
]);
|
|
566
600
|
const getEventParamsByJson = (0, react_1.useCallback)((_a) => {
|
|
567
601
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
@@ -741,37 +775,39 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
741
775
|
}
|
|
742
776
|
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
|
|
743
777
|
const bffMutateLike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
778
|
+
body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
|
|
744
779
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
|
|
745
780
|
return res === null || res === void 0 ? void 0 : res.success;
|
|
746
|
-
}), [bffFetch]);
|
|
781
|
+
}), [bffFetch, fakeUserId]);
|
|
747
782
|
const bffMutateUnlike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
783
|
+
body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
|
|
748
784
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
|
|
749
785
|
return res === null || res === void 0 ? void 0 : res.success;
|
|
750
|
-
}), [bffFetch]);
|
|
786
|
+
}), [bffFetch, fakeUserId]);
|
|
751
787
|
const bffSubmitForm = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
752
788
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
|
|
753
789
|
return res === null || res === void 0 ? void 0 : res.success;
|
|
754
790
|
}), [bffFetch]);
|
|
755
791
|
const bffGetTagList = (0, react_1.useCallback)((data) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
756
|
-
var
|
|
757
|
-
const isShowTag = !!((
|
|
792
|
+
var _8, _9, _10, _11, _12, _13, _14, _15;
|
|
793
|
+
const isShowTag = !!((_10 = (_9 = (_8 = data === null || data === void 0 ? void 0 : data.data) === null || _8 === void 0 ? void 0 : _8.sxpPageConf) === null || _9 === void 0 ? void 0 : _9.globalConfig) === null || _10 === void 0 ? void 0 : _10.isShowTag);
|
|
758
794
|
if (!utmVal || !isShowTag)
|
|
759
795
|
return;
|
|
760
796
|
try {
|
|
761
|
-
const val = (
|
|
797
|
+
const val = (_13 = (_12 = (_11 = (0, tool_1.splitUrlParams)(utmVal)) === null || _11 === void 0 ? void 0 : _11.filter((val) => {
|
|
762
798
|
var _a, _b;
|
|
763
799
|
const key = val.split('=')[0];
|
|
764
800
|
return (_b = ((_a = utmParameter === null || utmParameter === void 0 ? void 0 : utmParameter.channels) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.includes(key);
|
|
765
|
-
})) === null ||
|
|
801
|
+
})) === null || _12 === void 0 ? void 0 : _12.join('&')) !== null && _13 !== void 0 ? _13 : '';
|
|
766
802
|
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
|
|
767
|
-
setTagList((
|
|
803
|
+
setTagList((_15 = (_14 = result === null || result === void 0 ? void 0 : result.data) === null || _14 === void 0 ? void 0 : _14.tags) !== null && _15 !== void 0 ? _15 : []);
|
|
768
804
|
}
|
|
769
805
|
catch (e) {
|
|
770
806
|
console.log('e', e);
|
|
771
807
|
}
|
|
772
808
|
}), [bffFetch, utmVal]);
|
|
773
809
|
const ctaEvent = (0, react_1.useCallback)((eventInfo, rec, product, position, ctaActionType, targetUrl, contentType) => {
|
|
774
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
|
810
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
|
775
811
|
const cta = product === null || product === void 0 ? void 0 : product.bindCta;
|
|
776
812
|
const isProd = ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.bindProduct) || (((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.bindProducts) && ((_d = (_c = rec === null || rec === void 0 ? void 0 : rec.video) === null || _c === void 0 ? void 0 : _c.bindProducts) === null || _d === void 0 ? void 0 : _d.length) > 0);
|
|
777
813
|
let fromKName = '';
|
|
@@ -789,7 +825,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
789
825
|
}
|
|
790
826
|
const contentTags = (_p = (_m = (_h = product === null || product === void 0 ? void 0 : product.tags) !== null && _h !== void 0 ? _h : (_l = (_k = (_j = rec === null || rec === void 0 ? void 0 : rec.video) === null || _j === void 0 ? void 0 : _j.bindProducts) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : (_o = rec === null || rec === void 0 ? void 0 : rec.video) === null || _o === void 0 ? void 0 : _o.tags) !== null && _p !== void 0 ? _p : (_q = rec === null || rec === void 0 ? void 0 : rec.product) === null || _q === void 0 ? void 0 : _q.tags;
|
|
791
827
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
|
792
|
-
eventInfo: Object.assign(Object.assign({}, eventInfo), { ctaId: (_r = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _r !== void 0 ? _r : '', ctaName: (_s = cta === null || cta === void 0 ? void 0 : cta.title) !== null && _s !== void 0 ? _s : '', contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_u = (_t = rec === null || rec === void 0 ? void 0 : rec.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '', productId: isProd ? product === null || product === void 0 ? void 0 : product.itemId : '', traceInfo: (
|
|
828
|
+
eventInfo: Object.assign(Object.assign({}, eventInfo), { ctaId: (_r = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _r !== void 0 ? _r : '', ctaName: (_s = cta === null || cta === void 0 ? void 0 : cta.title) !== null && _s !== void 0 ? _s : '', contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_u = (_t = rec === null || rec === void 0 ? void 0 : rec.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '', sceneId: (_x = (_w = (_v = rec === null || rec === void 0 ? void 0 : rec.video) === null || _v === void 0 ? void 0 : _v.scene) === null || _w === void 0 ? void 0 : _w.sceneId) !== null && _x !== void 0 ? _x : '', productId: isProd ? product === null || product === void 0 ? void 0 : product.itemId : '', traceInfo: (_13 = (_10 = (_5 = (_1 = (_y = cta === null || cta === void 0 ? void 0 : cta.traceInfo) !== null && _y !== void 0 ? _y : (_0 = (_z = rec === null || rec === void 0 ? void 0 : rec.video) === null || _z === void 0 ? void 0 : _z.bindCta) === null || _0 === void 0 ? void 0 : _0.traceInfo) !== null && _1 !== void 0 ? _1 : (_4 = (_3 = (_2 = rec === null || rec === void 0 ? void 0 : rec.video) === null || _2 === void 0 ? void 0 : _2.bindProduct) === null || _3 === void 0 ? void 0 : _3.bindCta) === null || _4 === void 0 ? void 0 : _4.traceInfo) !== null && _5 !== void 0 ? _5 : (_9 = (_8 = (_7 = (_6 = rec === null || rec === void 0 ? void 0 : rec.video) === null || _6 === void 0 ? void 0 : _6.bindProducts) === null || _7 === void 0 ? void 0 : _7[0]) === null || _8 === void 0 ? void 0 : _8.bindCta) === null || _9 === void 0 ? void 0 : _9.traceInfo) !== null && _10 !== void 0 ? _10 : (_12 = (_11 = rec === null || rec === void 0 ? void 0 : rec.product) === null || _11 === void 0 ? void 0 : _11.bindCta) === null || _12 === void 0 ? void 0 : _12.traceInfo) !== null && _13 !== void 0 ? _13 : '', fromKName, fromKPage: (_14 = location === null || location === void 0 ? void 0 : location.href) !== null && _14 !== void 0 ? _14 : '', contentFormat })
|
|
793
829
|
});
|
|
794
830
|
}, [bffEventReport, isFromHashtag]);
|
|
795
831
|
const h5EnterLink = (0, react_1.useCallback)(() => {
|
|
@@ -813,10 +849,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
813
849
|
});
|
|
814
850
|
}, [bffEventReport]);
|
|
815
851
|
const getAccount = (0, react_1.useCallback)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
816
|
-
var
|
|
852
|
+
var _16, _17;
|
|
817
853
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/account', { method: 'GET' }));
|
|
818
|
-
setChatlabsId((
|
|
819
|
-
return ((
|
|
854
|
+
setChatlabsId((_16 = res === null || res === void 0 ? void 0 : res.data) === null || _16 === void 0 ? void 0 : _16.chatLabsId);
|
|
855
|
+
return ((_17 = res === null || res === void 0 ? void 0 : res.data) === null || _17 === void 0 ? void 0 : _17.consentResult) === 'true';
|
|
820
856
|
}), [bffFetch]);
|
|
821
857
|
const accountSonsent = (0, react_1.useCallback)((consentResult) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
822
858
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/account/consent', {
|
|
@@ -880,6 +916,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
880
916
|
}
|
|
881
917
|
setRtcList(list);
|
|
882
918
|
setCacheRtcList(list);
|
|
919
|
+
if (isDiyPage) {
|
|
920
|
+
setFirstRtcList(list);
|
|
921
|
+
}
|
|
883
922
|
bffGetTagList(curData !== null && curData !== void 0 ? curData : finalPageData);
|
|
884
923
|
if (channel) {
|
|
885
924
|
const item = list === null || list === void 0 ? void 0 : list[0];
|
|
@@ -899,7 +938,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
899
938
|
});
|
|
900
939
|
setLoading(false);
|
|
901
940
|
});
|
|
902
|
-
}, [isShowConsent, channel]);
|
|
941
|
+
}, [isShowConsent, channel, isDiyPage]);
|
|
903
942
|
(0, react_1.useEffect)(() => {
|
|
904
943
|
if (!isPreview)
|
|
905
944
|
return;
|
|
@@ -914,12 +953,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
914
953
|
}
|
|
915
954
|
setRtcList(list);
|
|
916
955
|
setCacheRtcList(list);
|
|
956
|
+
if (isDiyPage) {
|
|
957
|
+
setFirstRtcList(list);
|
|
958
|
+
}
|
|
917
959
|
}
|
|
918
960
|
})
|
|
919
961
|
.finally(() => {
|
|
920
962
|
setLoading(false);
|
|
921
963
|
});
|
|
922
|
-
}, [getRecommendVideos, bffGetTagList, channel]);
|
|
964
|
+
}, [getRecommendVideos, bffGetTagList, channel, isDiyPage]);
|
|
923
965
|
const defaultLoadingImage = (0, useIconLink_1.useIconLink)('/pb_static/a65d23c5893c49d7aaaa81681d3179e2.gif', appDomain);
|
|
924
966
|
return (react_1.default.createElement(exports.SxpDataSourceContext.Provider, { value: {
|
|
925
967
|
rtcList,
|
|
@@ -977,7 +1019,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
|
977
1019
|
refreshFeSession,
|
|
978
1020
|
getAccount,
|
|
979
1021
|
accountSonsent,
|
|
980
|
-
isDiyH5,
|
|
1022
|
+
isDiyH5: isDiyPage,
|
|
1023
|
+
firstRtcList,
|
|
981
1024
|
pixelPvStatusRef
|
|
982
1025
|
} }, isShowConsent ? (react_1.default.createElement(Consent_1.default, Object.assign({}, (_e = (_d = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.item) === null || _e === void 0 ? void 0 : _e.props))) : (render({
|
|
983
1026
|
rtcList,
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useEventReport = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const useSxpDataSource_1 = require("./useSxpDataSource");
|
|
6
5
|
const SxpDataSourceProvider_1 = require("../context/SxpDataSourceProvider");
|
|
6
|
+
const useSxpDataSource_1 = require("./useSxpDataSource");
|
|
7
7
|
function useEventReport() {
|
|
8
8
|
const { bffEventReport, popupDetailData, isFromHashtag, eventTimeList, setEventTimeList } = (0, useSxpDataSource_1.useSxpDataSource)();
|
|
9
9
|
const jumpToWeb = (0, react_1.useCallback)((e, data, product, cta, position, traceInfo) => {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
|
|
11
11
|
const i = eventTimeList === null || eventTimeList === void 0 ? void 0 : eventTimeList.findIndex((item) => item.target === (e === null || e === void 0 ? void 0 : e.target));
|
|
12
12
|
if (i !== -1) {
|
|
13
13
|
return;
|
|
@@ -40,11 +40,11 @@ function useEventReport() {
|
|
|
40
40
|
contentFormat = 'image';
|
|
41
41
|
}
|
|
42
42
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
|
43
|
-
eventInfo: Object.assign({ eventSubject: 'jumpToWeb', eventDescription: 'User jumped to website', productId: (_v = product === null || product === void 0 ? void 0 : product.itemId) !== null && _v !== void 0 ? _v : '', productName: (_w = product === null || product === void 0 ? void 0 : product.title) !== null && _w !== void 0 ? _w : '', price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0', productCollection: (_x = product === null || product === void 0 ? void 0 : product.collection) !== null && _x !== void 0 ? _x : '', fromKName, fromKPage: location === null || location === void 0 ? void 0 : location.href, contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_z = (_y = data === null || data === void 0 ? void 0 : data.video) === null || _y === void 0 ? void 0 : _y.itemId) !== null && _z !== void 0 ? _z : '',
|
|
43
|
+
eventInfo: Object.assign({ eventSubject: 'jumpToWeb', eventDescription: 'User jumped to website', productId: (_v = product === null || product === void 0 ? void 0 : product.itemId) !== null && _v !== void 0 ? _v : '', productName: (_w = product === null || product === void 0 ? void 0 : product.title) !== null && _w !== void 0 ? _w : '', price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0', productCollection: (_x = product === null || product === void 0 ? void 0 : product.collection) !== null && _x !== void 0 ? _x : '', fromKName, fromKPage: location === null || location === void 0 ? void 0 : location.href, contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_z = (_y = data === null || data === void 0 ? void 0 : data.video) === null || _y === void 0 ? void 0 : _y.itemId) !== null && _z !== void 0 ? _z : '', sceneId: (_2 = (_1 = (_0 = data === null || data === void 0 ? void 0 : data.video) === null || _0 === void 0 ? void 0 : _0.scene) === null || _1 === void 0 ? void 0 : _1.sceneId) !== null && _2 !== void 0 ? _2 : '', ctatId: (_3 = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _3 !== void 0 ? _3 : '', traceInfo: (_16 = (_13 = (_11 = (_7 = (_4 = traceInfo !== null && traceInfo !== void 0 ? traceInfo : product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _4 !== void 0 ? _4 : (_6 = (_5 = data === null || data === void 0 ? void 0 : data.video) === null || _5 === void 0 ? void 0 : _5.bindProduct) === null || _6 === void 0 ? void 0 : _6.traceInfo) !== null && _7 !== void 0 ? _7 : (_10 = (_9 = (_8 = data === null || data === void 0 ? void 0 : data.video) === null || _8 === void 0 ? void 0 : _8.bindProducts) === null || _9 === void 0 ? void 0 : _9[0]) === null || _10 === void 0 ? void 0 : _10.traceInfo) !== null && _11 !== void 0 ? _11 : (_12 = data === null || data === void 0 ? void 0 : data.product) === null || _12 === void 0 ? void 0 : _12.traceInfo) !== null && _13 !== void 0 ? _13 : (_15 = (_14 = data === null || data === void 0 ? void 0 : data.video) === null || _14 === void 0 ? void 0 : _14.bindCta) === null || _15 === void 0 ? void 0 : _15.traceInfo) !== null && _16 !== void 0 ? _16 : '' }, (contentFormat && { contentFormat }))
|
|
44
44
|
});
|
|
45
45
|
}, [bffEventReport, popupDetailData, isFromHashtag, eventTimeList]);
|
|
46
46
|
const productView = (0, react_1.useCallback)((data, product, cta, viewTime, position) => {
|
|
47
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
48
48
|
let fromKName = '';
|
|
49
49
|
if (popupDetailData && (((_b = (_a = data === null || data === void 0 ? void 0 : data.video) === null || _a === void 0 ? void 0 : _a.bindProducts) === null || _b === void 0 ? void 0 : _b.length) || ((_c = data === null || data === void 0 ? void 0 : data.video) === null || _c === void 0 ? void 0 : _c.bindProduct))) {
|
|
50
50
|
fromKName = 'pdpPage';
|
|
@@ -63,8 +63,9 @@ function useEventReport() {
|
|
|
63
63
|
contentTags: JSON.stringify(product === null || product === void 0 ? void 0 : product.tags),
|
|
64
64
|
position: position + '',
|
|
65
65
|
contentId: (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.itemId,
|
|
66
|
+
sceneId: (_g = (_f = (_e = data === null || data === void 0 ? void 0 : data.video) === null || _e === void 0 ? void 0 : _e.scene) === null || _f === void 0 ? void 0 : _f.sceneId) !== null && _g !== void 0 ? _g : '',
|
|
66
67
|
ctatId: cta === null || cta === void 0 ? void 0 : cta.itemId,
|
|
67
|
-
traceInfo: (
|
|
68
|
+
traceInfo: (_s = (_q = (_l = (_h = product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _h !== void 0 ? _h : (_k = (_j = data === null || data === void 0 ? void 0 : data.video) === null || _j === void 0 ? void 0 : _j.bindProduct) === null || _k === void 0 ? void 0 : _k.traceInfo) !== null && _l !== void 0 ? _l : (_p = (_o = (_m = data === null || data === void 0 ? void 0 : data.video) === null || _m === void 0 ? void 0 : _m.bindProducts) === null || _o === void 0 ? void 0 : _o[0]) === null || _p === void 0 ? void 0 : _p.traceInfo) !== null && _q !== void 0 ? _q : (_r = data === null || data === void 0 ? void 0 : data.product) === null || _r === void 0 ? void 0 : _r.traceInfo) !== null && _s !== void 0 ? _s : '',
|
|
68
69
|
timeOnSite: Math.floor((new Date() - viewTime) / 1000) + '',
|
|
69
70
|
eventSubject: 'productView',
|
|
70
71
|
eventDescription: 'User browsed the product'
|