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 +53 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -32
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +53 -32
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/context/SxpDataSourceProvider.js +49 -29
- package/lib/core/context/SxpDataSourceProvider.js +49 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -761,18 +761,18 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
761
761
|
set(value) {
|
762
762
|
// 继续正常设置 src
|
763
763
|
originalSrcDescriptor.set.call(this, value);
|
764
|
-
img.onload = function () {
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
}
|
775
|
-
}
|
764
|
+
// img.onload = function () {
|
765
|
+
// 检查是否是目标 URL
|
766
|
+
if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
|
767
|
+
// 解析 URL 参数
|
768
|
+
const url = new URL(value);
|
769
|
+
const params = Object.fromEntries(url.searchParams.entries());
|
770
|
+
bffCollectEvent({
|
771
|
+
eventName: params === null || params === void 0 ? void 0 : params.ev,
|
772
|
+
eventSource: 'Meta Pixel'
|
773
|
+
});
|
774
|
+
// }
|
775
|
+
}
|
776
776
|
},
|
777
777
|
get() {
|
778
778
|
return originalSrcDescriptor.get.call(this);
|
@@ -812,25 +812,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
812
812
|
var _a, _b;
|
813
813
|
try {
|
814
814
|
const parsedData = yield parseBeaconData(data);
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
});
|
833
|
-
}
|
815
|
+
// 使用你的自定义上报方法
|
816
|
+
if (urlString.includes('https://tr.snapchat.com/p')) {
|
817
|
+
(_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) => {
|
818
|
+
var _a, _b;
|
819
|
+
if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
|
820
|
+
bffCollectEvent({
|
821
|
+
eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
|
822
|
+
eventSource: 'Snapchat Pixel'
|
823
|
+
});
|
824
|
+
}
|
825
|
+
});
|
826
|
+
}
|
827
|
+
else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
|
828
|
+
bffCollectEvent({
|
829
|
+
eventName: parsedData.event,
|
830
|
+
eventSource: 'TikTok Pixel'
|
831
|
+
});
|
834
832
|
}
|
835
833
|
}
|
836
834
|
catch (error) {
|
@@ -852,6 +850,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
852
850
|
window.fetch = function (input, init) {
|
853
851
|
var arguments_1 = arguments;
|
854
852
|
return __awaiter(this, void 0, void 0, function* () {
|
853
|
+
var _a;
|
855
854
|
// 安全获取 URL 字符串
|
856
855
|
let url;
|
857
856
|
try {
|
@@ -872,17 +871,39 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
872
871
|
// 检查是否是 GA4 收集端点
|
873
872
|
try {
|
874
873
|
// 1. 先执行原始请求
|
875
|
-
const response =
|
874
|
+
const response = _originalFetch.apply(this, arguments_1);
|
876
875
|
// 2. 检查请求是否成功 (HTTP 200-299)
|
877
876
|
// 安全解析 URL
|
878
877
|
const urlObj = new URL(url);
|
879
878
|
const params = Object.fromEntries(urlObj.searchParams.entries());
|
879
|
+
const body = (_a = arguments_1[1]) === null || _a === void 0 ? void 0 : _a.body;
|
880
880
|
if (params === null || params === void 0 ? void 0 : params.en) {
|
881
881
|
bffCollectEvent({
|
882
882
|
eventName: params === null || params === void 0 ? void 0 : params.en,
|
883
883
|
eventSource: 'Google Analytics'
|
884
884
|
});
|
885
885
|
}
|
886
|
+
else if (body) {
|
887
|
+
function extractAllEnValuesSplit(queryString) {
|
888
|
+
if (typeof queryString !== 'string') {
|
889
|
+
return [];
|
890
|
+
}
|
891
|
+
const matches = [];
|
892
|
+
const regex = /en=([^&\r\n]*)/g;
|
893
|
+
let match;
|
894
|
+
while ((match = regex.exec(queryString)) !== null) {
|
895
|
+
matches.push(decodeURIComponent(match[1]));
|
896
|
+
}
|
897
|
+
return matches;
|
898
|
+
}
|
899
|
+
const enValues = extractAllEnValuesSplit(body);
|
900
|
+
enValues === null || enValues === void 0 ? void 0 : enValues.forEach((en) => {
|
901
|
+
bffCollectEvent({
|
902
|
+
eventName: en,
|
903
|
+
eventSource: 'Google Analytics'
|
904
|
+
});
|
905
|
+
});
|
906
|
+
}
|
886
907
|
return response;
|
887
908
|
}
|
888
909
|
catch (error) {
|