pb-sxp-ui 1.16.22 → 1.16.24-alpha.1

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
@@ -867,26 +867,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
867
867
  try {
868
868
  // 1. 先执行原始请求
869
869
  const response = _originalFetch.apply(this, arguments_1);
870
- if (url.includes('https://i.giesswein.com/nb-collector')) {
871
- if ((init === null || init === void 0 ? void 0 : init.method) === 'POST' && typeof (init === null || init === void 0 ? void 0 : init.body) === 'string') {
872
- try {
873
- const payload = JSON.parse(init.body);
874
- if (payload && Array.isArray(payload.data)) {
875
- payload.data.forEach((item) => {
876
- if (item && item.e) {
877
- bffCollectEvent({
878
- eventName: item.e,
879
- eventSource: 'Northbeam Pixel'
880
- });
881
- }
882
- });
883
- }
884
- }
885
- catch (e) {
886
- console.error('Failed to parse Northbeam event', e);
887
- }
888
- }
889
- }
890
870
  // 检查是否是 GA4 收集端点
891
871
  if (url.includes('https://www.google-analytics.com/g/collect')) {
892
872
  const urlObj = new URL(url);
@@ -929,6 +909,41 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
929
909
  });
930
910
  };
931
911
  }, [bffCollectEvent]);
912
+ useEffect(() => {
913
+ const originalOpen = XMLHttpRequest.prototype.open;
914
+ const originalSend = XMLHttpRequest.prototype.send;
915
+ XMLHttpRequest.prototype.open = function (method, url) {
916
+ this._url = url;
917
+ originalOpen.apply(this, arguments);
918
+ };
919
+ XMLHttpRequest.prototype.send = function (body) {
920
+ if (this._url && typeof this._url === 'string' && this._url.includes('https://i.giesswein.com/nb-collector')) {
921
+ if (body && typeof body === 'string') {
922
+ try {
923
+ const payload = JSON.parse(body);
924
+ if (payload && Array.isArray(payload.data)) {
925
+ payload.data.forEach((item) => {
926
+ if (item && item.e) {
927
+ bffCollectEvent({
928
+ eventName: item.e,
929
+ eventSource: 'Northbeam Pixel'
930
+ });
931
+ }
932
+ });
933
+ }
934
+ }
935
+ catch (e) {
936
+ console.error('Failed to parse Northbeam event from XHR', e);
937
+ }
938
+ }
939
+ }
940
+ originalSend.apply(this, arguments);
941
+ };
942
+ return () => {
943
+ XMLHttpRequest.prototype.open = originalOpen;
944
+ XMLHttpRequest.prototype.send = originalSend;
945
+ };
946
+ }, [bffCollectEvent]);
932
947
  useEffect(() => {
933
948
  if (typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
934
949
  window === null || window === void 0 ? void 0 : window.fbq('track', 'PageView');
@@ -1211,6 +1226,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1211
1226
  window === null || window === void 0 ? void 0 : window.snaptr('track', snapchatPixelEventParamsJson === null || snapchatPixelEventParamsJson === void 0 ? void 0 : snapchatPixelEventParamsJson.event_name, getEventParamsByJson(snapchatPixelEventParamsJson, product));
1212
1227
  }
1213
1228
  if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.Northbeam) === 'object' && typeof ((_f = window === null || window === void 0 ? void 0 : window.Northbeam) === null || _f === void 0 ? void 0 : _f.trackPageView) === 'function') {
1229
+ console.log('-----------------trackPageView触发了------------------');
1214
1230
  (_g = window === null || window === void 0 ? void 0 : window.Northbeam) === null || _g === void 0 ? void 0 : _g.trackPageView();
1215
1231
  }
1216
1232
  const converApiEventParamsJson = (_h = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _h === void 0 ? void 0 : _h[eventName];