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/pb-ui.js CHANGED
@@ -776,18 +776,18 @@
776
776
  set(value) {
777
777
  // 继续正常设置 src
778
778
  originalSrcDescriptor.set.call(this, value);
779
- img.onload = function () {
780
- // 检查是否是目标 URL
781
- if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
782
- // 解析 URL 参数
783
- const url = new URL(value);
784
- const params = Object.fromEntries(url.searchParams.entries());
785
- bffCollectEvent({
786
- eventName: params === null || params === void 0 ? void 0 : params.ev,
787
- eventSource: 'Meta Pixel'
788
- });
789
- }
790
- };
779
+ // img.onload = function () {
780
+ // 检查是否是目标 URL
781
+ if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
782
+ // 解析 URL 参数
783
+ const url = new URL(value);
784
+ const params = Object.fromEntries(url.searchParams.entries());
785
+ bffCollectEvent({
786
+ eventName: params === null || params === void 0 ? void 0 : params.ev,
787
+ eventSource: 'Meta Pixel'
788
+ });
789
+ // }
790
+ }
791
791
  },
792
792
  get() {
793
793
  return originalSrcDescriptor.get.call(this);
@@ -827,25 +827,23 @@
827
827
  var _a, _b;
828
828
  try {
829
829
  const parsedData = yield parseBeaconData(data);
830
- if (success) {
831
- // 使用你的自定义上报方法
832
- if (urlString.includes('https://tr.snapchat.com/p')) {
833
- (_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) => {
834
- var _a, _b;
835
- if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
836
- bffCollectEvent({
837
- eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
838
- eventSource: 'Snapchat Pixel'
839
- });
840
- }
841
- });
842
- }
843
- else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
844
- bffCollectEvent({
845
- eventName: parsedData.event,
846
- eventSource: 'TikTok Pixel'
847
- });
848
- }
830
+ // 使用你的自定义上报方法
831
+ if (urlString.includes('https://tr.snapchat.com/p')) {
832
+ (_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) => {
833
+ var _a, _b;
834
+ if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
835
+ bffCollectEvent({
836
+ eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
837
+ eventSource: 'Snapchat Pixel'
838
+ });
839
+ }
840
+ });
841
+ }
842
+ else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
843
+ bffCollectEvent({
844
+ eventName: parsedData.event,
845
+ eventSource: 'TikTok Pixel'
846
+ });
849
847
  }
850
848
  }
851
849
  catch (error) {
@@ -867,6 +865,7 @@
867
865
  window.fetch = function (input, init) {
868
866
  var arguments_1 = arguments;
869
867
  return __awaiter(this, void 0, void 0, function* () {
868
+ var _a;
870
869
  // 安全获取 URL 字符串
871
870
  let url;
872
871
  try {
@@ -887,17 +886,39 @@
887
886
  // 检查是否是 GA4 收集端点
888
887
  try {
889
888
  // 1. 先执行原始请求
890
- const response = yield _originalFetch.apply(this, arguments_1);
889
+ const response = _originalFetch.apply(this, arguments_1);
891
890
  // 2. 检查请求是否成功 (HTTP 200-299)
892
891
  // 安全解析 URL
893
892
  const urlObj = new URL(url);
894
893
  const params = Object.fromEntries(urlObj.searchParams.entries());
894
+ const body = (_a = arguments_1[1]) === null || _a === void 0 ? void 0 : _a.body;
895
895
  if (params === null || params === void 0 ? void 0 : params.en) {
896
896
  bffCollectEvent({
897
897
  eventName: params === null || params === void 0 ? void 0 : params.en,
898
898
  eventSource: 'Google Analytics'
899
899
  });
900
900
  }
901
+ else if (body) {
902
+ function extractAllEnValuesSplit(queryString) {
903
+ if (typeof queryString !== 'string') {
904
+ return [];
905
+ }
906
+ const matches = [];
907
+ const regex = /en=([^&\r\n]*)/g;
908
+ let match;
909
+ while ((match = regex.exec(queryString)) !== null) {
910
+ matches.push(decodeURIComponent(match[1]));
911
+ }
912
+ return matches;
913
+ }
914
+ const enValues = extractAllEnValuesSplit(body);
915
+ enValues === null || enValues === void 0 ? void 0 : enValues.forEach((en) => {
916
+ bffCollectEvent({
917
+ eventName: en,
918
+ eventSource: 'Google Analytics'
919
+ });
920
+ });
921
+ }
901
922
  return response;
902
923
  }
903
924
  catch (error) {