sobey-monitor-sdk 1.1.12 → 1.1.14
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/core/context.d.ts +2 -1
- package/dist/index.cjs.js +21 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +21 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +21 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/core/context.d.ts
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -178,12 +178,30 @@ class ContextManager {
|
|
|
178
178
|
this.breadcrumbs = [];
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
181
|
+
* 生成或获取会话 ID
|
|
182
|
+
* sessionId 保存在 sessionStorage 中,同一标签页会话期间保持不变
|
|
182
183
|
*/
|
|
183
184
|
generateSessionId() {
|
|
185
|
+
const storageKey = '__sobey_monitor_session_id__';
|
|
186
|
+
try {
|
|
187
|
+
const existing = sessionStorage.getItem(storageKey);
|
|
188
|
+
if (existing) {
|
|
189
|
+
return existing;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
// sessionStorage 不可用,继续生成新的
|
|
194
|
+
}
|
|
184
195
|
const timestamp = Date.now().toString(36);
|
|
185
196
|
const randomPart = Math.random().toString(36).substring(2, 10);
|
|
186
|
-
|
|
197
|
+
const newSessionId = `${timestamp}-${randomPart}`;
|
|
198
|
+
try {
|
|
199
|
+
sessionStorage.setItem(storageKey, newSessionId);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// 忽略存储错误
|
|
203
|
+
}
|
|
204
|
+
return newSessionId;
|
|
187
205
|
}
|
|
188
206
|
/**
|
|
189
207
|
* 收集设备信息
|
|
@@ -1078,7 +1096,7 @@ function reportHttpError(httpInfo, isBusinessError = false) {
|
|
|
1078
1096
|
? `Business Error ${httpInfo.method} ${httpInfo.url}`
|
|
1079
1097
|
: `HTTP ${httpInfo.status} ${httpInfo.method} ${httpInfo.url}`;
|
|
1080
1098
|
const errorData = {
|
|
1081
|
-
type: 'http_error',
|
|
1099
|
+
type: isBusinessError ? 'business_error' : 'http_error',
|
|
1082
1100
|
message,
|
|
1083
1101
|
httpInfo,
|
|
1084
1102
|
};
|