pb-sxp-ui 1.15.16 → 1.15.18

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.
@@ -298,7 +298,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
298
298
  external_id: fakeUserId,
299
299
  client_user_agent: (_c = (_b = window === null || window === void 0 ? void 0 : window.navigator) === null || _b === void 0 ? void 0 : _b.userAgent) !== null && _c !== void 0 ? _c : '',
300
300
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
301
- fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
301
+ fbp: getCookie('_fbp') ? `${getCookie('_fbp')}` : '',
302
302
  time: Math.floor(Date.now() / 1000)
303
303
  };
304
304
  const regex = /\{\{(.*?)\}\}/g;
@@ -350,18 +350,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
350
350
  return jsonParams;
351
351
  }, [fakeUserId]);
352
352
  const bffFbReport = useCallback(({ eventName, product }) => {
353
- var _a, _b, _c, _d, _e;
353
+ var _a, _b, _c, _d;
354
354
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
355
355
  return;
356
356
  }
357
- if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
358
- window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view', {
359
- page_location: (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href,
360
- page_title: document === null || document === void 0 ? void 0 : document.title
361
- });
362
- }
363
- const pixelEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _b === void 0 ? void 0 : _b[eventName];
364
- if (pixelEventParamsJson && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
357
+ const pixelEventParamsJson = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _a === void 0 ? void 0 : _a[eventName];
358
+ if ((pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
365
359
  function updateQueryStringParameter(uri, key, value) {
366
360
  const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
367
361
  const separator = uri.indexOf('?') !== -1 ? '&' : '?';
@@ -372,24 +366,29 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
372
366
  return uri + separator + key + '=' + value;
373
367
  }
374
368
  }
375
- const currentUrl = window.location.href;
376
- const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
377
- history.pushState({ path: newUrl }, '', newUrl);
369
+ if (eventName === 'PageView') {
370
+ const currentUrl = window.location.href;
371
+ const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
372
+ history.pushState({ path: newUrl }, '', newUrl);
373
+ }
378
374
  const body = getEventParamsByJson(pixelEventParamsJson);
379
- window === null || window === void 0 ? void 0 : window.fbq('track', eventName, body);
375
+ window === null || window === void 0 ? void 0 : window.fbq('track', pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name, body);
376
+ }
377
+ else if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
378
+ window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
380
379
  }
381
- const converApiEventParamsJson = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _c === void 0 ? void 0 : _c[eventName];
380
+ const converApiEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName];
382
381
  if (enabledMetaConversionApi && converApiEventParamsJson) {
383
382
  const body = getEventParamsByJson(converApiEventParamsJson, product);
384
383
  const params = {};
385
384
  const queryString = location.search.slice(1);
386
- (_d = splitUrlParams(queryString)) === null || _d === void 0 ? void 0 : _d.forEach((val) => {
385
+ (_c = splitUrlParams(queryString)) === null || _c === void 0 ? void 0 : _c.forEach((val) => {
387
386
  const key = val.split('=')[0];
388
387
  const value = val.split('=')[1];
389
388
  params[key] = value;
390
389
  });
391
390
  const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
392
- bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_e = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _e === void 0 ? void 0 : _e['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
391
+ bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_d = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _d === void 0 ? void 0 : _d['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
393
392
  method: 'POST',
394
393
  body,
395
394
  type: 'beacon'
@@ -301,7 +301,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
301
301
  external_id: fakeUserId,
302
302
  client_user_agent: (_c = (_b = window === null || window === void 0 ? void 0 : window.navigator) === null || _b === void 0 ? void 0 : _b.userAgent) !== null && _c !== void 0 ? _c : '',
303
303
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
304
- fbp: (0, tool_1.getCookie)('_fbp') ? `fb.2.${new Date().getTime()}.${(0, tool_1.getCookie)('_fbp')}` : '',
304
+ fbp: (0, tool_1.getCookie)('_fbp') ? `${(0, tool_1.getCookie)('_fbp')}` : '',
305
305
  time: Math.floor(Date.now() / 1000)
306
306
  };
307
307
  const regex = /\{\{(.*?)\}\}/g;
@@ -353,18 +353,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
353
353
  return jsonParams;
354
354
  }, [fakeUserId]);
355
355
  const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
356
- var _a, _b, _c, _d, _e;
356
+ var _a, _b, _c, _d;
357
357
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
358
358
  return;
359
359
  }
360
- if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
361
- window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view', {
362
- page_location: (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href,
363
- page_title: document === null || document === void 0 ? void 0 : document.title
364
- });
365
- }
366
- const pixelEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _b === void 0 ? void 0 : _b[eventName];
367
- if (pixelEventParamsJson && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
360
+ const pixelEventParamsJson = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _a === void 0 ? void 0 : _a[eventName];
361
+ if ((pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
368
362
  function updateQueryStringParameter(uri, key, value) {
369
363
  const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
370
364
  const separator = uri.indexOf('?') !== -1 ? '&' : '?';
@@ -375,24 +369,29 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
375
369
  return uri + separator + key + '=' + value;
376
370
  }
377
371
  }
378
- const currentUrl = window.location.href;
379
- const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
380
- history.pushState({ path: newUrl }, '', newUrl);
372
+ if (eventName === 'PageView') {
373
+ const currentUrl = window.location.href;
374
+ const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
375
+ history.pushState({ path: newUrl }, '', newUrl);
376
+ }
381
377
  const body = getEventParamsByJson(pixelEventParamsJson);
382
- window === null || window === void 0 ? void 0 : window.fbq('track', eventName, body);
378
+ window === null || window === void 0 ? void 0 : window.fbq('track', pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name, body);
379
+ }
380
+ else if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
381
+ window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
383
382
  }
384
- const converApiEventParamsJson = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _c === void 0 ? void 0 : _c[eventName];
383
+ const converApiEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName];
385
384
  if (enabledMetaConversionApi && converApiEventParamsJson) {
386
385
  const body = getEventParamsByJson(converApiEventParamsJson, product);
387
386
  const params = {};
388
387
  const queryString = location.search.slice(1);
389
- (_d = (0, tool_1.splitUrlParams)(queryString)) === null || _d === void 0 ? void 0 : _d.forEach((val) => {
388
+ (_c = (0, tool_1.splitUrlParams)(queryString)) === null || _c === void 0 ? void 0 : _c.forEach((val) => {
390
389
  const key = val.split('=')[0];
391
390
  const value = val.split('=')[1];
392
391
  params[key] = value;
393
392
  });
394
393
  const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
395
- bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_e = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _e === void 0 ? void 0 : _e['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
394
+ bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_d = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _d === void 0 ? void 0 : _d['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
396
395
  method: 'POST',
397
396
  body,
398
397
  type: 'beacon'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.15.16",
3
+ "version": "1.15.18",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",