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