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.
@@ -244,26 +244,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
244
244
  }
245
245
  try {
246
246
  const response = _originalFetch.apply(this, arguments_1);
247
- if (url.includes('https://i.giesswein.com/nb-collector')) {
248
- if ((init === null || init === void 0 ? void 0 : init.method) === 'POST' && typeof (init === null || init === void 0 ? void 0 : init.body) === 'string') {
249
- try {
250
- const payload = JSON.parse(init.body);
251
- if (payload && Array.isArray(payload.data)) {
252
- payload.data.forEach((item) => {
253
- if (item && item.e) {
254
- bffCollectEvent({
255
- eventName: item.e,
256
- eventSource: 'Northbeam Pixel'
257
- });
258
- }
259
- });
260
- }
261
- }
262
- catch (e) {
263
- console.error('Failed to parse Northbeam event', e);
264
- }
265
- }
266
- }
267
247
  if (url.includes('https://www.google-analytics.com/g/collect')) {
268
248
  const urlObj = new URL(url);
269
249
  const params = Object.fromEntries(urlObj.searchParams.entries());
@@ -305,6 +285,41 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
305
285
  });
306
286
  };
307
287
  }, [bffCollectEvent]);
288
+ useEffect(() => {
289
+ const originalOpen = XMLHttpRequest.prototype.open;
290
+ const originalSend = XMLHttpRequest.prototype.send;
291
+ XMLHttpRequest.prototype.open = function (method, url) {
292
+ this._url = url;
293
+ originalOpen.apply(this, arguments);
294
+ };
295
+ XMLHttpRequest.prototype.send = function (body) {
296
+ if (this._url && typeof this._url === 'string' && this._url.includes('https://i.giesswein.com/nb-collector')) {
297
+ if (body && typeof body === 'string') {
298
+ try {
299
+ const payload = JSON.parse(body);
300
+ if (payload && Array.isArray(payload.data)) {
301
+ payload.data.forEach((item) => {
302
+ if (item && item.e) {
303
+ bffCollectEvent({
304
+ eventName: item.e,
305
+ eventSource: 'Northbeam Pixel'
306
+ });
307
+ }
308
+ });
309
+ }
310
+ }
311
+ catch (e) {
312
+ console.error('Failed to parse Northbeam event from XHR', e);
313
+ }
314
+ }
315
+ }
316
+ originalSend.apply(this, arguments);
317
+ };
318
+ return () => {
319
+ XMLHttpRequest.prototype.open = originalOpen;
320
+ XMLHttpRequest.prototype.send = originalSend;
321
+ };
322
+ }, [bffCollectEvent]);
308
323
  useEffect(() => {
309
324
  if (typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
310
325
  window === null || window === void 0 ? void 0 : window.fbq('track', 'PageView');
@@ -580,6 +595,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
580
595
  window === null || window === void 0 ? void 0 : window.snaptr('track', snapchatPixelEventParamsJson === null || snapchatPixelEventParamsJson === void 0 ? void 0 : snapchatPixelEventParamsJson.event_name, getEventParamsByJson(snapchatPixelEventParamsJson, product));
581
596
  }
582
597
  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') {
598
+ console.log('-----------------trackPageView触发了------------------');
583
599
  (_g = window === null || window === void 0 ? void 0 : window.Northbeam) === null || _g === void 0 ? void 0 : _g.trackPageView();
584
600
  }
585
601
  const converApiEventParamsJson = (_h = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _h === void 0 ? void 0 : _h[eventName];
@@ -247,26 +247,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
247
247
  }
248
248
  try {
249
249
  const response = _originalFetch.apply(this, arguments_1);
250
- if (url.includes('https://i.giesswein.com/nb-collector')) {
251
- if ((init === null || init === void 0 ? void 0 : init.method) === 'POST' && typeof (init === null || init === void 0 ? void 0 : init.body) === 'string') {
252
- try {
253
- const payload = JSON.parse(init.body);
254
- if (payload && Array.isArray(payload.data)) {
255
- payload.data.forEach((item) => {
256
- if (item && item.e) {
257
- bffCollectEvent({
258
- eventName: item.e,
259
- eventSource: 'Northbeam Pixel'
260
- });
261
- }
262
- });
263
- }
264
- }
265
- catch (e) {
266
- console.error('Failed to parse Northbeam event', e);
267
- }
268
- }
269
- }
270
250
  if (url.includes('https://www.google-analytics.com/g/collect')) {
271
251
  const urlObj = new URL(url);
272
252
  const params = Object.fromEntries(urlObj.searchParams.entries());
@@ -308,6 +288,41 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
308
288
  });
309
289
  };
310
290
  }, [bffCollectEvent]);
291
+ (0, react_1.useEffect)(() => {
292
+ const originalOpen = XMLHttpRequest.prototype.open;
293
+ const originalSend = XMLHttpRequest.prototype.send;
294
+ XMLHttpRequest.prototype.open = function (method, url) {
295
+ this._url = url;
296
+ originalOpen.apply(this, arguments);
297
+ };
298
+ XMLHttpRequest.prototype.send = function (body) {
299
+ if (this._url && typeof this._url === 'string' && this._url.includes('https://i.giesswein.com/nb-collector')) {
300
+ if (body && typeof body === 'string') {
301
+ try {
302
+ const payload = JSON.parse(body);
303
+ if (payload && Array.isArray(payload.data)) {
304
+ payload.data.forEach((item) => {
305
+ if (item && item.e) {
306
+ bffCollectEvent({
307
+ eventName: item.e,
308
+ eventSource: 'Northbeam Pixel'
309
+ });
310
+ }
311
+ });
312
+ }
313
+ }
314
+ catch (e) {
315
+ console.error('Failed to parse Northbeam event from XHR', e);
316
+ }
317
+ }
318
+ }
319
+ originalSend.apply(this, arguments);
320
+ };
321
+ return () => {
322
+ XMLHttpRequest.prototype.open = originalOpen;
323
+ XMLHttpRequest.prototype.send = originalSend;
324
+ };
325
+ }, [bffCollectEvent]);
311
326
  (0, react_1.useEffect)(() => {
312
327
  if (typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
313
328
  window === null || window === void 0 ? void 0 : window.fbq('track', 'PageView');
@@ -583,6 +598,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
583
598
  window === null || window === void 0 ? void 0 : window.snaptr('track', snapchatPixelEventParamsJson === null || snapchatPixelEventParamsJson === void 0 ? void 0 : snapchatPixelEventParamsJson.event_name, getEventParamsByJson(snapchatPixelEventParamsJson, product));
584
599
  }
585
600
  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') {
601
+ console.log('-----------------trackPageView触发了------------------');
586
602
  (_g = window === null || window === void 0 ? void 0 : window.Northbeam) === null || _g === void 0 ? void 0 : _g.trackPageView();
587
603
  }
588
604
  const converApiEventParamsJson = (_h = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _h === void 0 ? void 0 : _h[eventName];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.16.22",
3
+ "version": "1.16.24-alpha.1",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",