pb-sxp-ui 1.15.31 → 1.15.33

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.
@@ -49,6 +49,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
49
49
  const [playbookType, setPlaybookType] = useState();
50
50
  const [chatlabsId, setChatlabsId] = useState();
51
51
  const finalPageData = useMemo(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
52
+ const pixelPvStatusRef = useRef(false);
52
53
  const isShowConsent = useMemo(() => {
53
54
  var _a, _b, _c, _d;
54
55
  return (((((_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.privacy_necessity) && !isAgreePolicy && !isEditor) || isOpenConsent) &&
@@ -380,7 +381,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
380
381
  return jsonParams;
381
382
  }, [fakeUserId]);
382
383
  const bffFbReport = useCallback(({ eventName, product }) => {
383
- var _a, _b, _c, _d, _e, _f;
384
+ var _a, _b, _c, _d, _e, _f, _g, _h;
384
385
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
385
386
  return;
386
387
  }
@@ -397,6 +398,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
397
398
  }
398
399
  }
399
400
  if (eventName === 'PageView' && (pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) === 'PageView') {
401
+ if (!pixelPvStatusRef.current) {
402
+ pixelPvStatusRef.current = true;
403
+ return;
404
+ }
400
405
  const currentUrl = window.location.href;
401
406
  const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
402
407
  history.pushState({ path: newUrl }, '', newUrl);
@@ -413,25 +418,27 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
413
418
  window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
414
419
  }
415
420
  const tiktokPixelEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.tiktokPixel) === null || _b === void 0 ? void 0 : _b[eventName];
416
- if ((tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.ttq) === 'function') {
417
- window === null || window === void 0 ? void 0 : window.ttq.track(tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name, tiktokPixelEventParamsJson);
421
+ if ((tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name) &&
422
+ typeof (window === null || window === void 0 ? void 0 : window.ttq) === 'object' &&
423
+ typeof ((_c = window === null || window === void 0 ? void 0 : window.ttq) === null || _c === void 0 ? void 0 : _c.track) === 'function') {
424
+ (_d = window === null || window === void 0 ? void 0 : window.ttq) === null || _d === void 0 ? void 0 : _d.track(tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name, tiktokPixelEventParamsJson);
418
425
  }
419
- const snapchatPixelEventParamsJson = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.snapchatPixel) === null || _c === void 0 ? void 0 : _c[eventName];
426
+ const snapchatPixelEventParamsJson = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.snapchatPixel) === null || _e === void 0 ? void 0 : _e[eventName];
420
427
  if ((snapchatPixelEventParamsJson === null || snapchatPixelEventParamsJson === void 0 ? void 0 : snapchatPixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.snaptr) === 'function') {
421
428
  window === null || window === void 0 ? void 0 : window.snaptr('track', snapchatPixelEventParamsJson === null || snapchatPixelEventParamsJson === void 0 ? void 0 : snapchatPixelEventParamsJson.event_name, snapchatPixelEventParamsJson);
422
429
  }
423
- const converApiEventParamsJson = (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _d === void 0 ? void 0 : _d[eventName];
430
+ const converApiEventParamsJson = (_f = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _f === void 0 ? void 0 : _f[eventName];
424
431
  if (enabledMetaConversionApi && converApiEventParamsJson) {
425
432
  const body = getEventParamsByJson(converApiEventParamsJson, product);
426
433
  const params = {};
427
434
  const queryString = location.search.slice(1);
428
- (_e = splitUrlParams(queryString)) === null || _e === void 0 ? void 0 : _e.forEach((val) => {
435
+ (_g = splitUrlParams(queryString)) === null || _g === void 0 ? void 0 : _g.forEach((val) => {
429
436
  const key = val.split('=')[0];
430
437
  const value = val.split('=')[1];
431
438
  params[key] = value;
432
439
  });
433
440
  const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
434
- bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_f = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _f === void 0 ? void 0 : _f['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
441
+ bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_h = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _h === void 0 ? void 0 : _h['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
435
442
  method: 'POST',
436
443
  body,
437
444
  type: 'beacon'
@@ -52,6 +52,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
52
52
  const [playbookType, setPlaybookType] = (0, react_1.useState)();
53
53
  const [chatlabsId, setChatlabsId] = (0, react_1.useState)();
54
54
  const finalPageData = (0, react_1.useMemo)(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
55
+ const pixelPvStatusRef = (0, react_1.useRef)(false);
55
56
  const isShowConsent = (0, react_1.useMemo)(() => {
56
57
  var _a, _b, _c, _d;
57
58
  return (((((_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.privacy_necessity) && !isAgreePolicy && !isEditor) || isOpenConsent) &&
@@ -383,7 +384,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
383
384
  return jsonParams;
384
385
  }, [fakeUserId]);
385
386
  const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
386
- var _a, _b, _c, _d, _e, _f;
387
+ var _a, _b, _c, _d, _e, _f, _g, _h;
387
388
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
388
389
  return;
389
390
  }
@@ -400,6 +401,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
400
401
  }
401
402
  }
402
403
  if (eventName === 'PageView' && (pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) === 'PageView') {
404
+ if (!pixelPvStatusRef.current) {
405
+ pixelPvStatusRef.current = true;
406
+ return;
407
+ }
403
408
  const currentUrl = window.location.href;
404
409
  const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
405
410
  history.pushState({ path: newUrl }, '', newUrl);
@@ -416,25 +421,27 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
416
421
  window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
417
422
  }
418
423
  const tiktokPixelEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.tiktokPixel) === null || _b === void 0 ? void 0 : _b[eventName];
419
- if ((tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.ttq) === 'function') {
420
- window === null || window === void 0 ? void 0 : window.ttq.track(tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name, tiktokPixelEventParamsJson);
424
+ if ((tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name) &&
425
+ typeof (window === null || window === void 0 ? void 0 : window.ttq) === 'object' &&
426
+ typeof ((_c = window === null || window === void 0 ? void 0 : window.ttq) === null || _c === void 0 ? void 0 : _c.track) === 'function') {
427
+ (_d = window === null || window === void 0 ? void 0 : window.ttq) === null || _d === void 0 ? void 0 : _d.track(tiktokPixelEventParamsJson === null || tiktokPixelEventParamsJson === void 0 ? void 0 : tiktokPixelEventParamsJson.event_name, tiktokPixelEventParamsJson);
421
428
  }
422
- const snapchatPixelEventParamsJson = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.snapchatPixel) === null || _c === void 0 ? void 0 : _c[eventName];
429
+ const snapchatPixelEventParamsJson = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.snapchatPixel) === null || _e === void 0 ? void 0 : _e[eventName];
423
430
  if ((snapchatPixelEventParamsJson === null || snapchatPixelEventParamsJson === void 0 ? void 0 : snapchatPixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.snaptr) === 'function') {
424
431
  window === null || window === void 0 ? void 0 : window.snaptr('track', snapchatPixelEventParamsJson === null || snapchatPixelEventParamsJson === void 0 ? void 0 : snapchatPixelEventParamsJson.event_name, snapchatPixelEventParamsJson);
425
432
  }
426
- const converApiEventParamsJson = (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _d === void 0 ? void 0 : _d[eventName];
433
+ const converApiEventParamsJson = (_f = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _f === void 0 ? void 0 : _f[eventName];
427
434
  if (enabledMetaConversionApi && converApiEventParamsJson) {
428
435
  const body = getEventParamsByJson(converApiEventParamsJson, product);
429
436
  const params = {};
430
437
  const queryString = location.search.slice(1);
431
- (_e = (0, tool_1.splitUrlParams)(queryString)) === null || _e === void 0 ? void 0 : _e.forEach((val) => {
438
+ (_g = (0, tool_1.splitUrlParams)(queryString)) === null || _g === void 0 ? void 0 : _g.forEach((val) => {
432
439
  const key = val.split('=')[0];
433
440
  const value = val.split('=')[1];
434
441
  params[key] = value;
435
442
  });
436
443
  const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
437
- bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_f = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _f === void 0 ? void 0 : _f['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
444
+ bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_h = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _h === void 0 ? void 0 : _h['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
438
445
  method: 'POST',
439
446
  body,
440
447
  type: 'beacon'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.15.31",
3
+ "version": "1.15.33",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",