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.
package/dist/index.js CHANGED
@@ -916,7 +916,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
916
916
  external_id: fakeUserId,
917
917
  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 : '',
918
918
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
919
- fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
919
+ fbp: getCookie('_fbp') ? `${getCookie('_fbp')}` : '',
920
920
  time: Math.floor(Date.now() / 1000)
921
921
  };
922
922
  const regex = /\{\{(.*?)\}\}/g;
@@ -968,18 +968,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
968
968
  return jsonParams;
969
969
  }, [fakeUserId]);
970
970
  const bffFbReport = useCallback(({ eventName, product }) => {
971
- var _a, _b, _c, _d, _e;
971
+ var _a, _b, _c, _d;
972
972
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
973
973
  return;
974
974
  }
975
- if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
976
- window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view', {
977
- page_location: (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href,
978
- page_title: document === null || document === void 0 ? void 0 : document.title
979
- });
980
- }
981
- const pixelEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _b === void 0 ? void 0 : _b[eventName];
982
- if (pixelEventParamsJson && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
975
+ const pixelEventParamsJson = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _a === void 0 ? void 0 : _a[eventName];
976
+ if ((pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
983
977
  function updateQueryStringParameter(uri, key, value) {
984
978
  const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
985
979
  const separator = uri.indexOf('?') !== -1 ? '&' : '?';
@@ -990,24 +984,29 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
990
984
  return uri + separator + key + '=' + value;
991
985
  }
992
986
  }
993
- const currentUrl = window.location.href;
994
- const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
995
- history.pushState({ path: newUrl }, '', newUrl);
987
+ if (eventName === 'PageView') {
988
+ const currentUrl = window.location.href;
989
+ const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
990
+ history.pushState({ path: newUrl }, '', newUrl);
991
+ }
996
992
  const body = getEventParamsByJson(pixelEventParamsJson);
997
- window === null || window === void 0 ? void 0 : window.fbq('track', eventName, body);
993
+ window === null || window === void 0 ? void 0 : window.fbq('track', pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name, body);
994
+ }
995
+ else if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
996
+ window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
998
997
  }
999
- const converApiEventParamsJson = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _c === void 0 ? void 0 : _c[eventName];
998
+ const converApiEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName];
1000
999
  if (enabledMetaConversionApi && converApiEventParamsJson) {
1001
1000
  const body = getEventParamsByJson(converApiEventParamsJson, product);
1002
1001
  const params = {};
1003
1002
  const queryString = location.search.slice(1);
1004
- (_d = splitUrlParams(queryString)) === null || _d === void 0 ? void 0 : _d.forEach((val) => {
1003
+ (_c = splitUrlParams(queryString)) === null || _c === void 0 ? void 0 : _c.forEach((val) => {
1005
1004
  const key = val.split('=')[0];
1006
1005
  const value = val.split('=')[1];
1007
1006
  params[key] = value;
1008
1007
  });
1009
1008
  const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
1010
- 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)}` : ''}`, {
1009
+ 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)}` : ''}`, {
1011
1010
  method: 'POST',
1012
1011
  body,
1013
1012
  type: 'beacon'