sentry-miniapp 1.3.0 → 1.4.1

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.
Files changed (32) hide show
  1. package/README.md +88 -0
  2. package/dist/sentry-miniapp.cjs.js +266 -137
  3. package/dist/sentry-miniapp.cjs.js.map +1 -1
  4. package/dist/sentry-miniapp.esm.js +266 -137
  5. package/dist/sentry-miniapp.esm.js.map +1 -1
  6. package/dist/sentry-miniapp.umd.js +266 -137
  7. package/dist/sentry-miniapp.umd.js.map +1 -1
  8. package/dist/types/client.d.ts +4 -6
  9. package/dist/types/client.d.ts.map +1 -1
  10. package/dist/types/crossPlatform.d.ts.map +1 -1
  11. package/dist/types/eventbuilder.d.ts.map +1 -1
  12. package/dist/types/helpers.d.ts.map +1 -1
  13. package/dist/types/index.d.ts +1 -1
  14. package/dist/types/index.d.ts.map +1 -1
  15. package/dist/types/integrations/dedupe.d.ts.map +1 -1
  16. package/dist/types/integrations/globalhandlers.d.ts.map +1 -1
  17. package/dist/types/integrations/index.d.ts +1 -0
  18. package/dist/types/integrations/index.d.ts.map +1 -1
  19. package/dist/types/integrations/linkederrors.d.ts.map +1 -1
  20. package/dist/types/integrations/networkbreadcrumbs.d.ts +29 -0
  21. package/dist/types/integrations/networkbreadcrumbs.d.ts.map +1 -0
  22. package/dist/types/integrations/performance.d.ts.map +1 -1
  23. package/dist/types/integrations/trycatch.d.ts.map +1 -1
  24. package/dist/types/sdk.d.ts +6 -4
  25. package/dist/types/sdk.d.ts.map +1 -1
  26. package/dist/types/transports/offlineStore.d.ts +4 -1
  27. package/dist/types/transports/offlineStore.d.ts.map +1 -1
  28. package/dist/types/transports/xhr.d.ts.map +1 -1
  29. package/dist/types/types.d.ts +4 -0
  30. package/dist/types/types.d.ts.map +1 -1
  31. package/dist/types/version.d.ts +1 -1
  32. package/package.json +103 -16
@@ -4938,7 +4938,7 @@ function addBreadcrumb(breadcrumb, hint) {
4938
4938
  }
4939
4939
  isolationScope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
4940
4940
  }
4941
- const SDK_VERSION = "1.3.0";
4941
+ const SDK_VERSION = "1.4.1";
4942
4942
  const SDK_NAME = "sentry.javascript.miniapp";
4943
4943
  const getSDK = () => {
4944
4944
  let currentSdk = {
@@ -5126,7 +5126,11 @@ function createMiniappTransport(options) {
5126
5126
  });
5127
5127
  },
5128
5128
  fail: (error2) => {
5129
- reject(new Error(`Network request failed: ${error2.errMsg || error2.errorMessage || error2.message || "Unknown error"}`));
5129
+ reject(
5130
+ new Error(
5131
+ `Network request failed: ${error2.errMsg || error2.errorMessage || error2.message || "Unknown error"}`
5132
+ )
5133
+ );
5130
5134
  }
5131
5135
  };
5132
5136
  if (sdk().request) {
@@ -5140,15 +5144,16 @@ function createMiniappTransport(options) {
5140
5144
  }
5141
5145
  return createTransport(options, makeRequest);
5142
5146
  }
5143
- const MAX_OFFLINE_CACHE_SIZE = 30;
5147
+ const DEFAULT_OFFLINE_CACHE_SIZE = 30;
5144
5148
  const OFFLINE_STORE_KEY = "sentry_offline_store";
5145
- function createMiniappOfflineStore(_options) {
5149
+ function createMiniappOfflineStore(options) {
5150
+ const maxCacheSize = options.offlineCacheLimit || DEFAULT_OFFLINE_CACHE_SIZE;
5146
5151
  return {
5147
5152
  push: (env) => __async(null, null, function* () {
5148
5153
  try {
5149
5154
  const store = getStore();
5150
5155
  store.push(env);
5151
- if (store.length > MAX_OFFLINE_CACHE_SIZE) {
5156
+ if (store.length > maxCacheSize) {
5152
5157
  store.shift();
5153
5158
  }
5154
5159
  setStore(store);
@@ -5160,7 +5165,7 @@ function createMiniappOfflineStore(_options) {
5160
5165
  try {
5161
5166
  const store = getStore();
5162
5167
  store.unshift(env);
5163
- if (store.length > MAX_OFFLINE_CACHE_SIZE) {
5168
+ if (store.length > maxCacheSize) {
5164
5169
  store.pop();
5165
5170
  }
5166
5171
  setStore(store);
@@ -5193,7 +5198,7 @@ function getStore() {
5193
5198
  return typeof storedStr === "string" ? JSON.parse(storedStr) : storedStr;
5194
5199
  }
5195
5200
  }
5196
- } catch (e) {
5201
+ } catch (_e) {
5197
5202
  }
5198
5203
  return [];
5199
5204
  }
@@ -5203,7 +5208,7 @@ function setStore(store) {
5203
5208
  if (storageApi) {
5204
5209
  storageApi(OFFLINE_STORE_KEY, JSON.stringify(store));
5205
5210
  }
5206
- } catch (e) {
5211
+ } catch (_e) {
5207
5212
  }
5208
5213
  }
5209
5214
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -5225,6 +5230,7 @@ class MiniappClient extends Client {
5225
5230
  }));
5226
5231
  if (options.enableOfflineCache !== false) {
5227
5232
  return makeOfflineTransport(() => baseTransport)(__spreadProps(__spreadValues({}, transportOptions), {
5233
+ offlineCacheLimit: options.offlineCacheLimit,
5228
5234
  createStore: createMiniappOfflineStore,
5229
5235
  flushAtStartup: true
5230
5236
  // 启动时自动重试发送
@@ -5240,10 +5246,12 @@ class MiniappClient extends Client {
5240
5246
  eventFromException(exception) {
5241
5247
  return Promise.resolve({
5242
5248
  exception: {
5243
- values: [{
5244
- type: exception.name || "Error",
5245
- value: exception.message || String(exception)
5246
- }]
5249
+ values: [
5250
+ {
5251
+ type: exception.name || "Error",
5252
+ value: exception.message || String(exception)
5253
+ }
5254
+ ]
5247
5255
  },
5248
5256
  level: "error"
5249
5257
  });
@@ -5314,34 +5322,19 @@ class MiniappClient extends Client {
5314
5322
  const currentScope = scope || getCurrentScope();
5315
5323
  const isolationScope = getIsolationScope();
5316
5324
  return super._prepareEvent(event, hint || {}, currentScope, isolationScope);
5317
- } catch (error2) {
5325
+ } catch (_error) {
5318
5326
  return Promise.resolve(event);
5319
5327
  }
5320
5328
  }
5321
5329
  /**
5322
- * Show a report dialog to the user to send feedback to a specific event.
5323
- * 向用户显示报告对话框以将反馈发送到特定事件。
5324
- * 注意:小程序环境使用模态对话框模拟此功能
5325
- *
5326
- * @param options Set individual options for the dialog
5327
- */
5328
- showReportDialog(options = {}) {
5329
- const showModal = sdk().showModal;
5330
- if (showModal) {
5331
- showModal({
5332
- title: options.title || "错误反馈",
5333
- content: options.subtitle || "应用遇到了一个错误,是否要发送错误报告?",
5334
- confirmText: "发送",
5335
- cancelText: "取消",
5336
- success: (res) => {
5337
- if (res.confirm && options.onLoad) {
5338
- options.onLoad();
5339
- }
5340
- }
5341
- });
5342
- } else {
5343
- console.warn("sentry-miniapp: showModal is not available in current miniapp platform", options);
5344
- }
5330
+ * @deprecated Miniapp environment does not support Sentry's default HTML report dialog.
5331
+ * Please implement your own UI form to collect user feedback (name, email, comments)
5332
+ * and use `Sentry.captureFeedback()` to submit it to Sentry.
5333
+ */
5334
+ showReportDialog(_options = {}) {
5335
+ console.warn(
5336
+ "[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead."
5337
+ );
5345
5338
  }
5346
5339
  /**
5347
5340
  * Capture feedback using the new feedback API.
@@ -5451,23 +5444,26 @@ const _GlobalHandlers = class _GlobalHandlers {
5451
5444
  return;
5452
5445
  }
5453
5446
  if (sdk().onPageNotFound) {
5454
- (_b = (_a = sdk()).onPageNotFound) == null ? void 0 : _b.call(_a, (res) => {
5455
- const scope = getCurrentScope();
5456
- const url = res.path.split("?")[0];
5457
- scope.setTag("pagenotfound", url);
5458
- scope.setContext("page_not_found", {
5459
- path: res.path,
5460
- query: res.query,
5461
- isEntryPage: res.isEntryPage
5462
- });
5463
- captureException(new Error(`页面无法找到: ${url}`), {
5464
- level: "warning",
5465
- mechanism: {
5466
- type: "onpagenotfound",
5467
- handled: true
5468
- }
5469
- });
5470
- });
5447
+ (_b = (_a = sdk()).onPageNotFound) == null ? void 0 : _b.call(
5448
+ _a,
5449
+ (res) => {
5450
+ const scope = getCurrentScope();
5451
+ const url = res.path.split("?")[0];
5452
+ scope.setTag("pagenotfound", url);
5453
+ scope.setContext("page_not_found", {
5454
+ path: res.path,
5455
+ query: res.query,
5456
+ isEntryPage: res.isEntryPage
5457
+ });
5458
+ captureException(new Error(`页面无法找到: ${url}`), {
5459
+ level: "warning",
5460
+ mechanism: {
5461
+ type: "onpagenotfound",
5462
+ handled: true
5463
+ }
5464
+ });
5465
+ }
5466
+ );
5471
5467
  }
5472
5468
  this._onPageNotFoundHandlerInstalled = true;
5473
5469
  }
@@ -5555,13 +5551,13 @@ const _TryCatch = class _TryCatch {
5555
5551
  setupOnce() {
5556
5552
  const global2 = globalThis;
5557
5553
  if (global2.setTimeout) {
5558
- fill(global2, "setTimeout", this._wrapTimeFunction.bind(this));
5554
+ fill$1(global2, "setTimeout", this._wrapTimeFunction.bind(this));
5559
5555
  }
5560
5556
  if (global2.setInterval) {
5561
- fill(global2, "setInterval", this._wrapTimeFunction.bind(this));
5557
+ fill$1(global2, "setInterval", this._wrapTimeFunction.bind(this));
5562
5558
  }
5563
5559
  if (global2.requestAnimationFrame) {
5564
- fill(global2, "requestAnimationFrame", this._wrapRAF.bind(this));
5560
+ fill$1(global2, "requestAnimationFrame", this._wrapRAF.bind(this));
5565
5561
  }
5566
5562
  }
5567
5563
  };
@@ -5578,7 +5574,7 @@ function wrap$1(fn, options = {}, before) {
5578
5574
  if (fn.__sentry_wrapped__) {
5579
5575
  return fn.__sentry_wrapped__;
5580
5576
  }
5581
- } catch (e) {
5577
+ } catch (_e) {
5582
5578
  return fn;
5583
5579
  }
5584
5580
  const sentryWrapped = function(...args) {
@@ -5642,7 +5638,7 @@ function wrap$1(fn, options = {}, before) {
5642
5638
  }
5643
5639
  return sentryWrapped;
5644
5640
  }
5645
- function fill(source, name, replacementFactory) {
5641
+ function fill$1(source, name, replacementFactory) {
5646
5642
  if (!(name in source)) {
5647
5643
  return;
5648
5644
  }
@@ -5660,7 +5656,7 @@ function fill(source, name, replacementFactory) {
5660
5656
  function getFunctionName(fn) {
5661
5657
  try {
5662
5658
  return fn && fn.name || "<anonymous>";
5663
- } catch (e) {
5659
+ } catch (_e) {
5664
5660
  return "<anonymous>";
5665
5661
  }
5666
5662
  }
@@ -5770,7 +5766,7 @@ const _HttpContext = class _HttpContext {
5770
5766
  const accountInfo = (_b = (_a = sdk()).getAccountInfoSync) == null ? void 0 : _b.call(_a);
5771
5767
  return ((_c = accountInfo.miniProgram) == null ? void 0 : _c.appId) || "unknown";
5772
5768
  }
5773
- } catch (e) {
5769
+ } catch (_e) {
5774
5770
  }
5775
5771
  return "unknown";
5776
5772
  }
@@ -5784,7 +5780,7 @@ const _HttpContext = class _HttpContext {
5784
5780
  const accountInfo = (_b = (_a = sdk()).getAccountInfoSync) == null ? void 0 : _b.call(_a);
5785
5781
  return ((_c = accountInfo == null ? void 0 : accountInfo.miniProgram) == null ? void 0 : _c.version) || "unknown";
5786
5782
  }
5787
- } catch (e) {
5783
+ } catch (_e) {
5788
5784
  }
5789
5785
  return "unknown";
5790
5786
  }
@@ -5823,7 +5819,7 @@ const _HttpContext = class _HttpContext {
5823
5819
  }
5824
5820
  });
5825
5821
  }
5826
- } catch (e) {
5822
+ } catch (_e) {
5827
5823
  }
5828
5824
  return {};
5829
5825
  }
@@ -6016,7 +6012,7 @@ const _System = class _System {
6016
6012
  scope.setTag("app.version", systemInfo.version);
6017
6013
  scope.setTag("language", systemInfo.language);
6018
6014
  }
6019
- } catch (e) {
6015
+ } catch (_e) {
6020
6016
  }
6021
6017
  }
6022
6018
  /**
@@ -6038,7 +6034,7 @@ const _System = class _System {
6038
6034
  }
6039
6035
  });
6040
6036
  }
6041
- } catch (e) {
6037
+ } catch (_e) {
6042
6038
  }
6043
6039
  }
6044
6040
  /**
@@ -6061,7 +6057,7 @@ const _System = class _System {
6061
6057
  }
6062
6058
  });
6063
6059
  }
6064
- } catch (e) {
6060
+ } catch (_e) {
6065
6061
  }
6066
6062
  }
6067
6063
  };
@@ -6145,7 +6141,7 @@ const _Router = class _Router {
6145
6141
  return currentPage.route || currentPage.__route__ || "";
6146
6142
  }
6147
6143
  }
6148
- } catch (e) {
6144
+ } catch (_e) {
6149
6145
  }
6150
6146
  return "";
6151
6147
  }
@@ -6297,7 +6293,10 @@ const _PerformanceIntegration = class _PerformanceIntegration {
6297
6293
  const safeTypes = entryTypes.filter((t) => t !== "measure" && t !== "mark");
6298
6294
  if (safeTypes.length < entryTypes.length && safeTypes.length > 0) {
6299
6295
  observer.observe({ entryTypes: safeTypes });
6300
- console.warn("[Sentry Performance] Failed to observe all types, falling back to:", safeTypes);
6296
+ console.warn(
6297
+ "[Sentry Performance] Failed to observe all types, falling back to:",
6298
+ safeTypes
6299
+ );
6301
6300
  entryTypes.length = 0;
6302
6301
  entryTypes.push(...safeTypes);
6303
6302
  } else {
@@ -6383,86 +6382,98 @@ const _PerformanceIntegration = class _PerformanceIntegration {
6383
6382
  pageReadyTime: entry.pageReadyTime
6384
6383
  }
6385
6384
  });
6386
- startSpan({
6387
- name: `Navigation: ${entry.name}`,
6388
- op: "navigation",
6389
- startTime: entry.startTime / 1e3
6390
- // 转换为秒
6391
- }, (span) => {
6392
- span.setAttributes({
6393
- "navigation.name": entry.name,
6394
- "navigation.duration": entry.duration,
6395
- "navigation.app_launch_time": entry.appLaunchTime || 0,
6396
- "navigation.page_ready_time": entry.pageReadyTime || 0,
6397
- "navigation.first_render_time": entry.firstRenderTime || 0
6398
- });
6399
- span.end((entry.startTime + entry.duration) / 1e3);
6400
- });
6385
+ startSpan(
6386
+ {
6387
+ name: `Navigation: ${entry.name}`,
6388
+ op: "navigation",
6389
+ startTime: entry.startTime / 1e3
6390
+ // 转换为秒
6391
+ },
6392
+ (span) => {
6393
+ span.setAttributes({
6394
+ "navigation.name": entry.name,
6395
+ "navigation.duration": entry.duration,
6396
+ "navigation.app_launch_time": entry.appLaunchTime || 0,
6397
+ "navigation.page_ready_time": entry.pageReadyTime || 0,
6398
+ "navigation.first_render_time": entry.firstRenderTime || 0
6399
+ });
6400
+ span.end((entry.startTime + entry.duration) / 1e3);
6401
+ }
6402
+ );
6401
6403
  }
6402
6404
  /**
6403
6405
  * 处理渲染性能条目
6404
6406
  */
6405
6407
  _processRenderEntry(entry) {
6406
- startSpan({
6407
- name: `Render: ${entry.name}`,
6408
- op: "render",
6409
- startTime: entry.startTime / 1e3
6410
- }, (span) => {
6411
- span.setAttributes({
6412
- "render.name": entry.name,
6413
- "render.duration": entry.duration,
6414
- "render.start": entry.renderStart || 0,
6415
- "render.end": entry.renderEnd || 0,
6416
- "render.script_start": entry.scriptStart || 0,
6417
- "render.script_end": entry.scriptEnd || 0
6418
- });
6419
- span.end((entry.startTime + entry.duration) / 1e3);
6420
- });
6408
+ startSpan(
6409
+ {
6410
+ name: `Render: ${entry.name}`,
6411
+ op: "render",
6412
+ startTime: entry.startTime / 1e3
6413
+ },
6414
+ (span) => {
6415
+ span.setAttributes({
6416
+ "render.name": entry.name,
6417
+ "render.duration": entry.duration,
6418
+ "render.start": entry.renderStart || 0,
6419
+ "render.end": entry.renderEnd || 0,
6420
+ "render.script_start": entry.scriptStart || 0,
6421
+ "render.script_end": entry.scriptEnd || 0
6422
+ });
6423
+ span.end((entry.startTime + entry.duration) / 1e3);
6424
+ }
6425
+ );
6421
6426
  }
6422
6427
  /**
6423
6428
  * 处理资源加载性能条目
6424
6429
  */
6425
6430
  _processResourceEntry(entry) {
6426
- startSpan({
6427
- name: `Resource: ${entry.name}`,
6428
- op: "resource",
6429
- startTime: entry.startTime / 1e3
6430
- }, (span) => {
6431
- span.setAttributes({
6432
- "resource.name": entry.name,
6433
- "resource.duration": entry.duration,
6434
- "resource.type": entry.initiatorType || "unknown",
6435
- "resource.transfer_size": entry.transferSize || 0,
6436
- "resource.encoded_size": entry.encodedBodySize || 0,
6437
- "resource.decoded_size": entry.decodedBodySize || 0
6438
- });
6439
- if (entry.fetchStart && entry.responseEnd) {
6431
+ startSpan(
6432
+ {
6433
+ name: `Resource: ${entry.name}`,
6434
+ op: "resource",
6435
+ startTime: entry.startTime / 1e3
6436
+ },
6437
+ (span) => {
6440
6438
  span.setAttributes({
6441
- "resource.fetch_start": entry.fetchStart,
6442
- "resource.response_end": entry.responseEnd,
6443
- "resource.network_time": entry.responseEnd - entry.fetchStart
6439
+ "resource.name": entry.name,
6440
+ "resource.duration": entry.duration,
6441
+ "resource.type": entry.initiatorType || "unknown",
6442
+ "resource.transfer_size": entry.transferSize || 0,
6443
+ "resource.encoded_size": entry.encodedBodySize || 0,
6444
+ "resource.decoded_size": entry.decodedBodySize || 0
6444
6445
  });
6446
+ if (entry.fetchStart && entry.responseEnd) {
6447
+ span.setAttributes({
6448
+ "resource.fetch_start": entry.fetchStart,
6449
+ "resource.response_end": entry.responseEnd,
6450
+ "resource.network_time": entry.responseEnd - entry.fetchStart
6451
+ });
6452
+ }
6453
+ span.end((entry.startTime + entry.duration) / 1e3);
6445
6454
  }
6446
- span.end((entry.startTime + entry.duration) / 1e3);
6447
- });
6455
+ );
6448
6456
  }
6449
6457
  /**
6450
6458
  * 处理用户自定义性能条目
6451
6459
  */
6452
6460
  _processUserTimingEntry(entry) {
6453
6461
  if (entry.entryType === "measure") {
6454
- startSpan({
6455
- name: `Measure: ${entry.name}`,
6456
- op: "measure",
6457
- startTime: entry.startTime / 1e3
6458
- }, (span) => {
6459
- span.setAttributes({
6460
- "measure.name": entry.name,
6461
- "measure.duration": entry.duration,
6462
- "measure.detail": entry.detail ? JSON.stringify(entry.detail) : void 0
6463
- });
6464
- span.end((entry.startTime + entry.duration) / 1e3);
6465
- });
6462
+ startSpan(
6463
+ {
6464
+ name: `Measure: ${entry.name}`,
6465
+ op: "measure",
6466
+ startTime: entry.startTime / 1e3
6467
+ },
6468
+ (span) => {
6469
+ span.setAttributes({
6470
+ "measure.name": entry.name,
6471
+ "measure.duration": entry.duration,
6472
+ "measure.detail": entry.detail ? JSON.stringify(entry.detail) : void 0
6473
+ });
6474
+ span.end((entry.startTime + entry.duration) / 1e3);
6475
+ }
6476
+ );
6466
6477
  } else if (entry.entryType === "mark") {
6467
6478
  const scope = getCurrentScope();
6468
6479
  scope.addBreadcrumb({
@@ -6706,12 +6717,132 @@ const _RewriteFrames = class _RewriteFrames {
6706
6717
  };
6707
6718
  _RewriteFrames.id = "RewriteFrames";
6708
6719
  let RewriteFrames = _RewriteFrames;
6720
+ function fill(source, name, replacementFactory) {
6721
+ if (!(name in source)) {
6722
+ return;
6723
+ }
6724
+ const original = source[name];
6725
+ const wrapped = replacementFactory(original);
6726
+ if (typeof wrapped === "function") {
6727
+ try {
6728
+ wrapped.prototype = wrapped.prototype || {};
6729
+ wrapped.prototype.constructor = wrapped;
6730
+ } catch (_Oo) {
6731
+ }
6732
+ }
6733
+ source[name] = wrapped;
6734
+ }
6735
+ const _NetworkBreadcrumbs = class _NetworkBreadcrumbs {
6736
+ constructor(options = {}) {
6737
+ this.name = _NetworkBreadcrumbs.id;
6738
+ this._traceNetworkBody = !!options.traceNetworkBody;
6739
+ }
6740
+ /**
6741
+ * @inheritDoc
6742
+ */
6743
+ setupOnce() {
6744
+ const miniappSdk = sdk();
6745
+ if (miniappSdk && typeof miniappSdk.request === "function") {
6746
+ fill(miniappSdk, "request", this._createRequestWrapper.bind(this));
6747
+ }
6748
+ if (miniappSdk && typeof miniappSdk.httpRequest === "function") {
6749
+ fill(miniappSdk, "httpRequest", this._createRequestWrapper.bind(this));
6750
+ }
6751
+ }
6752
+ /**
6753
+ * Wraps the miniapp request API to capture breadcrumbs
6754
+ */
6755
+ _createRequestWrapper(originalRequest) {
6756
+ const traceNetworkBody = this._traceNetworkBody;
6757
+ return function(options) {
6758
+ if (!options || typeof options !== "object") {
6759
+ return originalRequest.call(this, options);
6760
+ }
6761
+ const url = options.url || "";
6762
+ const client = getClient();
6763
+ let dsnUrl = "";
6764
+ if (client) {
6765
+ const dsn = client.getOptions().dsn;
6766
+ if (dsn) {
6767
+ try {
6768
+ const dsnMatch = dsn.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?([^:/\n]+)/i);
6769
+ if (dsnMatch && dsnMatch[1]) {
6770
+ dsnUrl = dsnMatch[1];
6771
+ }
6772
+ } catch (_e) {
6773
+ }
6774
+ }
6775
+ }
6776
+ if (typeof url === "string") {
6777
+ const hostMatch = url.match(/^https?:\/\/([^:/\n]+)/i);
6778
+ const requestHost = hostMatch && hostMatch[1] ? hostMatch[1] : "";
6779
+ const isSentryRequest = dsnUrl && requestHost === dsnUrl || requestHost === "sentry.io" || requestHost.endsWith(".sentry.io");
6780
+ if (isSentryRequest) {
6781
+ return originalRequest.call(this, options);
6782
+ }
6783
+ }
6784
+ const method = (options.method || "GET").toUpperCase();
6785
+ const requestData = options.data;
6786
+ const breadcrumbData = {
6787
+ url,
6788
+ method
6789
+ };
6790
+ if (traceNetworkBody && requestData) {
6791
+ try {
6792
+ breadcrumbData["request_body"] = typeof requestData === "string" ? requestData : JSON.stringify(requestData);
6793
+ } catch (_e) {
6794
+ breadcrumbData["request_body"] = "[Cannot serialize request body]";
6795
+ }
6796
+ }
6797
+ const originalSuccess = options.success;
6798
+ const originalFail = options.fail;
6799
+ options.success = function(...args) {
6800
+ const res = args[0] || {};
6801
+ const statusCode = res.statusCode || res.status;
6802
+ breadcrumbData["status_code"] = statusCode;
6803
+ if (traceNetworkBody && res.data) {
6804
+ try {
6805
+ breadcrumbData["response_body"] = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
6806
+ } catch (_e) {
6807
+ breadcrumbData["response_body"] = "[Cannot serialize response body]";
6808
+ }
6809
+ }
6810
+ addBreadcrumb({
6811
+ type: "http",
6812
+ category: "xhr",
6813
+ data: breadcrumbData,
6814
+ level: statusCode >= 400 ? "warning" : "info"
6815
+ });
6816
+ if (typeof originalSuccess === "function") {
6817
+ return originalSuccess.apply(this, args);
6818
+ }
6819
+ };
6820
+ options.fail = function(...args) {
6821
+ const err = args[0] || {};
6822
+ breadcrumbData["error"] = err.errMsg || err.errorMessage || "Network request failed";
6823
+ addBreadcrumb({
6824
+ type: "http",
6825
+ category: "xhr",
6826
+ data: breadcrumbData,
6827
+ level: "error"
6828
+ });
6829
+ if (typeof originalFail === "function") {
6830
+ return originalFail.apply(this, args);
6831
+ }
6832
+ };
6833
+ return originalRequest.call(this, options);
6834
+ };
6835
+ }
6836
+ };
6837
+ _NetworkBreadcrumbs.id = "NetworkBreadcrumbs";
6838
+ let NetworkBreadcrumbs = _NetworkBreadcrumbs;
6709
6839
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6710
6840
  __proto__: null,
6711
6841
  Dedupe,
6712
6842
  GlobalHandlers,
6713
6843
  HttpContext,
6714
6844
  LinkedErrors,
6845
+ NetworkBreadcrumbs,
6715
6846
  PerformanceIntegration,
6716
6847
  RewriteFrames,
6717
6848
  Router,
@@ -6752,6 +6883,7 @@ function init(options = {}) {
6752
6883
  if (opts.enableSourceMap !== false) {
6753
6884
  opts.integrations.push(new RewriteFrames());
6754
6885
  }
6886
+ opts.integrations.push(new NetworkBreadcrumbs({ traceNetworkBody: opts.traceNetworkBody }));
6755
6887
  setContext("miniapp", {
6756
6888
  platform: appName,
6757
6889
  environment: "miniapp"
@@ -6774,16 +6906,13 @@ function init(options = {}) {
6774
6906
  initAndBind(MiniappClient, opts);
6775
6907
  return getCurrentScope().getClient();
6776
6908
  }
6777
- function showReportDialog(options = {}) {
6778
- const client = getCurrentScope().getClient();
6779
- if (client) {
6780
- client.showReportDialog(options);
6781
- } else {
6782
- console.warn("sentry-miniapp: No client available for showReportDialog");
6783
- }
6909
+ function showReportDialog(_options = {}) {
6910
+ console.warn(
6911
+ "[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead."
6912
+ );
6784
6913
  }
6785
6914
  function wrap(fn) {
6786
- return (function(...args) {
6915
+ return function(...args) {
6787
6916
  return withScope(() => {
6788
6917
  try {
6789
6918
  return fn.apply(this, args);
@@ -6792,7 +6921,7 @@ function wrap(fn) {
6792
6921
  throw error2;
6793
6922
  }
6794
6923
  });
6795
- });
6924
+ };
6796
6925
  }
6797
6926
  function captureFeedback(params) {
6798
6927
  const client = getCurrentScope().getClient();