pb-sxp-ui 1.6.6 → 1.7.0

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.
Files changed (33) hide show
  1. package/dist/index.cjs +93 -33
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +93 -33
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +3 -3
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +3 -3
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +93 -33
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +3 -3
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/SxpPageRender/VideoWidget/index.js +8 -5
  14. package/es/core/components/SxpPageRender/WaterFall/index.js +6 -1
  15. package/es/core/components/SxpPageRender/index.d.ts +1 -0
  16. package/es/core/components/SxpPageRender/index.js +7 -11
  17. package/es/core/context/SxpDataSourceProvider.d.ts +2 -4
  18. package/es/core/context/SxpDataSourceProvider.js +52 -11
  19. package/es/materials/sxp/popup/CommodityDetail/index.js +6 -1
  20. package/es/materials/sxp/popup/CommodityDetailDiro/index.js +6 -1
  21. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +6 -1
  22. package/es/materials/sxp/popup/CommodityList/index.js +7 -2
  23. package/lib/core/components/SxpPageRender/VideoWidget/index.js +8 -5
  24. package/lib/core/components/SxpPageRender/WaterFall/index.js +6 -1
  25. package/lib/core/components/SxpPageRender/index.d.ts +1 -0
  26. package/lib/core/components/SxpPageRender/index.js +7 -11
  27. package/lib/core/context/SxpDataSourceProvider.d.ts +2 -4
  28. package/lib/core/context/SxpDataSourceProvider.js +52 -11
  29. package/lib/materials/sxp/popup/CommodityDetail/index.js +6 -1
  30. package/lib/materials/sxp/popup/CommodityDetailDiro/index.js +6 -1
  31. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +6 -1
  32. package/lib/materials/sxp/popup/CommodityList/index.js +6 -1
  33. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -797,23 +797,64 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
797
797
  type: 'beacon'
798
798
  });
799
799
  }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
800
- const bffFbReport = useCallback((_a) => {
801
- var _b, _c, _d;
802
- var { eventName, actionSource = 'website', eventSourceUrl = (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href, externalId } = _a;
800
+ const bffFbReport = useCallback(({ eventName, product }) => {
801
+ var _a, _b, _c, _d;
803
802
  if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
804
803
  return;
805
804
  }
806
- const fakeUserId = storeAndLoadFeUserId();
805
+ let jsonParams = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName];
807
806
  const urlParams = new URLSearchParams(window.location.search);
808
- const fbclid = urlParams.get('fbclid');
807
+ const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
808
+ const fix_par = {
809
+ event_source_url: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href,
810
+ external_id: storeAndLoadFeUserId(),
811
+ client_user_agent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '',
812
+ fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
813
+ fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
814
+ time: new Date().getTime()
815
+ };
816
+ const regex = /\{\{(.*?)\}\}/g;
817
+ const getEventParams = (obj) => {
818
+ if (!obj)
819
+ return;
820
+ if (obj instanceof Array) {
821
+ obj === null || obj === void 0 ? void 0 : obj.map((item) => getEventParams(item));
822
+ }
823
+ else {
824
+ for (const key in obj) {
825
+ if (obj.hasOwnProperty(key)) {
826
+ const value = obj === null || obj === void 0 ? void 0 : obj[key];
827
+ if (typeof value === 'object') {
828
+ getEventParams(value);
829
+ }
830
+ else if (typeof value === 'string') {
831
+ const matches = value === null || value === void 0 ? void 0 : value.match(regex);
832
+ if (matches) {
833
+ matches.forEach((match) => {
834
+ const prop = match.substring(2, match.length - 2);
835
+ try {
836
+ const replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
837
+ if (replaceValue) {
838
+ obj[key] = replaceValue;
839
+ }
840
+ else {
841
+ delete obj[key];
842
+ }
843
+ }
844
+ catch (error) {
845
+ console.error('An error occurred:', error === null || error === void 0 ? void 0 : error.message);
846
+ }
847
+ });
848
+ }
849
+ }
850
+ }
851
+ }
852
+ }
853
+ };
854
+ getEventParams(jsonParams);
809
855
  return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
810
856
  method: 'POST',
811
- body: {
812
- eventName,
813
- actionSource,
814
- eventSourceUrl,
815
- userData: Object.assign(Object.assign(Object.assign({ externalId: fakeUserId }, (fbclid && { fbc: `fb.2.${new Date().getTime()}.${fbclid}` })), (getCookie('_fbp') && { fbp: `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` })), { clientUserAgent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '' })
816
- },
857
+ body: jsonParams,
817
858
  type: 'beacon'
818
859
  });
819
860
  }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
@@ -9342,9 +9383,14 @@ const CommodityDetail$1 = (_a) => {
9342
9383
  useEffect(() => {
9343
9384
  if (!isPost) {
9344
9385
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
9345
- eventName: 'ProductView'
9386
+ eventName: 'ProductView',
9387
+ product
9346
9388
  });
9347
9389
  }
9390
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
9391
+ eventName: 'PageView',
9392
+ product
9393
+ });
9348
9394
  }, [isPost, bffFbReport]);
9349
9395
  useEffect(() => {
9350
9396
  const initTime = () => {
@@ -10223,7 +10269,12 @@ const CommodityDetailDiroNew$1 = (_a) => {
10223
10269
  useEffect(() => {
10224
10270
  if (!isPost) {
10225
10271
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
10226
- eventName: 'ProductView'
10272
+ eventName: 'ProductView',
10273
+ product
10274
+ });
10275
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
10276
+ eventName: 'PageView',
10277
+ product
10227
10278
  });
10228
10279
  }
10229
10280
  }, [isPost, bffFbReport]);
@@ -10848,7 +10899,7 @@ var Img$1 = memo(Img);
10848
10899
  const CommodityList$1 = (_a) => {
10849
10900
  var _b, _c, _d;
10850
10901
  var { style, isDefault, rec, viewTime, isPost, bottom_image, commodityStyles, buttonStyle, translateY = 0, commodityPicture, isExternalLink, onClick } = _a, props = __rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "commodityStyles", "buttonStyle", "translateY", "commodityPicture", "isExternalLink", "onClick"]);
10851
- const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig } = useSxpDataSource();
10902
+ const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig, bffFbReport } = useSxpDataSource();
10852
10903
  const { jumpToWeb } = useEventReport();
10853
10904
  const { popup } = useEditor();
10854
10905
  const recData = isPost ? rec : popupDetailData;
@@ -10878,6 +10929,11 @@ const CommodityList$1 = (_a) => {
10878
10929
  onClick === null || onClick === void 0 ? void 0 : onClick();
10879
10930
  }
10880
10931
  }, popup === null || popup === void 0 ? void 0 : popup.duration);
10932
+ useEffect(() => {
10933
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
10934
+ eventName: 'PageView'
10935
+ });
10936
+ }, []);
10881
10937
  return (React.createElement("div", { className: css(Object.assign(Object.assign({}, style), { display: 'flex', flexDirection: 'column', gap: '10px', padding: '0 20px', marginTop: '50px', boxSizing: 'border-box' })) }, product === null || product === void 0 ? void 0 : product.map((item, index) => {
10882
10938
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10883
10939
  return (React.createElement(React.Fragment, null, recData && !(item === null || item === void 0 ? void 0 : item.bindCta) ? null : (React.createElement("div", Object.assign({ key: index }, props, { className: css({
@@ -14395,17 +14451,22 @@ function WaterfallList(_a) {
14395
14451
  * @Author: binruan@chatlabs.com
14396
14452
  * @Date: 2024-01-10 10:58:24
14397
14453
  * @LastEditors: binruan@chatlabs.com
14398
- * @LastEditTime: 2024-10-11 13:43:22
14454
+ * @LastEditTime: 2024-10-18 18:59:47
14399
14455
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\WaterFall\index.tsx
14400
14456
  *
14401
14457
  */
14402
14458
  const WaterFall = (props) => {
14403
14459
  var _a;
14404
- const { waterFallData, setOpenHashtag, openHashtag, swiperRef, setWaterFallData, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, setCacheRtcList, setIsFromHashtag, isFromHashtag, bffEventReport, themeTag, selectTag } = useSxpDataSource();
14460
+ const { waterFallData, setOpenHashtag, openHashtag, swiperRef, setWaterFallData, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, setCacheRtcList, setIsFromHashtag, isFromHashtag, bffEventReport, themeTag, selectTag, bffFbReport } = useSxpDataSource();
14405
14461
  const { backMainFeed } = useEventReport();
14406
14462
  useRef(null);
14407
14463
  const modalEleRef = useRef(null);
14408
14464
  const [viewTime, setViewTime] = useState();
14465
+ useEffect(() => {
14466
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
14467
+ eventName: 'PageView'
14468
+ });
14469
+ }, []);
14409
14470
  useEffect(() => {
14410
14471
  const parentNode = document.getElementById('sxp-render');
14411
14472
  const node = document.getElementById('water-fall');
@@ -15780,17 +15841,18 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15780
15841
  };
15781
15842
  }, [isActive]);
15782
15843
  useEffect(() => {
15783
- var _a, _b;
15844
+ var _a, _b, _c, _d;
15784
15845
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
15785
15846
  return;
15786
15847
  if (isActive) {
15787
15848
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15788
- eventName: 'ViewContent'
15849
+ eventName: 'ViewContent',
15850
+ product: (_b = (_a = data === null || data === void 0 ? void 0 : data[index]) === null || _a === void 0 ? void 0 : _a.video) === null || _b === void 0 ? void 0 : _b.bindProduct
15789
15851
  });
15790
- (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
15852
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.play();
15791
15853
  }
15792
15854
  else {
15793
- (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.pause();
15855
+ (_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.pause();
15794
15856
  }
15795
15857
  }, [isActive, isLoadFinish, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
15796
15858
  /*
@@ -15812,9 +15874,11 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
15812
15874
  if (!isActive)
15813
15875
  return;
15814
15876
  const onShow = () => {
15877
+ var _a, _b;
15815
15878
  handleClickVideo('start')();
15816
15879
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
15817
- eventName: 'ViewContent'
15880
+ eventName: 'ViewContent',
15881
+ product: (_b = (_a = data === null || data === void 0 ? void 0 : data[index]) === null || _a === void 0 ? void 0 : _a.video) === null || _b === void 0 ? void 0 : _b.bindProduct
15818
15882
  });
15819
15883
  };
15820
15884
  const onHide = handleClickVideo('pause');
@@ -16301,7 +16365,7 @@ var Tagbar$1 = memo(Tagbar);
16301
16365
  * @Author: binruan@chatlabs.com
16302
16366
  * @Date: 2024-01-15 19:03:09
16303
16367
  * @LastEditors: binruan@chatlabs.com
16304
- * @LastEditTime: 2024-10-17 17:16:42
16368
+ * @LastEditTime: 2024-10-18 18:54:40
16305
16369
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
16306
16370
  *
16307
16371
  */
@@ -16331,9 +16395,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16331
16395
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
16332
16396
  const now = new Date();
16333
16397
  viewTime.current = now;
16334
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16335
- eventName: 'PageView'
16336
- });
16337
16398
  }
16338
16399
  }, [data === null || data === void 0 ? void 0 : data.length]);
16339
16400
  const handleH5EnterLink = useCallback(() => {
@@ -16342,11 +16403,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16342
16403
  if (data.length > 0) {
16343
16404
  const now = new Date();
16344
16405
  viewTime.current = now;
16345
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16346
- eventName: 'PageView'
16347
- });
16348
16406
  }
16349
- }, [data.length, bffFbReport, h5EnterLink]);
16407
+ }, [data.length, h5EnterLink]);
16350
16408
  useEffect(() => {
16351
16409
  var _a;
16352
16410
  if (!ctaType || (ctaType === null || ctaType === void 0 ? void 0 : ctaType.length) < 1)
@@ -16651,7 +16709,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16651
16709
  }
16652
16710
  };
16653
16711
  const handleScrollEvent = (swiper) => {
16654
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
16712
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
16655
16713
  const item = data[swiper.previousIndex];
16656
16714
  if (!item)
16657
16715
  return;
@@ -16698,7 +16756,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16698
16756
  const curItem = data[swiper.activeIndex];
16699
16757
  if (!((_r = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _r === void 0 ? void 0 : _r.url) && !((_s = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _s === void 0 ? void 0 : _s.imgUrls) && (curItem === null || curItem === void 0 ? void 0 : curItem.product)) {
16700
16758
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16701
- eventName: 'ProductView'
16759
+ eventName: 'ProductView',
16760
+ product: (_t = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _t === void 0 ? void 0 : _t.bindProduct
16702
16761
  });
16703
16762
  }
16704
16763
  viewTime.current = new Date();
@@ -16719,7 +16778,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16719
16778
  }
16720
16779
  }, [openHashtag, data, activeIndex]);
16721
16780
  const handleViewImageStartEvent = (activeIndex) => {
16722
- var _a, _b, _c, _d, _e, _f;
16781
+ var _a, _b, _c, _d, _e, _f, _g;
16723
16782
  const item = data[activeIndex];
16724
16783
  // 如果是图片集则上报事件
16725
16784
  if (!((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.url) && ((_b = item === null || item === void 0 ? void 0 : item.video) === null || _b === void 0 ? void 0 : _b.imgUrls)) {
@@ -16739,7 +16798,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
16739
16798
  }
16740
16799
  });
16741
16800
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
16742
- eventName: 'ViewContent'
16801
+ eventName: 'ViewContent',
16802
+ product: (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.bindProduct
16743
16803
  });
16744
16804
  }
16745
16805
  };