pb-sxp-ui 1.16.15 → 1.16.16

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.cjs CHANGED
@@ -783,18 +783,18 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
783
783
  set(value) {
784
784
  // 继续正常设置 src
785
785
  originalSrcDescriptor.set.call(this, value);
786
- img.onload = function () {
787
- // 检查是否是目标 URL
788
- if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
789
- // 解析 URL 参数
790
- const url = new URL(value);
791
- const params = Object.fromEntries(url.searchParams.entries());
792
- bffCollectEvent({
793
- eventName: params === null || params === void 0 ? void 0 : params.ev,
794
- eventSource: 'Meta Pixel'
795
- });
796
- }
797
- };
786
+ // img.onload = function () {
787
+ // 检查是否是目标 URL
788
+ if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
789
+ // 解析 URL 参数
790
+ const url = new URL(value);
791
+ const params = Object.fromEntries(url.searchParams.entries());
792
+ bffCollectEvent({
793
+ eventName: params === null || params === void 0 ? void 0 : params.ev,
794
+ eventSource: 'Meta Pixel'
795
+ });
796
+ // }
797
+ }
798
798
  },
799
799
  get() {
800
800
  return originalSrcDescriptor.get.call(this);
@@ -834,25 +834,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
834
834
  var _a, _b;
835
835
  try {
836
836
  const parsedData = yield parseBeaconData(data);
837
- if (success) {
838
- // 使用你的自定义上报方法
839
- if (urlString.includes('https://tr.snapchat.com/p')) {
840
- (_b = (_a = parsedData === null || parsedData === void 0 ? void 0 : parsedData.req) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (item) => {
841
- var _a, _b;
842
- if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
843
- bffCollectEvent({
844
- eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
845
- eventSource: 'Snapchat Pixel'
846
- });
847
- }
848
- });
849
- }
850
- else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
851
- bffCollectEvent({
852
- eventName: parsedData.event,
853
- eventSource: 'TikTok Pixel'
854
- });
855
- }
837
+ // 使用你的自定义上报方法
838
+ if (urlString.includes('https://tr.snapchat.com/p')) {
839
+ (_b = (_a = parsedData === null || parsedData === void 0 ? void 0 : parsedData.req) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (item) => {
840
+ var _a, _b;
841
+ if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
842
+ bffCollectEvent({
843
+ eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
844
+ eventSource: 'Snapchat Pixel'
845
+ });
846
+ }
847
+ });
848
+ }
849
+ else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
850
+ bffCollectEvent({
851
+ eventName: parsedData.event,
852
+ eventSource: 'TikTok Pixel'
853
+ });
856
854
  }
857
855
  }
858
856
  catch (error) {
@@ -874,6 +872,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
874
872
  window.fetch = function (input, init) {
875
873
  var arguments_1 = arguments;
876
874
  return __awaiter(this, void 0, void 0, function* () {
875
+ var _a;
877
876
  // 安全获取 URL 字符串
878
877
  let url;
879
878
  try {
@@ -894,17 +893,39 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
894
893
  // 检查是否是 GA4 收集端点
895
894
  try {
896
895
  // 1. 先执行原始请求
897
- const response = yield _originalFetch.apply(this, arguments_1);
896
+ const response = _originalFetch.apply(this, arguments_1);
898
897
  // 2. 检查请求是否成功 (HTTP 200-299)
899
898
  // 安全解析 URL
900
899
  const urlObj = new URL(url);
901
900
  const params = Object.fromEntries(urlObj.searchParams.entries());
901
+ const body = (_a = arguments_1[1]) === null || _a === void 0 ? void 0 : _a.body;
902
902
  if (params === null || params === void 0 ? void 0 : params.en) {
903
903
  bffCollectEvent({
904
904
  eventName: params === null || params === void 0 ? void 0 : params.en,
905
905
  eventSource: 'Google Analytics'
906
906
  });
907
907
  }
908
+ else if (body) {
909
+ function extractAllEnValuesSplit(queryString) {
910
+ if (typeof queryString !== 'string') {
911
+ return [];
912
+ }
913
+ const matches = [];
914
+ const regex = /en=([^&\r\n]*)/g;
915
+ let match;
916
+ while ((match = regex.exec(queryString)) !== null) {
917
+ matches.push(decodeURIComponent(match[1]));
918
+ }
919
+ return matches;
920
+ }
921
+ const enValues = extractAllEnValuesSplit(body);
922
+ enValues === null || enValues === void 0 ? void 0 : enValues.forEach((en) => {
923
+ bffCollectEvent({
924
+ eventName: en,
925
+ eventSource: 'Google Analytics'
926
+ });
927
+ });
928
+ }
908
929
  return response;
909
930
  }
910
931
  catch (error) {