pb-sxp-ui 1.15.22-alpha.5 → 1.15.23

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.
@@ -108,6 +108,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
108
108
  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)();
109
109
  }, [bffDataSource]);
110
110
  const bffFetch = (0, react_1.useCallback)((path, options) => {
111
+ var _a, _b;
111
112
  if (!bffDataSource)
112
113
  return;
113
114
  const url = bffDataSource.url;
@@ -115,7 +116,33 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
115
116
  const queryString = qs_1.default.stringify(options.query);
116
117
  path = `${path}?${queryString}`;
117
118
  }
118
- if (options.type === 'beacon' && navigator.sendBeacon) {
119
+ let isTikTokChannel = false;
120
+ const params = {};
121
+ const queryString = location.search.slice(1);
122
+ (_a = (0, tool_1.splitUrlParams)(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
123
+ const key = val.split('=')[0];
124
+ const value = val.split('=')[1];
125
+ params[key] = value;
126
+ });
127
+ const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
128
+ if (cl_source &&
129
+ ((_b = [
130
+ '40A-SPRK--DRESS_EYEWEAR-',
131
+ '41A-SPRK--MADRAGUE-',
132
+ '42A-SPRK--MOOD-',
133
+ '43A-SPRK--SUMMER-',
134
+ '44A-SPRK--DRESS_EYEWEAR-',
135
+ '45A-SPRK--MADRAGUE-',
136
+ '46A-SPRK--MOOD-',
137
+ '47A-SPRK--SUMMER-',
138
+ '48A-SPRK--DRESS_EYEWEAR-',
139
+ '49A-SPRK--MADRAGUE-',
140
+ '50A-SPRK--MOOD-',
141
+ '51A-SPRK--SUMMER-'
142
+ ]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
143
+ isTikTokChannel = true;
144
+ }
145
+ if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
119
146
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
120
147
  JSON.stringify({
121
148
  body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
@@ -125,11 +152,11 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
125
152
  }));
126
153
  }
127
154
  return window
128
- .fetch(`${url}/api/${path}`, {
129
- headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
130
- method: options.method,
131
- body: JSON.stringify(options.body)
132
- })
155
+ .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
156
+ ? JSON.stringify({
157
+ body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
158
+ })
159
+ : JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
133
160
  .then((res) => res.json())
134
161
  .catch((err) => Promise.reject(err));
135
162
  }, [bffDataSource, fakeUserId]);
@@ -294,23 +321,17 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
294
321
  playbookType,
295
322
  bffDataSource
296
323
  ]);
297
- const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
298
- var _a, _b, _c, _d, _e, _f, _g;
299
- if (!enableReportEvent ||
300
- !enabledMetaConversionApi ||
301
- (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
302
- !((_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName])) {
303
- return;
304
- }
305
- const jsonParams = (0, lodash_1.cloneDeep)((_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName]);
324
+ const getEventParamsByJson = (0, react_1.useCallback)((json, product) => {
325
+ var _a, _b, _c;
326
+ const jsonParams = (0, lodash_1.cloneDeep)(json);
306
327
  const urlParams = new URLSearchParams(window.location.search);
307
328
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
308
329
  const fix_par = {
309
- event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
330
+ event_source_url: (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href,
310
331
  external_id: fakeUserId,
311
- client_user_agent: (_e = (_d = window === null || window === void 0 ? void 0 : window.navigator) === null || _d === void 0 ? void 0 : _d.userAgent) !== null && _e !== void 0 ? _e : '',
332
+ 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 : '',
312
333
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
313
- fbp: (0, tool_1.getCookie)('_fbp') ? `fb.2.${new Date().getTime()}.${(0, tool_1.getCookie)('_fbp')}` : '',
334
+ fbp: (0, tool_1.getCookie)('_fbp') ? `${(0, tool_1.getCookie)('_fbp')}` : '',
314
335
  time: Math.floor(Date.now() / 1000)
315
336
  };
316
337
  const regex = /\{\{(.*?)\}\}/g;
@@ -322,7 +343,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
322
343
  }
323
344
  else {
324
345
  for (const key in obj) {
325
- if (obj.hasOwnProperty(key)) {
346
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
326
347
  const value = obj === null || obj === void 0 ? void 0 : obj[key];
327
348
  if (typeof value === 'object') {
328
349
  getEventParams(value);
@@ -359,28 +380,59 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
359
380
  }
360
381
  };
361
382
  getEventParams(jsonParams);
362
- const params = {};
363
- const queryString = location.search.slice(1);
364
- (_f = (0, tool_1.splitUrlParams)(queryString)) === null || _f === void 0 ? void 0 : _f.map((val) => {
365
- const key = val.split('=')[0];
366
- const value = val.split('=')[1];
367
- params[key] = value;
368
- });
369
- const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
370
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/fb/${(_g = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _g === void 0 ? void 0 : _g['x-app-id']}/${eventName}${cl_source ? `/${decodeURIComponent(cl_source)}` : ''}`, {
371
- method: 'POST',
372
- body: jsonParams,
373
- type: 'beacon'
374
- });
375
- }, [
376
- bffFetch,
377
- enableReportEvent,
378
- enabledMetaConversionApi,
379
- globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
380
- globalConfig,
381
- fakeUserId,
382
- bffDataSource
383
- ]);
383
+ return jsonParams;
384
+ }, [fakeUserId]);
385
+ const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
386
+ var _a, _b, _c, _d;
387
+ if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
388
+ return;
389
+ }
390
+ const pixelEventParamsJson = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.pixel) === null || _a === void 0 ? void 0 : _a[eventName];
391
+ if ((pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) && typeof (window === null || window === void 0 ? void 0 : window.fbq) === 'function') {
392
+ function updateQueryStringParameter(uri, key, value) {
393
+ const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
394
+ const separator = uri.indexOf('?') !== -1 ? '&' : '?';
395
+ if (uri.match(re)) {
396
+ return uri.replace(re, '$1' + key + '=' + value + '$2');
397
+ }
398
+ else {
399
+ return uri + separator + key + '=' + value;
400
+ }
401
+ }
402
+ if (eventName === 'PageView' && (pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) === 'PageView') {
403
+ const currentUrl = window.location.href;
404
+ const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
405
+ history.pushState({ path: newUrl }, '', newUrl);
406
+ }
407
+ else {
408
+ const body = getEventParamsByJson(pixelEventParamsJson);
409
+ window === null || window === void 0 ? void 0 : window.fbq('track', pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name, body);
410
+ if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
411
+ window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
412
+ }
413
+ }
414
+ }
415
+ else if (eventName === 'PageView' && typeof (window === null || window === void 0 ? void 0 : window.gtag) === 'function') {
416
+ window === null || window === void 0 ? void 0 : window.gtag('event', 'page_view');
417
+ }
418
+ const converApiEventParamsJson = (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _b === void 0 ? void 0 : _b[eventName];
419
+ if (enabledMetaConversionApi && converApiEventParamsJson) {
420
+ const body = getEventParamsByJson(converApiEventParamsJson, product);
421
+ const params = {};
422
+ const queryString = location.search.slice(1);
423
+ (_c = (0, tool_1.splitUrlParams)(queryString)) === null || _c === void 0 ? void 0 : _c.forEach((val) => {
424
+ const key = val.split('=')[0];
425
+ const value = val.split('=')[1];
426
+ params[key] = value;
427
+ });
428
+ const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
429
+ 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)}` : ''}`, {
430
+ method: 'POST',
431
+ body,
432
+ type: 'beacon'
433
+ });
434
+ }
435
+ }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
384
436
  const bffMutateLike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
385
437
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
386
438
  return res === null || res === void 0 ? void 0 : res.success;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const css_1 = require("@emotion/css");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
+ const CommodityGroup_1 = tslib_1.__importDefault(require("../../template/components/CommodityGroup"));
6
7
  const hooks_1 = require("../../../../core/hooks");
7
8
  require("./index.less");
8
9
  const modules_1 = require("swiper/modules");
@@ -12,7 +13,6 @@ const Modal_1 = tslib_1.__importDefault(require("../../../../core/components/Sxp
12
13
  const ExpandableText_1 = tslib_1.__importDefault(require("../../../../core/components/SxpPageRender/ExpandableText"));
13
14
  const FormatImage_1 = tslib_1.__importDefault(require("../../../../core/components/SxpPageRender/FormatImage"));
14
15
  const tool_1 = require("../../../../core/utils/tool");
15
- const CommodityGroup_1 = tslib_1.__importDefault(require("../../template/components/CommodityGroup"));
16
16
  const materials_1 = require("../../../../core/utils/materials");
17
17
  const CommodityDetail = (_a) => {
18
18
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
@@ -69,7 +69,7 @@ const CommodityDetail = (_a) => {
69
69
  };
70
70
  }, []);
71
71
  const priceText = (0, materials_1.getPriceText)({
72
- product: product,
72
+ product,
73
73
  enableFormattedPrice: (_t = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _t === void 0 ? void 0 : _t.enableFormattedPrice,
74
74
  globalConfig,
75
75
  style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const css_1 = require("@emotion/css");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
+ const CommodityGroup_1 = tslib_1.__importDefault(require("../../template/components/CommodityGroup"));
6
7
  const hooks_1 = require("../../../../core/hooks");
7
8
  require("./index.less");
8
9
  const modules_1 = require("swiper/modules");
@@ -12,7 +13,6 @@ const ExpandableText_1 = tslib_1.__importDefault(require("../../../../core/compo
12
13
  const useEventReport_1 = require("../../../../core/hooks/useEventReport");
13
14
  const FormatImage_1 = tslib_1.__importDefault(require("../../../../core/components/SxpPageRender/FormatImage"));
14
15
  const tool_1 = require("../../../../core/utils/tool");
15
- const CommodityGroup_1 = tslib_1.__importDefault(require("../../template/components/CommodityGroup"));
16
16
  const materials_1 = require("../../../../core/utils/materials");
17
17
  const CommodityDetailDiroNew = (_a) => {
18
18
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.15.22-alpha.5",
3
+ "version": "1.15.23",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",