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/pb-ui.js CHANGED
@@ -930,6 +930,30 @@
930
930
  navigatorWithBeacon.sendBeacon = originalSendBeacon;
931
931
  };
932
932
  }, [bffCollectEvent]);
933
+ React.useEffect(() => {
934
+ // 保存原始的 form.submit 方法
935
+ const originalFormSubmit = HTMLFormElement.prototype.submit;
936
+ // 重写 form.submit 方法
937
+ HTMLFormElement.prototype.submit = function () {
938
+ const form = this;
939
+ // 检查是否是 Facebook Pixel 请求
940
+ if (form.action.includes('facebook.com/tr')) {
941
+ // 收集所有表单数据
942
+ const formData = new FormData(form);
943
+ const params = {};
944
+ for (const [key, value] of formData.entries()) {
945
+ params[key] = value;
946
+ }
947
+ bffCollectEvent({
948
+ eventName: params === null || params === void 0 ? void 0 : params.ev,
949
+ eventSource: 'Meta Pixel'
950
+ });
951
+ return originalFormSubmit.call(form);
952
+ }
953
+ // 非 Facebook 请求,正常提交
954
+ return originalFormSubmit.call(form);
955
+ };
956
+ }, []);
933
957
  React.useEffect(() => {
934
958
  const _originalFetch = window.fetch;
935
959
  // 覆盖 fetch 方法
@@ -10931,8 +10955,8 @@
10931
10955
  contentType: 'product',
10932
10956
  view_time: new Date() - curTimeRef.current
10933
10957
  });
10934
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, () => onShow());
10935
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, () => onHide());
10958
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW);
10959
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE);
10936
10960
  };
10937
10961
  }, [isActive, isPost, bffFbReport, data, product, position, curTimeRef]);
10938
10962
  React.useEffect(() => {
@@ -11894,8 +11918,8 @@
11894
11918
  contentType: 'product',
11895
11919
  view_time: new Date() - curTimeRef.current
11896
11920
  });
11897
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, () => onShow());
11898
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, () => onHide());
11921
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW);
11922
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE);
11899
11923
  };
11900
11924
  }, [isActive, isPost, bffFbReport, data, product, position, curTimeRef]);
11901
11925
  React.useEffect(() => {