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.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
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
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
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
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 =
|
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) {
|