pb-sxp-ui 1.20.4 → 1.20.5

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.js CHANGED
@@ -915,6 +915,30 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
915
915
  navigatorWithBeacon.sendBeacon = originalSendBeacon;
916
916
  };
917
917
  }, [bffCollectEvent]);
918
+ useEffect(() => {
919
+ // 保存原始的 form.submit 方法
920
+ const originalFormSubmit = HTMLFormElement.prototype.submit;
921
+ // 重写 form.submit 方法
922
+ HTMLFormElement.prototype.submit = function () {
923
+ const form = this;
924
+ // 检查是否是 Facebook Pixel 请求
925
+ if (form.action.includes('facebook.com/tr')) {
926
+ // 收集所有表单数据
927
+ const formData = new FormData(form);
928
+ const params = {};
929
+ for (const [key, value] of formData.entries()) {
930
+ params[key] = value;
931
+ }
932
+ bffCollectEvent({
933
+ eventName: params === null || params === void 0 ? void 0 : params.ev,
934
+ eventSource: 'Meta Pixel'
935
+ });
936
+ return originalFormSubmit.call(form);
937
+ }
938
+ // 非 Facebook 请求,正常提交
939
+ return originalFormSubmit.call(form);
940
+ };
941
+ }, []);
918
942
  useEffect(() => {
919
943
  const _originalFetch = window.fetch;
920
944
  // 覆盖 fetch 方法
@@ -10916,8 +10940,8 @@ const CommodityDetail$1 = (_a) => {
10916
10940
  contentType: 'product',
10917
10941
  view_time: new Date() - curTimeRef.current
10918
10942
  });
10919
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, () => onShow());
10920
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, () => onHide());
10943
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW);
10944
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE);
10921
10945
  };
10922
10946
  }, [isActive, isPost, bffFbReport, data, product, position, curTimeRef]);
10923
10947
  useEffect(() => {
@@ -11879,8 +11903,8 @@ const CommodityDetailDiroNew$1 = (_a) => {
11879
11903
  contentType: 'product',
11880
11904
  view_time: new Date() - curTimeRef.current
11881
11905
  });
11882
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, () => onShow());
11883
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, () => onHide());
11906
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW);
11907
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE);
11884
11908
  };
11885
11909
  }, [isActive, isPost, bffFbReport, data, product, position, curTimeRef]);
11886
11910
  useEffect(() => {