pb-sxp-ui 1.19.0-alpha.1 → 1.19.0-alpha.3

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.
@@ -26,6 +26,7 @@ import ConsentPopup from './ConsentPopup';
26
26
  import MultiPosts from '../../../materials/sxp/MultiPosts';
27
27
  import { useEditorDataProvider } from '../../../core/context/EditorDataProvider';
28
28
  import NavBack from './NavBack';
29
+ import { deleteCookie, getCookie, setCookie } from '../../../core/utils/tool';
29
30
  const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], defaultData }) => {
30
31
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
31
32
  const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
@@ -42,6 +43,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
42
43
  const skipLinkRef = useRef(false);
43
44
  const [pageNum, setPageNum] = useState(2);
44
45
  const videoWidgetRef = useRef(null);
46
+ const fbcRef = useRef('');
45
47
  const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession, isDiyH5 } = useSxpDataSource();
46
48
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
47
49
  const isShowFingerTip = useMemo(() => {
@@ -479,6 +481,35 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
479
481
  viewTime.current = new Date();
480
482
  }
481
483
  }, [openHashtag, data, activeIndex]);
484
+ useEffect(() => {
485
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
486
+ return;
487
+ window.OptanonWrapper = function () {
488
+ var _a, _b;
489
+ const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
490
+ if (!activeGroups)
491
+ return;
492
+ if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
493
+ if (fbcRef.current) {
494
+ setCookie('_fbc', fbcRef.current, 90);
495
+ }
496
+ }
497
+ else {
498
+ fbcRef.current = getCookie('_fbc');
499
+ deleteCookie('_fbc');
500
+ const item = data[activeIndex];
501
+ const traceInfo = ((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.traceInfo) || ((_b = item === null || item === void 0 ? void 0 : item.product) === null || _b === void 0 ? void 0 : _b.traceInfo) || '';
502
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
503
+ eventInfo: {
504
+ eventSubject: 'refuseCookie',
505
+ eventDescription: 'refuseCookie',
506
+ traceInfo
507
+ },
508
+ isActiveTargetingCookie: false
509
+ });
510
+ }
511
+ };
512
+ }, [globalConfig, bffEventReport, data, activeIndex]);
482
513
  const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
483
514
  var _a, _b, _c, _d, _e, _f, _g, _h;
484
515
  const item = data[activeIndex];
@@ -43,6 +43,8 @@ export interface ISxpDataSourceContext {
43
43
  bffEventReport?: (body: {
44
44
  userInfo?: object;
45
45
  eventInfo: object;
46
+ reportLayId?: boolean;
47
+ isActiveTargetingCookie?: boolean;
46
48
  }) => Promise<any> | undefined | boolean;
47
49
  isPreview?: boolean;
48
50
  loading?: boolean;
@@ -7,7 +7,7 @@ import { storeAndLoadFeUserId, AGREE_POLICY } from '../utils/localStore';
7
7
  import { useIconLink } from '../components/SxpPageRender/useIconLink';
8
8
  import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../utils/event';
9
9
  import Consent from '../components/Consent';
10
- import { deleteCookie, getCookie, setCookie, splitUrlParams } from '../utils/tool';
10
+ import { getCookie, splitUrlParams } from '../utils/tool';
11
11
  export const SxpDataSourceContext = createContext({
12
12
  rtcList: [],
13
13
  tagList: []
@@ -50,7 +50,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
50
50
  const [chatlabsId, setChatlabsId] = useState();
51
51
  const finalPageData = useMemo(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
52
52
  const pixelPvStatusRef = useRef(false);
53
- const fbcRef = useRef('');
54
53
  const isShowConsent = useMemo(() => {
55
54
  var _a, _b, _c, _d;
56
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) &&
@@ -106,23 +105,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
106
105
  var _a;
107
106
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
108
107
  }, [bffDataSource]);
109
- useEffect(() => {
110
- if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
111
- return;
112
- fbcRef.current = getCookie('_fbc');
113
- window.OptanonWrapper = function () {
114
- const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
115
- if (!activeGroups)
116
- return;
117
- if (!(activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4'))) {
118
- deleteCookie('_fbc');
119
- }
120
- else if (fbcRef.current) {
121
- setCookie('_fbc', fbcRef.current, 90);
122
- }
123
- };
124
- }, [globalConfig]);
125
- const isActiveTargetingCookie = useMemo(() => {
108
+ const getTargetingCookie = () => {
126
109
  var _a;
127
110
  function isTargetingRejected(cookieValue) {
128
111
  const groupsMatch = cookieValue.match(/groups=([^&]+)/);
@@ -148,11 +131,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
148
131
  return '';
149
132
  }
150
133
  const OptanonConsent = decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
151
- if (((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
134
+ console.log('OptanonConsent:', window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups);
135
+ if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
152
136
  return true;
153
137
  }
154
138
  return false;
155
- }, [globalConfig]);
139
+ };
156
140
  const bffFetch = useCallback((path, options, isBota = true) => {
157
141
  var _a;
158
142
  if (!bffDataSource)
@@ -180,7 +164,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
180
164
  }, [bffDataSource, fakeUserId]);
181
165
  const bffCollectEvent = useCallback((params) => {
182
166
  var _a;
183
- if (isActiveTargetingCookie)
167
+ if (getTargetingCookie())
184
168
  return Promise.resolve();
185
169
  const body = {
186
170
  eventName: params === null || params === void 0 ? void 0 : params.eventName,
@@ -191,7 +175,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
191
175
  body,
192
176
  type: 'beacon'
193
177
  }, false);
194
- }, [bffFetch, bffDataSource, isActiveTargetingCookie]);
178
+ }, [bffFetch, bffDataSource]);
195
179
  useEffect(() => {
196
180
  const OriginalImage = window.Image;
197
181
  window.Image = function () {
@@ -199,7 +183,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
199
183
  const originalSrcDescriptor = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'src');
200
184
  Object.defineProperty(img, 'src', {
201
185
  set(value) {
202
- if (isActiveTargetingCookie && (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/') || value.includes('https://www.facebook.com/tr'))) {
186
+ if (getTargetingCookie() && (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/') || value.includes('https://www.facebook.com/tr'))) {
203
187
  return;
204
188
  }
205
189
  originalSrcDescriptor.set.call(this, value);
@@ -219,7 +203,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
219
203
  });
220
204
  return img;
221
205
  };
222
- }, [bffCollectEvent, isActiveTargetingCookie]);
206
+ }, [bffCollectEvent]);
223
207
  useEffect(() => {
224
208
  const navigatorWithBeacon = navigator;
225
209
  if (!navigatorWithBeacon.sendBeacon) {
@@ -229,7 +213,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
229
213
  const originalSendBeacon = navigatorWithBeacon.sendBeacon.bind(navigatorWithBeacon);
230
214
  navigatorWithBeacon.sendBeacon = function (url, data) {
231
215
  const urlString = url instanceof URL ? url.href : url.toString();
232
- if (isActiveTargetingCookie && (urlString.includes('https://tr.snapchat.com/p') || urlString.includes('https://analytics.tiktok.com/api/v2/pixel'))) {
216
+ if (getTargetingCookie() && (urlString.includes('https://tr.snapchat.com/p') || urlString.includes('https://analytics.tiktok.com/api/v2/pixel'))) {
233
217
  return true;
234
218
  }
235
219
  const success = originalSendBeacon(url, data);
@@ -277,7 +261,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
277
261
  return () => {
278
262
  navigatorWithBeacon.sendBeacon = originalSendBeacon;
279
263
  };
280
- }, [bffCollectEvent, isActiveTargetingCookie]);
264
+ }, [bffCollectEvent]);
281
265
  useEffect(() => {
282
266
  const _originalFetch = window.fetch;
283
267
  window.fetch = function (input, init) {
@@ -297,7 +281,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
297
281
  return _originalFetch.apply(this, arguments_1);
298
282
  }
299
283
  try {
300
- if (isActiveTargetingCookie && (url.includes('https://www.google-analytics.com/g/collect') || url.includes('https://arms-retcode.aliyuncs.com/r.png'))) {
284
+ if (getTargetingCookie() && (url.includes('https://www.google-analytics.com/g/collect') || url.includes('https://arms-retcode.aliyuncs.com/r.png'))) {
301
285
  return Promise.resolve(new Response(''));
302
286
  }
303
287
  const response = _originalFetch.apply(this, arguments_1);
@@ -341,7 +325,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
341
325
  }
342
326
  });
343
327
  };
344
- }, [bffCollectEvent, isActiveTargetingCookie]);
328
+ }, [bffCollectEvent]);
345
329
  useEffect(() => {
346
330
  const originalOpen = XMLHttpRequest.prototype.open;
347
331
  const originalSend = XMLHttpRequest.prototype.send;
@@ -351,7 +335,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
351
335
  };
352
336
  XMLHttpRequest.prototype.send = function (body) {
353
337
  var _a;
354
- if (isActiveTargetingCookie && this._url && typeof this._url === 'string' && (this._url.includes('https://rumcollector.uptime.com') || this._url.includes('https://arms-retcode.aliyuncs.com/r.png') || this._url.includes('https://i.giesswein.com/nb-collector'))) {
338
+ if (getTargetingCookie() && this._url && typeof this._url === 'string' && (this._url.includes('https://rumcollector.uptime.com') || this._url.includes('https://arms-retcode.aliyuncs.com/r.png') || this._url.includes('https://i.giesswein.com/nb-collector'))) {
355
339
  return;
356
340
  }
357
341
  if (this._url && typeof this._url === 'string' && this._url.includes('https://i.giesswein.com/nb-collector')) {
@@ -379,7 +363,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
379
363
  XMLHttpRequest.prototype.open = originalOpen;
380
364
  XMLHttpRequest.prototype.send = originalSend;
381
365
  };
382
- }, [bffCollectEvent, isActiveTargetingCookie]);
366
+ }, [bffCollectEvent]);
383
367
  useEffect(() => {
384
368
  if (typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
385
369
  window === null || window === void 0 ? void 0 : window.fbq('track', 'PageView');
@@ -504,9 +488,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
504
488
  }
505
489
  return expire;
506
490
  }, [data]);
507
- const bffEventReport = useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
491
+ const bffEventReport = useCallback(({ userInfo, eventInfo, reportLayId = true, isActiveTargetingCookie = true }) => {
508
492
  var _a, _b;
509
- if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isActiveTargetingCookie) {
493
+ if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || (isActiveTargetingCookie && getTargetingCookie())) {
510
494
  return;
511
495
  }
512
496
  if (!userInfo) {
@@ -543,8 +527,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
543
527
  layoutVariantId,
544
528
  globalConfig,
545
529
  playbookType,
546
- bffDataSource,
547
- isActiveTargetingCookie
530
+ bffDataSource
548
531
  ]);
549
532
  const getEventParamsByJson = useCallback((json, product) => {
550
533
  var _a, _b, _c;
@@ -609,7 +592,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
609
592
  }, [fakeUserId]);
610
593
  const bffFbReport = useCallback(({ eventName, product }) => {
611
594
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
612
- if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isActiveTargetingCookie) {
595
+ if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || getTargetingCookie()) {
613
596
  return;
614
597
  }
615
598
  let isPushState = false;
@@ -675,7 +658,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
675
658
  type: 'beacon'
676
659
  });
677
660
  }
678
- }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson, isActiveTargetingCookie]);
661
+ }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
679
662
  const bffMutateLike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
680
663
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
681
664
  return res === null || res === void 0 ? void 0 : res.success;
@@ -29,6 +29,7 @@ const ConsentPopup_1 = tslib_1.__importDefault(require("./ConsentPopup"));
29
29
  const MultiPosts_1 = tslib_1.__importDefault(require("../../../materials/sxp/MultiPosts"));
30
30
  const EditorDataProvider_1 = require("../../../core/context/EditorDataProvider");
31
31
  const NavBack_1 = tslib_1.__importDefault(require("./NavBack"));
32
+ const tool_1 = require("../../../core/utils/tool");
32
33
  const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], defaultData }) => {
33
34
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
34
35
  const mutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
@@ -45,6 +46,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
45
46
  const skipLinkRef = (0, react_1.useRef)(false);
46
47
  const [pageNum, setPageNum] = (0, react_1.useState)(2);
47
48
  const videoWidgetRef = (0, react_1.useRef)(null);
49
+ const fbcRef = (0, react_1.useRef)('');
48
50
  const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession, isDiyH5 } = (0, hooks_1.useSxpDataSource)();
49
51
  const { backMainFeed, productView, jumpToWeb } = (0, useEventReport_1.useEventReport)();
50
52
  const isShowFingerTip = (0, react_1.useMemo)(() => {
@@ -482,6 +484,35 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
482
484
  viewTime.current = new Date();
483
485
  }
484
486
  }, [openHashtag, data, activeIndex]);
487
+ (0, react_1.useEffect)(() => {
488
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
489
+ return;
490
+ window.OptanonWrapper = function () {
491
+ var _a, _b;
492
+ const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
493
+ if (!activeGroups)
494
+ return;
495
+ if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
496
+ if (fbcRef.current) {
497
+ (0, tool_1.setCookie)('_fbc', fbcRef.current, 90);
498
+ }
499
+ }
500
+ else {
501
+ fbcRef.current = (0, tool_1.getCookie)('_fbc');
502
+ (0, tool_1.deleteCookie)('_fbc');
503
+ const item = data[activeIndex];
504
+ const traceInfo = ((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.traceInfo) || ((_b = item === null || item === void 0 ? void 0 : item.product) === null || _b === void 0 ? void 0 : _b.traceInfo) || '';
505
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
506
+ eventInfo: {
507
+ eventSubject: 'refuseCookie',
508
+ eventDescription: 'refuseCookie',
509
+ traceInfo
510
+ },
511
+ isActiveTargetingCookie: false
512
+ });
513
+ }
514
+ };
515
+ }, [globalConfig, bffEventReport, data, activeIndex]);
485
516
  const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
486
517
  var _a, _b, _c, _d, _e, _f, _g, _h;
487
518
  const item = data[activeIndex];
@@ -43,6 +43,8 @@ export interface ISxpDataSourceContext {
43
43
  bffEventReport?: (body: {
44
44
  userInfo?: object;
45
45
  eventInfo: object;
46
+ reportLayId?: boolean;
47
+ isActiveTargetingCookie?: boolean;
46
48
  }) => Promise<any> | undefined | boolean;
47
49
  isPreview?: boolean;
48
50
  loading?: boolean;
@@ -53,7 +53,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
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
55
  const pixelPvStatusRef = (0, react_1.useRef)(false);
56
- const fbcRef = (0, react_1.useRef)('');
57
56
  const isShowConsent = (0, react_1.useMemo)(() => {
58
57
  var _a, _b, _c, _d;
59
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) &&
@@ -109,23 +108,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
109
108
  var _a;
110
109
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + (0, localStore_1.storeAndLoadFeUserId)();
111
110
  }, [bffDataSource]);
112
- (0, react_1.useEffect)(() => {
113
- if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
114
- return;
115
- fbcRef.current = (0, tool_1.getCookie)('_fbc');
116
- window.OptanonWrapper = function () {
117
- const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
118
- if (!activeGroups)
119
- return;
120
- if (!(activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4'))) {
121
- (0, tool_1.deleteCookie)('_fbc');
122
- }
123
- else if (fbcRef.current) {
124
- (0, tool_1.setCookie)('_fbc', fbcRef.current, 90);
125
- }
126
- };
127
- }, [globalConfig]);
128
- const isActiveTargetingCookie = (0, react_1.useMemo)(() => {
111
+ const getTargetingCookie = () => {
129
112
  var _a;
130
113
  function isTargetingRejected(cookieValue) {
131
114
  const groupsMatch = cookieValue.match(/groups=([^&]+)/);
@@ -151,11 +134,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
151
134
  return '';
152
135
  }
153
136
  const OptanonConsent = decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
154
- if (((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
137
+ console.log('OptanonConsent:', window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups);
138
+ if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
155
139
  return true;
156
140
  }
157
141
  return false;
158
- }, [globalConfig]);
142
+ };
159
143
  const bffFetch = (0, react_1.useCallback)((path, options, isBota = true) => {
160
144
  var _a;
161
145
  if (!bffDataSource)
@@ -183,7 +167,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
183
167
  }, [bffDataSource, fakeUserId]);
184
168
  const bffCollectEvent = (0, react_1.useCallback)((params) => {
185
169
  var _a;
186
- if (isActiveTargetingCookie)
170
+ if (getTargetingCookie())
187
171
  return Promise.resolve();
188
172
  const body = {
189
173
  eventName: params === null || params === void 0 ? void 0 : params.eventName,
@@ -194,7 +178,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
194
178
  body,
195
179
  type: 'beacon'
196
180
  }, false);
197
- }, [bffFetch, bffDataSource, isActiveTargetingCookie]);
181
+ }, [bffFetch, bffDataSource]);
198
182
  (0, react_1.useEffect)(() => {
199
183
  const OriginalImage = window.Image;
200
184
  window.Image = function () {
@@ -202,7 +186,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
202
186
  const originalSrcDescriptor = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'src');
203
187
  Object.defineProperty(img, 'src', {
204
188
  set(value) {
205
- if (isActiveTargetingCookie && (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/') || value.includes('https://www.facebook.com/tr'))) {
189
+ if (getTargetingCookie() && (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/') || value.includes('https://www.facebook.com/tr'))) {
206
190
  return;
207
191
  }
208
192
  originalSrcDescriptor.set.call(this, value);
@@ -222,7 +206,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
222
206
  });
223
207
  return img;
224
208
  };
225
- }, [bffCollectEvent, isActiveTargetingCookie]);
209
+ }, [bffCollectEvent]);
226
210
  (0, react_1.useEffect)(() => {
227
211
  const navigatorWithBeacon = navigator;
228
212
  if (!navigatorWithBeacon.sendBeacon) {
@@ -232,7 +216,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
232
216
  const originalSendBeacon = navigatorWithBeacon.sendBeacon.bind(navigatorWithBeacon);
233
217
  navigatorWithBeacon.sendBeacon = function (url, data) {
234
218
  const urlString = url instanceof URL ? url.href : url.toString();
235
- if (isActiveTargetingCookie && (urlString.includes('https://tr.snapchat.com/p') || urlString.includes('https://analytics.tiktok.com/api/v2/pixel'))) {
219
+ if (getTargetingCookie() && (urlString.includes('https://tr.snapchat.com/p') || urlString.includes('https://analytics.tiktok.com/api/v2/pixel'))) {
236
220
  return true;
237
221
  }
238
222
  const success = originalSendBeacon(url, data);
@@ -280,7 +264,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
280
264
  return () => {
281
265
  navigatorWithBeacon.sendBeacon = originalSendBeacon;
282
266
  };
283
- }, [bffCollectEvent, isActiveTargetingCookie]);
267
+ }, [bffCollectEvent]);
284
268
  (0, react_1.useEffect)(() => {
285
269
  const _originalFetch = window.fetch;
286
270
  window.fetch = function (input, init) {
@@ -300,7 +284,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
300
284
  return _originalFetch.apply(this, arguments_1);
301
285
  }
302
286
  try {
303
- if (isActiveTargetingCookie && (url.includes('https://www.google-analytics.com/g/collect') || url.includes('https://arms-retcode.aliyuncs.com/r.png'))) {
287
+ if (getTargetingCookie() && (url.includes('https://www.google-analytics.com/g/collect') || url.includes('https://arms-retcode.aliyuncs.com/r.png'))) {
304
288
  return Promise.resolve(new Response(''));
305
289
  }
306
290
  const response = _originalFetch.apply(this, arguments_1);
@@ -344,7 +328,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
344
328
  }
345
329
  });
346
330
  };
347
- }, [bffCollectEvent, isActiveTargetingCookie]);
331
+ }, [bffCollectEvent]);
348
332
  (0, react_1.useEffect)(() => {
349
333
  const originalOpen = XMLHttpRequest.prototype.open;
350
334
  const originalSend = XMLHttpRequest.prototype.send;
@@ -354,7 +338,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
354
338
  };
355
339
  XMLHttpRequest.prototype.send = function (body) {
356
340
  var _a;
357
- if (isActiveTargetingCookie && this._url && typeof this._url === 'string' && (this._url.includes('https://rumcollector.uptime.com') || this._url.includes('https://arms-retcode.aliyuncs.com/r.png') || this._url.includes('https://i.giesswein.com/nb-collector'))) {
341
+ if (getTargetingCookie() && this._url && typeof this._url === 'string' && (this._url.includes('https://rumcollector.uptime.com') || this._url.includes('https://arms-retcode.aliyuncs.com/r.png') || this._url.includes('https://i.giesswein.com/nb-collector'))) {
358
342
  return;
359
343
  }
360
344
  if (this._url && typeof this._url === 'string' && this._url.includes('https://i.giesswein.com/nb-collector')) {
@@ -382,7 +366,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
382
366
  XMLHttpRequest.prototype.open = originalOpen;
383
367
  XMLHttpRequest.prototype.send = originalSend;
384
368
  };
385
- }, [bffCollectEvent, isActiveTargetingCookie]);
369
+ }, [bffCollectEvent]);
386
370
  (0, react_1.useEffect)(() => {
387
371
  if (typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
388
372
  window === null || window === void 0 ? void 0 : window.fbq('track', 'PageView');
@@ -507,9 +491,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
507
491
  }
508
492
  return expire;
509
493
  }, [data]);
510
- const bffEventReport = (0, react_1.useCallback)(({ userInfo, eventInfo, reportLayId = true }) => {
494
+ const bffEventReport = (0, react_1.useCallback)(({ userInfo, eventInfo, reportLayId = true, isActiveTargetingCookie = true }) => {
511
495
  var _a, _b;
512
- if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isActiveTargetingCookie) {
496
+ if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || (isActiveTargetingCookie && getTargetingCookie())) {
513
497
  return;
514
498
  }
515
499
  if (!userInfo) {
@@ -546,8 +530,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
546
530
  layoutVariantId,
547
531
  globalConfig,
548
532
  playbookType,
549
- bffDataSource,
550
- isActiveTargetingCookie
533
+ bffDataSource
551
534
  ]);
552
535
  const getEventParamsByJson = (0, react_1.useCallback)((json, product) => {
553
536
  var _a, _b, _c;
@@ -612,7 +595,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
612
595
  }, [fakeUserId]);
613
596
  const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
614
597
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
615
- if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isActiveTargetingCookie) {
598
+ if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || getTargetingCookie()) {
616
599
  return;
617
600
  }
618
601
  let isPushState = false;
@@ -678,7 +661,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
678
661
  type: 'beacon'
679
662
  });
680
663
  }
681
- }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson, isActiveTargetingCookie]);
664
+ }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
682
665
  const bffMutateLike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
683
666
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
684
667
  return res === null || res === void 0 ? void 0 : res.success;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.19.0-alpha.1",
3
+ "version": "1.19.0-alpha.3",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",