pb-sxp-ui 1.6.5 → 1.7.0

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.
Files changed (35) hide show
  1. package/dist/index.cjs +114 -51
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +114 -51
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +3 -3
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +3 -3
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +114 -51
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +3 -3
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/SxpPageRender/ExpandableText.js +3 -1
  14. package/es/core/components/SxpPageRender/VideoWidget/index.js +25 -21
  15. package/es/core/components/SxpPageRender/WaterFall/index.js +6 -1
  16. package/es/core/components/SxpPageRender/index.d.ts +1 -0
  17. package/es/core/components/SxpPageRender/index.js +7 -11
  18. package/es/core/context/SxpDataSourceProvider.d.ts +2 -4
  19. package/es/core/context/SxpDataSourceProvider.js +52 -11
  20. package/es/materials/sxp/popup/CommodityDetail/index.js +6 -1
  21. package/es/materials/sxp/popup/CommodityDetailDiro/index.js +6 -1
  22. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +6 -1
  23. package/es/materials/sxp/popup/CommodityList/index.js +7 -2
  24. package/lib/core/components/SxpPageRender/ExpandableText.js +3 -1
  25. package/lib/core/components/SxpPageRender/VideoWidget/index.js +25 -21
  26. package/lib/core/components/SxpPageRender/WaterFall/index.js +6 -1
  27. package/lib/core/components/SxpPageRender/index.d.ts +1 -0
  28. package/lib/core/components/SxpPageRender/index.js +7 -11
  29. package/lib/core/context/SxpDataSourceProvider.d.ts +2 -4
  30. package/lib/core/context/SxpDataSourceProvider.js +52 -11
  31. package/lib/materials/sxp/popup/CommodityDetail/index.js +6 -1
  32. package/lib/materials/sxp/popup/CommodityDetailDiro/index.js +6 -1
  33. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +6 -1
  34. package/lib/materials/sxp/popup/CommodityList/index.js +6 -1
  35. package/package.json +1 -1
@@ -192,23 +192,64 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
192
192
  type: 'beacon'
193
193
  });
194
194
  }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
195
- const bffFbReport = (0, react_1.useCallback)((_a) => {
196
- var _b, _c, _d;
197
- var { eventName, actionSource = 'website', eventSourceUrl = (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href, externalId } = _a;
195
+ const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
196
+ var _a, _b, _c, _d;
198
197
  if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
199
198
  return;
200
199
  }
201
- const fakeUserId = (0, localStore_1.storeAndLoadFeUserId)();
200
+ let jsonParams = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName];
202
201
  const urlParams = new URLSearchParams(window.location.search);
203
- const fbclid = urlParams.get('fbclid');
202
+ const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
203
+ const fix_par = {
204
+ event_source_url: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href,
205
+ external_id: (0, localStore_1.storeAndLoadFeUserId)(),
206
+ client_user_agent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '',
207
+ fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
208
+ fbp: (0, tool_1.getCookie)('_fbp') ? `fb.2.${new Date().getTime()}.${(0, tool_1.getCookie)('_fbp')}` : '',
209
+ time: new Date().getTime()
210
+ };
211
+ const regex = /\{\{(.*?)\}\}/g;
212
+ const getEventParams = (obj) => {
213
+ if (!obj)
214
+ return;
215
+ if (obj instanceof Array) {
216
+ obj === null || obj === void 0 ? void 0 : obj.map((item) => getEventParams(item));
217
+ }
218
+ else {
219
+ for (const key in obj) {
220
+ if (obj.hasOwnProperty(key)) {
221
+ const value = obj === null || obj === void 0 ? void 0 : obj[key];
222
+ if (typeof value === 'object') {
223
+ getEventParams(value);
224
+ }
225
+ else if (typeof value === 'string') {
226
+ const matches = value === null || value === void 0 ? void 0 : value.match(regex);
227
+ if (matches) {
228
+ matches.forEach((match) => {
229
+ const prop = match.substring(2, match.length - 2);
230
+ try {
231
+ const replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
232
+ if (replaceValue) {
233
+ obj[key] = replaceValue;
234
+ }
235
+ else {
236
+ delete obj[key];
237
+ }
238
+ }
239
+ catch (error) {
240
+ console.error('An error occurred:', error === null || error === void 0 ? void 0 : error.message);
241
+ }
242
+ });
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ };
249
+ getEventParams(jsonParams);
204
250
  return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
205
251
  method: 'POST',
206
- body: {
207
- eventName,
208
- actionSource,
209
- eventSourceUrl,
210
- userData: Object.assign(Object.assign(Object.assign({ externalId: fakeUserId }, (fbclid && { fbc: `fb.2.${new Date().getTime()}.${fbclid}` })), ((0, tool_1.getCookie)('_fbp') && { fbp: `fb.2.${new Date().getTime()}.${(0, tool_1.getCookie)('_fbp')}` })), { clientUserAgent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '' })
211
- },
252
+ body: jsonParams,
212
253
  type: 'beacon'
213
254
  });
214
255
  }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
@@ -48,9 +48,14 @@ const CommodityDetail = (_a) => {
48
48
  (0, react_1.useEffect)(() => {
49
49
  if (!isPost) {
50
50
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
51
- eventName: 'ProductView'
51
+ eventName: 'ProductView',
52
+ product
52
53
  });
53
54
  }
55
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
56
+ eventName: 'PageView',
57
+ product
58
+ });
54
59
  }, [isPost, bffFbReport]);
55
60
  (0, react_1.useEffect)(() => {
56
61
  const initTime = () => {
@@ -40,7 +40,12 @@ const CommodityDetailDiro = (_a) => {
40
40
  (0, react_1.useEffect)(() => {
41
41
  if (!isPost) {
42
42
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
43
- eventName: 'ProductView'
43
+ eventName: 'ProductView',
44
+ product
45
+ });
46
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
47
+ eventName: 'PageView',
48
+ product
44
49
  });
45
50
  }
46
51
  }, [isPost, bffFbReport]);
@@ -52,7 +52,12 @@ const CommodityDetailDiroNew = (_a) => {
52
52
  (0, react_1.useEffect)(() => {
53
53
  if (!isPost) {
54
54
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
55
- eventName: 'ProductView'
55
+ eventName: 'ProductView',
56
+ product
57
+ });
58
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
59
+ eventName: 'PageView',
60
+ product
56
61
  });
57
62
  }
58
63
  }, [isPost, bffFbReport]);
@@ -13,7 +13,7 @@ const materials_1 = require("../../../../core/utils/materials");
13
13
  const CommodityList = (_a) => {
14
14
  var _b, _c, _d;
15
15
  var { style, isDefault, rec, viewTime, isPost, bottom_image, commodityStyles, buttonStyle, translateY = 0, commodityPicture, isExternalLink, onClick } = _a, props = tslib_1.__rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "commodityStyles", "buttonStyle", "translateY", "commodityPicture", "isExternalLink", "onClick"]);
16
- const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig } = (0, hooks_1.useSxpDataSource)();
16
+ const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig, bffFbReport } = (0, hooks_1.useSxpDataSource)();
17
17
  const { jumpToWeb } = (0, useEventReport_1.useEventReport)();
18
18
  const { popup } = (0, hooks_1.useEditor)();
19
19
  const recData = isPost ? rec : popupDetailData;
@@ -43,6 +43,11 @@ const CommodityList = (_a) => {
43
43
  onClick === null || onClick === void 0 ? void 0 : onClick();
44
44
  }
45
45
  }, popup === null || popup === void 0 ? void 0 : popup.duration);
46
+ (0, react_1.useEffect)(() => {
47
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
48
+ eventName: 'PageView'
49
+ });
50
+ }, []);
46
51
  return (react_1.default.createElement("div", { className: (0, css_1.css)(Object.assign(Object.assign({}, style), { display: 'flex', flexDirection: 'column', gap: '10px', padding: '0 20px', marginTop: '50px', boxSizing: 'border-box' })) }, product === null || product === void 0 ? void 0 : product.map((item, index) => {
47
52
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
48
53
  return (react_1.default.createElement(react_1.default.Fragment, null, recData && !(item === null || item === void 0 ? void 0 : item.bindCta) ? null : (react_1.default.createElement("div", Object.assign({ key: index }, props, { className: (0, css_1.css)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.6.5",
3
+ "version": "1.7.0",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",