jason-trace-log 1.1.2 → 1.1.5
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/jason-trace-log.esm.js +37 -6
- package/dist/jason-trace-log.esm.js.map +1 -1
- package/dist/jason-trace-log.umd.js +37 -5
- package/dist/jason-trace-log.umd.js.map +1 -1
- package/dist/lib/baseTrace.js +36 -5
- package/dist/lib/baseTrace.js.map +1 -1
- package/dist/lib/index.js +3 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/types/baseTrace.d.ts +17 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -2
|
@@ -835,6 +835,7 @@ var BaseTrace = /** @class */ (function () {
|
|
|
835
835
|
};
|
|
836
836
|
this.fpId = getFingerprintId('TraceCourse');
|
|
837
837
|
this.customGlobalFields = options.customGlobalFields || {};
|
|
838
|
+
this.beforeSendCallback = options.beforeSend;
|
|
838
839
|
}
|
|
839
840
|
BaseTrace.prototype.log = function (log) {
|
|
840
841
|
try {
|
|
@@ -911,18 +912,45 @@ var BaseTrace = /** @class */ (function () {
|
|
|
911
912
|
BaseTrace.prototype.send = function (data) {
|
|
912
913
|
try {
|
|
913
914
|
var traceData = this.setTraceData(data);
|
|
914
|
-
|
|
915
|
+
var finalData = this.applyBeforeSend(traceData);
|
|
916
|
+
if (finalData) {
|
|
917
|
+
send(this.sendMethod, this.dsn, this.ltsConfig, finalData);
|
|
918
|
+
}
|
|
915
919
|
}
|
|
916
920
|
catch (error) {
|
|
917
921
|
console.error('Failed to send trace data:', error);
|
|
918
922
|
}
|
|
919
923
|
};
|
|
924
|
+
/**
|
|
925
|
+
* 应用 beforeSend 钩子
|
|
926
|
+
* 返回 null 表示丢弃,返回 TraceData 表示发送
|
|
927
|
+
*/
|
|
928
|
+
BaseTrace.prototype.applyBeforeSend = function (data) {
|
|
929
|
+
if (!this.beforeSendCallback) {
|
|
930
|
+
return data;
|
|
931
|
+
}
|
|
932
|
+
try {
|
|
933
|
+
var result = this.beforeSendCallback(data);
|
|
934
|
+
if (result === null) {
|
|
935
|
+
this.debug && console.log('[beforeSend] Data dropped by beforeSend hook');
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
938
|
+
return result;
|
|
939
|
+
}
|
|
940
|
+
catch (error) {
|
|
941
|
+
console.error('[beforeSend] Error in beforeSend callback, sending original data:', error);
|
|
942
|
+
return data;
|
|
943
|
+
}
|
|
944
|
+
};
|
|
920
945
|
BaseTrace.prototype.enqueueOrSend = function (data) {
|
|
946
|
+
var finalData = this.applyBeforeSend(data);
|
|
947
|
+
if (!finalData)
|
|
948
|
+
return;
|
|
921
949
|
if (this.sendMethod === SendMethod.LTS) {
|
|
922
|
-
send(this.sendMethod, this.dsn, this.ltsConfig,
|
|
950
|
+
send(this.sendMethod, this.dsn, this.ltsConfig, finalData);
|
|
923
951
|
}
|
|
924
952
|
else {
|
|
925
|
-
this.queue.push(
|
|
953
|
+
this.queue.push(finalData);
|
|
926
954
|
}
|
|
927
955
|
};
|
|
928
956
|
BaseTrace.prototype.createPerfReport = function () {
|
|
@@ -1032,7 +1060,10 @@ var BaseTrace = /** @class */ (function () {
|
|
|
1032
1060
|
message: event.message,
|
|
1033
1061
|
time: getTimestamp(),
|
|
1034
1062
|
type: TraceDataTypes.RESOURCE,
|
|
1035
|
-
stack: null
|
|
1063
|
+
stack: null,
|
|
1064
|
+
extra: {
|
|
1065
|
+
url: url
|
|
1066
|
+
}
|
|
1036
1067
|
};
|
|
1037
1068
|
this.resources.push(traceData);
|
|
1038
1069
|
this.breadcrumb.push({
|
|
@@ -1088,7 +1119,7 @@ var BaseTrace = /** @class */ (function () {
|
|
|
1088
1119
|
this.debug && console.log('onGlobalError');
|
|
1089
1120
|
window.addEventListener('error', function (event) {
|
|
1090
1121
|
_t.saveError(event);
|
|
1091
|
-
}
|
|
1122
|
+
});
|
|
1092
1123
|
// 单独处理 Promise 异常
|
|
1093
1124
|
window.addEventListener('unhandledrejection', function (event) {
|
|
1094
1125
|
_this.debug && console.log('[unhandledrejection] event: ', event);
|
|
@@ -1268,5 +1299,5 @@ var traceLogSdk = {
|
|
|
1268
1299
|
};
|
|
1269
1300
|
|
|
1270
1301
|
export default traceLogSdk;
|
|
1271
|
-
export { init, getInstance, SendMethod, BrowserType };
|
|
1302
|
+
export { init, getInstance, SendMethod, BaseTrace, BrowserType };
|
|
1272
1303
|
//# sourceMappingURL=jason-trace-log.esm.js.map
|