sentry-miniapp 1.11.1 → 1.11.2

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/README.en.md CHANGED
@@ -7,9 +7,12 @@
7
7
  ![test coverage](https://img.shields.io/badge/test%20coverage-100%25-brightgreen.svg)
8
8
  [![Sentry Community SDK](https://img.shields.io/badge/Sentry-Community%20SDK-362d59?logo=sentry)](https://docs.sentry.io/platforms/#sdks-supported-by-our-community)
9
9
  [![license](https://img.shields.io/github/license/lizhiyao/sentry-miniapp)](./LICENSE)
10
+ [![docs](https://img.shields.io/badge/docs-sentry--miniapp.pages.dev-3eaf7c?logo=readthedocs&logoColor=white)](https://sentry-miniapp.pages.dev/)
10
11
 
11
12
  [简体中文](./README.md) | English
12
13
 
14
+ > **📖 Documentation**: [https://sentry-miniapp.pages.dev/](https://sentry-miniapp.pages.dev/) — getting started, capability matrix, FAQ, Source Map setup, and examples, with nav and search. (Chinese for now)
15
+
13
16
  A **mini program monitoring SDK** built on `@sentry/core`, providing **error monitoring**, **performance monitoring**, offline caching, and distributed tracing. Supports WeChat, Alipay, ByteDance, Baidu, QQ, DingTalk, Kuaishou mini programs, **WeChat / Douyin mini games**, and cross-platform frameworks (Taro / uni-app).
14
17
 
15
18
  > **What are Mini Programs?** Mini programs (小程序) are lightweight apps that run inside super-apps like WeChat, Alipay, and ByteDance/Douyin. They form a massive ecosystem in China with **hundreds of millions of daily active users**, but have no direct equivalent in the Western tech stack. Think of them as a hybrid between PWAs and native apps, but hosted within a platform's sandbox.
@@ -403,6 +406,84 @@ export default Sentry;
403
406
 
404
407
  Both sides report to the same Sentry DSN so all errors land in a single project. For Taro, use `process.env.TARO_ENV === 'h5'` to branch similarly.
405
408
 
409
+ ### 4. Are network requests included with error events?
410
+
411
+ **Yes, and it's on by default.** The SDK enables `NetworkBreadcrumbs` out of the box, which patches `wx.request` / `my.httpRequest` and records each request as a `category: xhr` breadcrumb. Those breadcrumbs ride along with the **next captured error event** (same as `@sentry/browser`), so you'll see the request trail leading up to the error in the event's **Breadcrumbs** section.
412
+
413
+ - **Fields by default:** `url` / `method` / `status_code` / `duration`; failed requests are `error` level, slow ones (>3s) are `warning`.
414
+ - **Bodies are NOT included by default.** Enable `traceNetworkBody: true` to capture request/response bodies (with built-in sensitive-field scrubbing; use `denyBodyUrls` to exclude specific URLs):
415
+
416
+ ```js
417
+ Sentry.init({ dsn: '...', traceNetworkBody: true });
418
+ ```
419
+
420
+ - **No extra config for uni-app / Taro:** `uni.request` / `Taro.request` ultimately call the patched global `wx.request`, so they're captured too.
421
+
422
+ If an error has no network breadcrumb, it's usually one of:
423
+
424
+ 1. **No request happened before the error fired** (e.g. calling `captureException` right on page load). To verify, make a request first and trigger the error in its callback:
425
+
426
+ ```js
427
+ wx.request({
428
+ url: 'https://httpbin.org/get',
429
+ success() {
430
+ Sentry.captureException(new Error('net test'));
431
+ },
432
+ });
433
+ ```
434
+
435
+ You should then see a `category: xhr` breadcrumb on the event.
436
+
437
+ 2. **`Sentry.init` ran after the request.** The patch is installed during `init`, so requests fired before `init` aren't captured. Always call `Sentry.init` before `App()` / any business request.
438
+
439
+ ### 5. Errors in uni-app (Vue) components aren't reported / reporting rate is very low?
440
+
441
+ With **uni-app** (Vue under the hood) you may hit "`sampleRate` is 1 but only an occasional error shows up". The reason: **Vue catches errors thrown inside components (render / lifecycle / watchers / methods invoked from `@click`) with its own error handler — by default it only logs to console and does NOT bubble them to `wx.onError`**, so the SDK never sees them. Only errors that escape Vue (e.g. `setTimeout` callbacks, unhandled promises, hard crashes) get through, which is why reporting looks sporadic.
442
+
443
+ Wire Vue's `errorHandler` to Sentry so component errors are reported:
444
+
445
+ **uni-app Vue3 (`main.js` / `main.ts`, the current default):**
446
+
447
+ ```js
448
+ import Sentry from '@/utils/sentry'; // your sentry-miniapp init wrapper
449
+ import { createSSRApp } from 'vue';
450
+ import App from './App.vue';
451
+
452
+ export function createApp() {
453
+ const app = createSSRApp(App);
454
+ app.config.errorHandler = (err, instance, info) => {
455
+ Sentry.captureException(err, { extra: { lifecycleHook: info } });
456
+ console.error(err);
457
+ };
458
+ return { app };
459
+ }
460
+ ```
461
+
462
+ **Vue2 (older uni-app):**
463
+
464
+ ```js
465
+ Vue.config.errorHandler = (err, vm, info) => {
466
+ Sentry.captureException(err);
467
+ console.error(err);
468
+ };
469
+ ```
470
+
471
+ > **Taro is not Vue.** Taro defaults to **React** (and also supports Vue). With **Vue**, wire `errorHandler` the same way; with **React**, React does not silently swallow component errors like Vue (an uncaught render error propagates upward), but you can add an **Error Boundary** to forward render errors to Sentry with richer context:
472
+ >
473
+ > ```jsx
474
+ > class SentryBoundary extends React.Component {
475
+ > componentDidCatch(error, info) {
476
+ > Sentry.captureException(error, { extra: info });
477
+ > }
478
+ > render() {
479
+ > return this.props.children;
480
+ > }
481
+ > }
482
+ > // Wrap your root: <SentryBoundary><App /></SentryBoundary>
483
+ > ```
484
+
485
+ This also improves delivery: once `errorHandler` / the boundary catches the error the app keeps running, so the in-flight report request completes (a hard crash would otherwise kill it).
486
+
406
487
  ---
407
488
 
408
489
  ## Documentation
package/README.md CHANGED
@@ -7,9 +7,12 @@
7
7
  ![test coverage](https://img.shields.io/badge/test%20coverage-100%25-brightgreen.svg)
8
8
  [![Sentry Community SDK](https://img.shields.io/badge/Sentry-Community%20SDK-362d59?logo=sentry)](https://docs.sentry.io/platforms/#sdks-supported-by-our-community)
9
9
  [![license](https://img.shields.io/github/license/lizhiyao/sentry-miniapp)](./LICENSE)
10
+ [![文档站 docs](https://img.shields.io/badge/docs-sentry--miniapp.pages.dev-3eaf7c?logo=readthedocs&logoColor=white)](https://sentry-miniapp.pages.dev/)
10
11
 
11
12
  简体中文 | [English](./README.en.md)
12
13
 
14
+ > **📖 文档站**:[https://sentry-miniapp.pages.dev/](https://sentry-miniapp.pages.dev/) —— 快速接入、能力矩阵、FAQ、Source Map 配置、示例索引,带导航与搜索。
15
+
13
16
  一个基于 `@sentry/core` 核心构建的**小程序监控 SDK**,提供**异常监控**、**性能监控**、离线缓存、分布式追踪等能力。支持微信、支付宝、字节跳动、百度、QQ、钉钉、快手等多端小程序,以及微信 / 抖音等**小游戏**,并兼容 Taro / uni-app 等跨端框架。
14
17
 
15
18
  > **📰 最新文章**:[《我给 Sentry 提了个 PR,后来 sentry-miniapp 进了官方文档》](https://juejin.cn/post/7636106283963760681) — sentry-miniapp 已被收录进 Sentry 官方文档的 community-supported SDK 列表,这篇文章记录这件事的来龙去脉。觉得有用请帮忙点个 ⭐ Star,让更多小程序团队找到它。
@@ -418,6 +421,84 @@ export default Sentry;
418
421
 
419
422
  两端上报同一个 Sentry DSN,可以在同一个 Project 里聚合查看错误。Taro 用户可以用类似的 `process.env.TARO_ENV === 'h5'` 判断分端引入。
420
423
 
424
+ ### 4. 网络请求会随错误事件一起上报吗?
425
+
426
+ **会,且默认开启。** SDK 默认启用 `NetworkBreadcrumbs`,自动劫持 `wx.request` / `my.httpRequest`,把每个网络请求记成 `category: xhr` 的面包屑,随**下一个被捕获的错误事件**一起上报(与 `@sentry/browser` 默认行为一致)。在 Sentry 错误详情的 **Breadcrumbs** 区即可看到出错前的请求链路。
427
+
428
+ - **默认带的字段**:`url` / `method` / `status_code` / `duration`;失败请求标 `error` 级、慢请求(>3s)标 `warning` 级。
429
+ - **默认不带请求 / 响应体**。需要 body 时开启 `traceNetworkBody: true`(内置常见敏感字段脱敏,可用 `denyBodyUrls` 排除指定 URL):
430
+
431
+ ```js
432
+ Sentry.init({ dsn: '...', traceNetworkBody: true });
433
+ ```
434
+
435
+ - **uni-app / Taro 无需额外配置**:`uni.request` / `Taro.request` 最终都会走到被包裹的全局 `wx.request`,照常记录。
436
+
437
+ 如果错误里没有网络面包屑,多半是这两点之一:
438
+
439
+ 1. **错误触发前没发过请求**(比如一进页面就手动 `captureException`,自然没有请求面包屑)。验证方式:先发一个请求,在回调里再触发错误——
440
+
441
+ ```js
442
+ wx.request({
443
+ url: 'https://httpbin.org/get',
444
+ success() {
445
+ Sentry.captureException(new Error('net test'));
446
+ },
447
+ });
448
+ ```
449
+
450
+ 到事件 Breadcrumbs 里应能看到 `category: xhr` 那条。
451
+
452
+ 2. **`Sentry.init` 晚于请求执行**:面包屑包裹在 `init` 时装上,`init` 之前发出的请求抓不到。务必让 `Sentry.init` 在 `App()` / 任何业务请求**之前**执行。
453
+
454
+ ### 5. uni-app(Vue)组件内的错误没上报 / 上报率很低?
455
+
456
+ 如果你用 **uni-app**(底层是 Vue),可能遇到「`sampleRate` 设成 1,却只偶尔上报一条」的情况。原因:**Vue 会用自己的错误处理接住组件内(render / 生命周期 / watch / 模板 `@click` 调用的方法)抛出的错误,默认只打印 console,不会再冒泡到 `wx.onError`**,于是 SDK 捕获不到。能上来的只剩「逃逸出 Vue」的那部分(`setTimeout` 回调、未处理 promise、硬崩溃),所以看起来只偶尔上报。
457
+
458
+ 把 Vue 的 `errorHandler` 接到 Sentry,组件内错误就会上报:
459
+
460
+ **uni-app Vue3(`main.js` / `main.ts`,现在默认):**
461
+
462
+ ```js
463
+ import Sentry from '@/utils/sentry'; // 你封装的 sentry-miniapp 初始化
464
+ import { createSSRApp } from 'vue';
465
+ import App from './App.vue';
466
+
467
+ export function createApp() {
468
+ const app = createSSRApp(App);
469
+ app.config.errorHandler = (err, instance, info) => {
470
+ Sentry.captureException(err, { extra: { lifecycleHook: info } });
471
+ console.error(err);
472
+ };
473
+ return { app };
474
+ }
475
+ ```
476
+
477
+ **Vue2(uni-app 旧版):**
478
+
479
+ ```js
480
+ Vue.config.errorHandler = (err, vm, info) => {
481
+ Sentry.captureException(err);
482
+ console.error(err);
483
+ };
484
+ ```
485
+
486
+ > **Taro 不是 Vue。** Taro 默认用 **React**(也支持 Vue)。用 **Vue** 时同理接 `errorHandler`;用 **React** 时,React 不会像 Vue 那样静默吞掉组件错误(未捕获的渲染错误会向上抛),但你可以加一个**错误边界(Error Boundary)**把渲染错误更完整地转给 Sentry:
487
+ >
488
+ > ```jsx
489
+ > class SentryBoundary extends React.Component {
490
+ > componentDidCatch(error, info) {
491
+ > Sentry.captureException(error, { extra: info });
492
+ > }
493
+ > render() {
494
+ > return this.props.children;
495
+ > }
496
+ > }
497
+ > // 用它包住根组件:<SentryBoundary><App /></SentryBoundary>
498
+ > ```
499
+
500
+ 接上之后还顺带提升送达率——`errorHandler` / 错误边界接住后应用不崩,上报请求能正常发完(硬崩溃会把还在飞的上报请求一起带走)。
501
+
421
502
  ---
422
503
 
423
504
  ## 📖 文档导航
@@ -4,7 +4,7 @@ ${JSON.stringify(o)}
4
4
  `),typeof a=="string"||a instanceof Uint8Array)s(a);else{let c;try{c=JSON.stringify(a)}catch(u){c=JSON.stringify(q(a))}s(c)}}return typeof r=="string"?r:uo(r)}function uo(t){const e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function lo(t){return[{type:"span"},t]}function fo(t){const e=typeof t.data=="string"?Xt(t.data):t.data;return[{type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType},e]}const es={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function po(t){return t in es}function Gn(t){return po(t)?es[t]:t}function ts(t){if(!(t!=null&&t.sdk))return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function ho(t,e,n,r){var i;const s=(i=t.sdkProcessingMetadata)==null?void 0:i.dynamicSamplingContext;return l(l(l({event_id:t.event_id,sent_at:new Date().toISOString()},e&&{sdk:e}),!!n&&r&&{dsn:fe(r)}),s&&{trace:s})}function _o(t,e){var r,s,i,o;if(!e)return t;const n=t.sdk||{};return t.sdk=E(l({},n),{name:n.name||e.name,version:n.version||e.version,integrations:[...((r=t.sdk)==null?void 0:r.integrations)||[],...e.integrations||[]],packages:[...((s=t.sdk)==null?void 0:s.packages)||[],...e.packages||[]],settings:(i=t.sdk)!=null&&i.settings||e.settings?l(l({},(o=t.sdk)==null?void 0:o.settings),e.settings):void 0}),t}function mo(t,e,n,r){const s=ts(n),i=l(l({sent_at:new Date().toISOString()},s&&{sdk:s}),!!r&&e&&{dsn:fe(e)}),o="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return J(i,[o])}function go(t,e,n,r){const s=ts(n),i=t.type&&t.type!=="replay_event"?t.type:"event";_o(t,n==null?void 0:n.sdk);const o=ho(t,s,r,e);return delete t.sdkProcessingMetadata,J(o,[[{type:i},t]])}function yo(t,e){function n(d){return!!d.trace_id&&!!d.public_key}const r=ne(t[0]),s=e==null?void 0:e.getDsn(),i=e==null?void 0:e.getOptions().tunnel,o=l(l({sent_at:new Date().toISOString()},n(r)&&{trace:r}),!!i&&s&&{dsn:fe(s)}),{beforeSendSpan:a,ignoreSpans:c}=(e==null?void 0:e.getOptions())||{},u=c!=null&&c.length?t.filter(d=>{const _=x(d);return!ze({description:_.description,op:_.op,attributes:_.data},c)}):t,p=t.length-u.length;p&&(e==null||e.recordDroppedEvent("before_send","span",p));const f=a?d=>{const _=x(d),b=Qr(a)?_:a(_);return b||(Vt(),_)}:x,h=[];for(const d of u){const _=f(d);_&&h.push(lo(_))}return J(o,h)}function So(t){if(!g)return;const{description:e="< unknown name >",op:n="< unknown op >",parent_span_id:r}=x(t),{spanId:s}=t.spanContext(),i=Y(t),o=L(t),a=o===t,c=`[Tracing] Starting ${i?"sampled":"unsampled"} ${a?"root ":""}span`,u=[`op: ${n}`,`name: ${e}`,`ID: ${s}`];if(r&&u.push(`parent ID: ${r}`),!a){const{op:p,description:f}=x(o);u.push(`root ID: ${o.spanContext().spanId}`),p&&u.push(`root op: ${p}`),f&&u.push(`root description: ${f}`)}m.log(`${c}
5
5
  ${u.join(`
6
6
  `)}`)}function bo(t){if(!g)return;const{description:e="< unknown name >",op:n="< unknown op >"}=x(t),{spanId:r}=t.spanContext(),i=L(t)===t,o=`[Tracing] Finishing "${n}" ${i?"root ":""}span "${e}" with ID ${r}`;m.log(o)}function he(t,e,n,r=Yr()){const s=r&&L(r);s&&(g&&m.log(`[Measurement] Setting measurement on root span: ${t} = ${e} ${n}`),s.addEvent(t,{[$r]:e,[Lr]:n}))}function Kn(t){if(!t||t.length===0)return;const e={};return t.forEach(n=>{const r=n.attributes||{},s=r[Lr],i=r[$r];typeof s=="string"&&typeof i=="number"&&(e[n.name]={value:i,unit:s})}),e}function Ce(t){return t.getOptions().traceLifecycle==="stream"}const Vn=1e3;class dn{constructor(e={}){this._traceId=e.traceId||ee(),this._spanId=e.spanId||ue(),this._startTime=e.startTimestamp||Ee(),this._links=e.links,this._attributes={},this.setAttributes(l({[Wt]:"manual",[Be]:e.op},e.attributes)),this._name=e.name,e.parentSpanId&&(this._parentSpanId=e.parentSpanId),"sampled"in e&&(this._sampled=e.sampled),e.endTimestamp&&(this._endTime=e.endTimestamp),this._events=[],this._isStandaloneSpan=e.isStandalone,this._endTime&&this._onSpanEnded()}addLink(e){return this._links?this._links.push(e):this._links=[e],this}addLinks(e){return this._links?this._links.push(...e):this._links=e,this}recordException(e,n){}spanContext(){const{_spanId:e,_traceId:n,_sampled:r}=this;return{spanId:e,traceId:n,traceFlags:r?Et:Wr}}setAttribute(e,n){return n===void 0?delete this._attributes[e]:this._attributes[e]=n,this}setAttributes(e){return Object.keys(e).forEach(n=>this.setAttribute(n,e[n])),this}updateStartTime(e){this._startTime=Q(e)}setStatus(e){return this._status=e,this}updateName(e){return this._name=e,this.setAttribute(je,"custom"),this}end(e){this._endTime||(this._endTime=Q(e),bo(this),this._onSpanEnded())}getSpanJSON(){return{data:this._attributes,description:this._name,op:this._attributes[Be],parent_span_id:this._parentSpanId,span_id:this._spanId,start_timestamp:this._startTime,status:Kr(this._status),timestamp:this._endTime,trace_id:this._traceId,origin:this._attributes[Wt],profile_id:this._attributes[cn],exclusive_time:this._attributes[un],measurements:Kn(this._events),is_segment:this._isStandaloneSpan&&L(this)===this||void 0,segment_id:this._isStandaloneSpan?L(this).spanContext().spanId:void 0,links:Gr(this._links)}}getStreamedSpanJSON(){var e,n;return{name:(e=this._name)!=null?e:"",span_id:this._spanId,trace_id:this._traceId,parent_span_id:this._parentSpanId,start_timestamp:this._startTime,end_timestamp:(n=this._endTime)!=null?n:this._startTime,is_segment:this._isStandaloneSpan||this===L(this),status:no(this._status),attributes:this._attributes,links:Xi(this._links)}}isRecording(){return!this._endTime&&!!this._sampled}addEvent(e,n,r){g&&m.log("[Tracing] Adding an event to span:",e);const s=Yn(n)?n:r||Ee(),i=Yn(n)?{}:n||{},o={name:e,time:Q(s),attributes:i};return this._events.push(o),this}isStandaloneSpan(){return!!this._isStandaloneSpan}_onSpanEnded(){const e=k();if(e&&(e.emit("spanEnd",this),this._isStandaloneSpan||e.emit("afterSpanEnd",this)),!(this._isStandaloneSpan||this===L(this)))return;if(this._isStandaloneSpan){this._sampled?To(yo([this],e)):(g&&m.log("[Tracing] Discarding standalone span because its trace was not chosen to be sampled."),e&&e.recordDroppedEvent("sample_rate","span"));return}else if(e&&Ce(e)){e.emit("afterSegmentSpanEnd",this);return}const r=this._convertSpanToTransaction();r&&(Ue(this).scope||y()).captureEvent(r)}_convertSpanToTransaction(){var f;if(!Jn(x(this)))return;this._name||(g&&m.warn("Transaction has no name, falling back to `<unlabeled transaction>`."),this._name="<unlabeled transaction>");const{scope:e,isolationScope:n}=Ue(this),r=(f=e==null?void 0:e.getScopeData().sdkProcessingMetadata)==null?void 0:f.normalizedRequest;if(this._sampled!==!0)return;const i=ro(this).filter(h=>h!==this&&!Eo(h)).map(h=>x(h)).filter(Jn),o=this._attributes[je];delete this._attributes[jn];let a=!1;i.forEach(h=>{var d;delete h.data[jn],(d=h.op)!=null&&d.startsWith("gen_ai.")&&(a=!0)});const c=l({contexts:{trace:Ki(this)},spans:i.length>Vn?i.sort((h,d)=>h.start_timestamp-d.start_timestamp).slice(0,Vn):i,start_timestamp:this._startTime,timestamp:this._endTime,transaction:this._name,type:"transaction",sdkProcessingMetadata:{capturedSpanScope:e,capturedSpanIsolationScope:n,dynamicSamplingContext:ne(this),hasGenAiSpans:a},request:r},o&&{transaction_info:{source:o}}),u=Kn(this._events);return u&&Object.keys(u).length&&(g&&m.log("[Measurements] Adding measurements to transaction event",JSON.stringify(u,void 0,2)),c.measurements=u),c}}function Yn(t){return t&&typeof t=="number"||t instanceof Date||Array.isArray(t)}function Jn(t){return!!t.start_timestamp&&!!t.timestamp&&!!t.span_id&&!!t.trace_id}function Eo(t){return t instanceof dn&&t.isStandaloneSpan()}function To(t){const e=k();if(!e)return;const n=t[1];if(!n||n.length===0){e.recordDroppedEvent("before_send","span");return}e.sendEnvelope(t)}function vo(t,e,n=()=>{},r=()=>{}){let s;try{s=t()}catch(i){throw e(i),n(),i}return wo(s,e,n,r)}function wo(t,e,n,r){return ce(t)?Mr(t,s=>{n(),r(s)},s=>{e(s),n()}):(n(),r(t),t)}function Io(t,e,n){if(!fn(t))return[!1];let r,s;typeof t.tracesSampler=="function"?(s=t.tracesSampler(E(l({},e),{inheritOrSampleWith:a=>typeof e.parentSampleRate=="number"?e.parentSampleRate:typeof e.parentSampled=="boolean"?Number(e.parentSampled):a})),r=!0):e.parentSampled!==void 0?s=e.parentSampled:typeof t.tracesSampleRate!="undefined"&&(s=t.tracesSampleRate,r=!0);const i=ln(s);if(i===void 0)return g&&m.warn(`[Tracing] Discarding root span because of invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(s)} of type ${JSON.stringify(typeof s)}.`),[!1];if(!i)return g&&m.log(`[Tracing] Discarding transaction because ${typeof t.tracesSampler=="function"?"tracesSampler returned 0 or false":"a negative sampling decision was inherited or tracesSampleRate is set to 0"}`),[!1,i,r];const o=n<i;return o||g&&m.log(`[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number(s)})`),[o,i,r]}const ko="__SENTRY_SUPPRESS_TRACING__";function _e(t,e){const n=hn();if(n.startSpan)return n.startSpan(t,e);const r=ss(t),{forceTransaction:s,parentSpan:i,scope:o}=t,a=o==null?void 0:o.clone();return Re(a,()=>Ro(i)(()=>{const u=y(),p=is(u,i),f=k(),h=t.onlyIfParent&&!p,d=h?new W:rs({parentSpan:p,spanArguments:r,forceTransaction:s,scope:u});return h&&(f==null||f.recordDroppedEvent("no_parent_span","span")),(!Po(d)||!p)&&$e(u,d),vo(()=>e(d),()=>{const{status:_}=x(d);d.isRecording()&&(!_||_==="ok")&&d.setStatus({code:C,message:"internal_error"})},()=>{d.end()})}))}function Tt(t){const e=hn();if(e.startInactiveSpan)return e.startInactiveSpan(t);const n=ss(t),{forceTransaction:r,parentSpan:s}=t;return(t.scope?o=>Re(t.scope,o):s!==void 0?o=>ns(s,o):o=>o())(()=>{const o=y(),a=is(o,s),c=k();return t.onlyIfParent&&!a?(c==null||c.recordDroppedEvent("no_parent_span","span"),new W):rs({parentSpan:a,spanArguments:n,forceTransaction:r,scope:o})})}function ns(t,e){const n=hn();return n.withActiveSpan?n.withActiveSpan(t,e):Re(r=>($e(r,t||void 0),e(r)))}function rs({parentSpan:t,spanArguments:e,forceTransaction:n,scope:r}){var a;if(!fn()){const c=new W;if(n||!t){const u=l({sampled:"false",sample_rate:"0",transaction:e.name},ne(c));Rt(c,u)}return c}const s=k();if(Co(s,e))return _n(r)||s==null||s.recordDroppedEvent("ignored","span"),new W({dropReason:"ignored",traceId:(a=t==null?void 0:t.spanContext().traceId)!=null?a:r.getPropagationContext().traceId});const i=A();let o;if(t&&!n)o=Ao(t,r,e),Vr(t,o);else if(t){const c=ne(t),{traceId:u,spanId:p}=t.spanContext(),f=Y(t);o=Xn(l({traceId:u,parentSpanId:p},e),r,f),Rt(o,c)}else{const{traceId:c,dsc:u,parentSpanId:p,sampled:f}=l(l({},i.getPropagationContext()),r.getPropagationContext());o=Xn(l({traceId:c,parentSpanId:p},e),r,f),u&&Rt(o,u)}return So(o),Ni(o,r,i),o}function ss(t){const e=t.experimental||{},n=l({isStandalone:e.standalone},t);if(t.startTime){const r=l({},n);return r.startTimestamp=Q(t.startTime),delete r.startTime,r}return n}function hn(){const t=V();return le(t)}function Xn(t,e,n){var b,T;const r=k(),s=(r==null?void 0:r.getOptions())||{},{name:i=""}=t,o={spanAttributes:l({},t.attributes),spanName:i,parentSampled:n};r==null||r.emit("beforeSampling",o,{decision:!1});const a=(b=o.parentSampled)!=null?b:n,c=o.spanAttributes,u=e.getPropagationContext(),p=_n(e),[f,h,d]=p?[!1]:Io(s,{name:i,parentSampled:a,attributes:c,parentSampleRate:ln((T=u.dsc)==null?void 0:T.sample_rate)},u.sampleRand),_=new dn(E(l({},t),{attributes:l({[je]:"custom",[Fr]:h!==void 0&&d?h:void 0},c),sampled:f}));return!f&&r&&!p&&(g&&m.log("[Tracing] Discarding root span because its trace was not chosen to be sampled."),r.recordDroppedEvent("sample_rate",Ce(r)?"span":"transaction")),r&&r.emit("spanStart",_),_}function Ao(t,e,n){const{spanId:r,traceId:s}=t.spanContext(),i=_n(e),o=i?!1:Y(t),a=o?new dn(E(l({},n),{parentSpanId:r,traceId:s,sampled:o})):new W({traceId:s});Vr(t,a);const c=k();return c&&(Ce(c)&&a instanceof W&&(t instanceof W&&t.dropReason?(a.dropReason=t.dropReason,c.recordDroppedEvent(t.dropReason,"span")):i||(a.dropReason="sample_rate",c.recordDroppedEvent("sample_rate","span"))),c.emit("spanStart",a),n.endTimestamp&&(c.emit("spanEnd",a),c.emit("afterSpanEnd",a))),a}function is(t,e){if(e)return e;if(e===null)return;const n=He(t);if(!n)return;const r=k();return(r?r.getOptions():{}).parentSpanIsAlwaysRootSpan?L(n):n}function Ro(t){return t!==void 0?e=>ns(t,e):e=>e()}function Co(t,e){var r;const n=t==null?void 0:t.getOptions().ignoreSpans;return!t||!Ce(t)||!(n!=null&&n.length)?!1:ze({description:e.name||"",op:((r=e.attributes)==null?void 0:r[Be])||e.op,attributes:e.attributes},n)}function Po(t){return t instanceof W&&t.dropReason==="ignored"}function _n(t){return t.getScopeData().sdkProcessingMetadata[ko]===!0}function xo(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;No(t,e),r&&Mo(t,r),Fo(t,n),Do(t,s),Oo(t,i)}function Zn(t,e){const{extra:n,tags:r,attributes:s,user:i,contexts:o,level:a,sdkProcessingMetadata:c,breadcrumbs:u,fingerprint:p,eventProcessors:f,attachments:h,propagationContext:d,transactionName:_,span:b}=e;de(t,"extra",n),de(t,"tags",r),de(t,"attributes",s),de(t,"user",i),de(t,"contexts",o),t.sdkProcessingMetadata=Ae(t.sdkProcessingMetadata,c,2),a&&(t.level=a),_&&(t.transactionName=_),b&&(t.span=b),u.length&&(t.breadcrumbs=[...t.breadcrumbs,...u]),p.length&&(t.fingerprint=[...t.fingerprint,...p]),f.length&&(t.eventProcessors=[...t.eventProcessors,...f]),h.length&&(t.attachments=[...t.attachments,...h]),t.propagationContext=l(l({},t.propagationContext),d)}function de(t,e,n){t[e]=Ae(t[e],n,1)}function os(t,e){const n=Ai().getScopeData();return t&&Zn(n,t.getScopeData()),e&&Zn(n,e.getScopeData()),n}function No(t,e){const{extra:n,tags:r,user:s,contexts:i,level:o,transactionName:a}=e;Object.keys(n).length&&(t.extra=l(l({},n),t.extra)),Object.keys(r).length&&(t.tags=l(l({},r),t.tags)),Object.keys(s).length&&(t.user=l(l({},s),t.user)),Object.keys(i).length&&(t.contexts=l(l({},i),t.contexts)),o&&(t.level=o),a&&t.type!=="transaction"&&(t.transaction=a)}function Do(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function Oo(t,e){t.sdkProcessingMetadata=l(l({},t.sdkProcessingMetadata),e)}function Mo(t,e){t.contexts=l({trace:Vi(e)},t.contexts),t.sdkProcessingMetadata=l({dynamicSamplingContext:ne(e)},t.sdkProcessingMetadata);const n=L(e),r=x(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function Fo(t,e){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint.length||delete t.fingerprint}const Ct=0,Qn=1,er=2;function mn(t){return new Te(e=>{e(t)})}function gn(t){return new Te((e,n)=>{n(t)})}class Te{constructor(e){this._state=Ct,this._handlers=[],this._runExecutor(e)}then(e,n){return new Te((r,s)=>{this._handlers.push([!1,i=>{if(!e)r(i);else try{r(e(i))}catch(o){s(o)}},i=>{if(!n)s(i);else try{r(n(i))}catch(o){s(o)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new Te((n,r)=>{let s,i;return this.then(o=>{i=!1,s=o,e&&e()},o=>{i=!0,s=o,e&&e()}).then(()=>{if(i){r(s);return}n(s)})})}_executeHandlers(){if(this._state===Ct)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===Qn&&n[1](this._value),this._state===er&&n[2](this._value),n[0]=!0)})}_runExecutor(e){const n=(i,o)=>{if(this._state===Ct){if(ce(o)){o.then(r,s);return}this._state=i,this._value=o,this._executeHandlers()}},r=i=>{n(Qn,i)},s=i=>{n(er,i)};try{e(r,s)}catch(i){s(i)}}}function Lo(t,e,n,r=0){try{const s=Zt(e,n,t,r);return ce(s)?s:mn(s)}catch(s){return gn(s)}}function Zt(t,e,n,r){const s=n[r];if(!t||!s)return t;const i=s(l({},t),e);return g&&i===null&&m.log(`Event processor "${s.id||"?"}" dropped event`),ce(i)?i.then(o=>Zt(o,e,n,r+1)):Zt(i,e,n,r+1)}let U,tr,nr,z;function $o(t){const e=P._sentryDebugIds,n=P._debugIds;if(!e&&!n)return{};const r=e?Object.keys(e):[],s=n?Object.keys(n):[];if(z&&r.length===tr&&s.length===nr)return z;tr=r.length,nr=s.length,z={},U||(U={});const i=(o,a)=>{for(const c of o){const u=a[c],p=U==null?void 0:U[c];if(p&&z&&u)z[p[0]]=u,U&&(U[c]=[p[0],u]);else if(u){const f=t(c);for(let h=f.length-1;h>=0;h--){const d=f[h],_=d==null?void 0:d.filename;if(_&&z&&U){z[_]=u,U[c]=[_,u];break}}}}};return e&&i(r,e),n&&i(s,n),z}function Ho(t,e,n,r,s,i){const{normalizeDepth:o=3,normalizeMaxBreadth:a=1e3}=t,c=E(l({},e),{event_id:e.event_id||n.event_id||M(),timestamp:e.timestamp||ke()}),u=n.integrations||t.integrations.map(w=>w.name);jo(c,t),zo(c,u),s&&s.emit("applyFrameMetadata",e),e.type===void 0&&Bo(c,t.stackParser);const p=Wo(r,n.captureContext);n.mechanism&&pi(c,n.mechanism);const f=s?s.getEventProcessors():[],h=os(i,p),d=[...n.attachments||[],...h.attachments];d.length&&(n.attachments=d),xo(c,h);const _=[...f,...h.eventProcessors];return(n.data&&n.data.__sentry__===!0?mn(c):Lo(_,c,n)).then(w=>(w&&Uo(w),typeof o=="number"&&o>0?qo(w,o,a):w))}function jo(t,e){var a,c;const{environment:n,release:r,dist:s,maxValueLength:i}=e;t.environment=t.environment||n||pn,!t.release&&r&&(t.release=r),!t.dist&&s&&(t.dist=s);const o=t.request;o!=null&&o.url&&i&&(o.url=zt(o.url,i)),i&&((c=(a=t.exception)==null?void 0:a.values)==null||c.forEach(u=>{u.value&&(u.value=zt(u.value,i))}))}function Bo(t,e){var r,s;const n=$o(e);(s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,a;(a=(o=i.stacktrace)==null?void 0:o.frames)==null||a.forEach(c=>{c.filename&&(c.debug_id=n[c.filename])})})}function Uo(t){var r,s;const e={};if((s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,a;(a=(o=i.stacktrace)==null?void 0:o.frames)==null||a.forEach(c=>{c.debug_id&&(c.abs_path?e[c.abs_path]=c.debug_id:c.filename&&(e[c.filename]=c.debug_id),delete c.debug_id)})}),Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const n=t.debug_meta.images;Object.entries(e).forEach(([i,o])=>{n.push({type:"sourcemap",code_file:i,debug_id:o})})}function zo(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function qo(t,e,n){var s,i;if(!t)return null;const r=l(l(l(l(l({},t),t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(o=>l(l({},o),o.data&&{data:q(o.data,e,n)}))}),t.user&&{user:q(t.user,e,n)}),t.contexts&&{contexts:q(t.contexts,e,n)}),t.extra&&{extra:q(t.extra,e,n)});return(s=t.contexts)!=null&&s.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=q(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(o=>l(l({},o),o.data&&{data:q(o.data,e,n)}))),(i=t.contexts)!=null&&i.flags&&r.contexts&&(r.contexts.flags=q(t.contexts.flags,3,n)),r}function Wo(t,e){if(!e)return t;const n=t?t.clone():new H;return n.update(e),n}function Go(t){if(t)return Ko(t)?{captureContext:t}:Yo(t)?{captureContext:t}:t}function Ko(t){return t instanceof H||typeof t=="function"}const Vo=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function Yo(t){return Object.keys(t).some(e=>Vo.includes(e))}function Z(t,e){return y().captureException(t,Go(e))}function Jo(t,e){const n=typeof e=="string"?e:void 0,r=typeof e!="string"?{captureContext:e}:void 0;return y().captureMessage(t,n,r)}function Xo(t,e){return y().captureEvent(t,e)}function $(t,e){A().setContext(t,e)}function Zo(t){A().setExtras(t)}function Qo(t,e){A().setExtra(t,e)}function ea(t){A().setTags(t)}function ta(t,e){A().setTag(t,e)}function na(t){A().setUser(t)}function ra(){return A().lastEventId()}function as(t){return D(this,null,function*(){const e=k();return e?e.flush(t):(g&&m.warn("Cannot flush events. No client defined."),Promise.resolve(!1))})}function sa(t){return D(this,null,function*(){const e=k();return e?e.close(t):(g&&m.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))})}function cs(){const t=k();return(t==null?void 0:t.getOptions().enabled)!==!1&&!!(t!=null&&t.getTransport())}function ia(t){A().addEventProcessor(t)}function us(t){const e=A(),{user:n}=os(e,y()),{userAgent:r}=P.navigator||{},s=Pr(l(l({user:n},r&&{userAgent:r}),t)),i=e.getSession();return(i==null?void 0:i.status)==="ok"&&K(i,{status:"exited"}),vt(),e.setSession(s),s}function vt(){const t=A(),n=y().getSession()||t.getSession();n&&xr(n),ls(),t.setSession()}function ls(){const t=A(),e=k(),n=t.getSession();n&&e&&e.captureSession(n)}function Qt(t=!1){if(t){vt();return}ls()}const oa="7";function aa(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function ca(t){return`${aa(t)}${t.projectId}/envelope/`}function ua(t,e){const n={sentry_version:oa};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}function la(t,e,n){return e||`${ca(t)}?${ua(t,n)}`}const rr=[];function fa(t,e){const n={};return e.forEach(r=>{r!=null&&r.beforeSetup&&r.beforeSetup(t)}),e.forEach(r=>{r&&fs(t,r,n)}),n}function sr(t,e){for(const n of e)n!=null&&n.afterAllSetup&&n.afterAllSetup(t)}function fs(t,e,n){if(n[e.name]){g&&m.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,!rr.includes(e.name)&&typeof e.setupOnce=="function"&&(e.setupOnce(),rr.push(e.name)),e.setup&&typeof e.setup=="function"&&e.setup(t),typeof e.preprocessEvent=="function"){const r=e.preprocessEvent.bind(e);t.on("preprocessEvent",(s,i)=>r(s,i,t))}if(typeof e.processEvent=="function"){const r=e.processEvent.bind(e),s=Object.assign((i,o)=>r(i,o,t),{id:e.name});t.addEventProcessor(s)}["processSpan","processSegmentSpan"].forEach(r=>{const s=e[r];typeof s=="function"&&t.on(r,i=>s.call(e,i,t))}),g&&m.log(`Integration installed: ${e.name}`)}function pa(t){const e=k();if(!e){g&&m.warn(`Cannot add integration "${t.name}" because no SDK Client is available.`);return}e.addIntegration(t)}function da(){return typeof __SENTRY_BROWSER_BUNDLE__!="undefined"&&!!__SENTRY_BROWSER_BUNDLE__}function ha(){return!da()&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]"}function yn(){return typeof window!="undefined"&&(!ha()||_a())}function _a(){const t=P.process;return(t==null?void 0:t.type)==="renderer"}function ma(t,e){const n=e?"auto":"never";return[{type:"log",item_count:t.length,content_type:"application/vnd.sentry.items.log+json"},E(l({version:2},yn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function ga(t,e,n,r,s){const i={};return e!=null&&e.sdk&&(i.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(i.dsn=fe(r)),J(i,[ma(t,s)])}function ir(t,e){var i;const n=(i=e!=null?e:ya(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=ga(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);ps().set(t,[]),t.emit("flushLogs"),t.sendEnvelope(s)}function ya(t){return ps().get(t)}function ps(){return ae("clientToLogBufferMap",()=>new WeakMap)}function Sa(t,e){const n=e?"auto":"never";return[{type:"trace_metric",item_count:t.length,content_type:"application/vnd.sentry.items.trace-metric+json"},E(l({version:2},yn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function ba(t,e,n,r,s){const i={};return e!=null&&e.sdk&&(i.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(i.dsn=fe(r)),J(i,[Sa(t,s)])}function Ea(t,e){var i;const n=(i=e!=null?e:Ta(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=ba(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);ds().set(t,[]),t.emit("flushMetrics"),t.sendEnvelope(s)}function Ta(t){return ds().get(t)}function ds(){return ae("clientToMetricBufferMap",()=>new WeakMap)}function va(t){const e={trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,name:t.description||"",start_timestamp:t.start_timestamp,end_timestamp:t.timestamp||t.start_timestamp,status:!t.status||t.status==="ok"||t.status==="cancelled"?"ok":"error",is_segment:!1,attributes:l({},t.data),links:t.links};return Qi(e)}function wa(t,e){var i,o,a;if(t.type!=="transaction"||!((i=t.spans)!=null&&i.length)||!((o=t.sdkProcessingMetadata)!=null&&o.hasGenAiSpans)||!e.getOptions().streamGenAiSpans||Ce(e))return;const n=[],r=[];for(const c of t.spans)(a=c.op)!=null&&a.startsWith("gen_ai.")?n.push(va(c)):r.push(c);if(n.length===0)return;t.spans=r;const s=e.getDataCollectionOptions().userInfo?"auto":"never";return[{type:"span",item_count:n.length,content_type:"application/vnd.sentry.items.span.v2+json"},E(l({version:2},yn()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}}),{items:n})]}function Sn(t){return typeof t=="object"&&typeof t.unref=="function"&&t.unref(),t}const bn=Symbol.for("SentryBufferFullError");function hs(t=100){const e=new Set;function n(){return e.size<t}function r(o){e.delete(o)}function s(o){if(!n())return gn(bn);const a=o();return e.add(a),a.then(()=>r(a),()=>r(a)),a}function i(o){if(!e.size)return mn(!0);const a=Promise.allSettled(Array.from(e)).then(()=>!0);if(!o)return a;const c=[a,new Promise(u=>Sn(setTimeout(()=>u(!1),o)))];return Promise.race(c)}return{get $(){return Array.from(e)},add:s,drain:i}}const Ia=60*1e3;function _s(t,e=St()){const n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;const r=Date.parse(`${t}`);return isNaN(r)?Ia:r-e}function ka(t,e){return t[e]||t.all||0}function Aa(t,e,n=St()){return ka(t,e)>n}function Ra(t,{statusCode:e,headers:n},r=St()){const s=l({},t),i=n==null?void 0:n["x-sentry-rate-limits"],o=n==null?void 0:n["retry-after"];if(i)for(const a of i.trim().split(",")){const[c,u,,,p]=a.split(":",5),f=parseInt(c,10),h=(isNaN(f)?60:f)*1e3;if(!u)s.all=r+h;else for(const d of u.split(";"))d==="metric_bucket"?(!p||p.split(";").includes("custom"))&&(s[d]=r+h):s[d]=r+h}else o?s.all=r+_s(o,r):e===429&&(s.all=r+60*1e3);return s}const ms=64;function Ca(t,e,n=hs(t.bufferSize||ms)){let r={};const s=o=>n.drain(o);function i(o){const a=[];if(Yt(o,(f,h)=>{const d=Gn(h);Aa(r,d)?t.recordDroppedEvent("ratelimit_backoff",d):a.push(f)}),a.length===0)return Promise.resolve({});const c=J(o[0],a),u=f=>{if(Jt(c,["client_report"])){g&&m.warn(`Dropping client report. Will not send outcomes (reason: ${f}).`);return}Yt(c,(h,d)=>{t.recordDroppedEvent(f,Gn(d))})},p=()=>e({body:co(c)}).then(f=>f.statusCode===413?(g&&m.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),u("send_error"),f):(g&&f.statusCode!==void 0&&(f.statusCode<200||f.statusCode>=300)&&m.warn(`Sentry responded with status code ${f.statusCode} to sent event.`),r=Ra(r,f),f),f=>{throw u("network_error"),g&&m.error("Encountered error running transport request:",f),f});return n.add(p).then(f=>f,f=>{if(f===bn)return g&&m.error("Skipped sending event because buffer is full."),u("queue_overflow"),Promise.resolve({});throw f})}return{send:i,flush:s}}function Pa(t,e,n){const r=[{type:"client_report"},{timestamp:ke(),discarded_events:t}];return J(e?{dsn:e}:{},[r])}function xa(t){const e=[];t.message&&e.push(t.message);try{const n=t.exception.values[t.exception.values.length-1];n!=null&&n.value&&(e.push(n.value),n.type&&e.push(`${n.type}: ${n.value}`))}catch(n){}return e}function Na(t){var c,u,p;const{trace_id:e,parent_span_id:n,span_id:r,status:s,origin:i,data:o,op:a}=(u=(c=t.contexts)==null?void 0:c.trace)!=null?u:{};return{data:o!=null?o:{},description:t.transaction,op:a,parent_span_id:n,span_id:r!=null?r:"",start_timestamp:(p=t.start_timestamp)!=null?p:0,status:s,timestamp:t.timestamp,trace_id:e!=null?e:"",origin:i,profile_id:o==null?void 0:o[cn],exclusive_time:o==null?void 0:o[un],measurements:t.measurements,is_segment:!0}}function Da(t){return{type:"transaction",timestamp:t.timestamp,start_timestamp:t.start_timestamp,transaction:t.description,contexts:{trace:{trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,op:t.op,status:t.status,origin:t.origin,data:l(l(l({},t.data),t.profile_id&&{[cn]:t.profile_id}),t.exclusive_time&&{[un]:t.exclusive_time})}},measurements:t.measurements}}const De=["forwarded","-ip","remote-","via","-user"];function Oa(t){return t===!0?{userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:5}:{userInfo:!1,cookies:{deny:De},httpHeaders:{request:{deny:De},response:{deny:De}},httpBodies:[],queryParams:{deny:De},genAI:{inputs:!1,outputs:!1},stackFrameVariables:!0,frameContextLines:5}}const Ma={userInfo:!1,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:[],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:5};function Fa(t){var r,s,i,o,a,c,u,p,f,h,d,_,b,T,w;const e=t.dataCollection!=null?Ma:Oa(t.sendDefaultPii),n=(r=t.dataCollection)!=null?r:{};return{userInfo:(s=n.userInfo)!=null?s:e.userInfo,cookies:(i=n.cookies)!=null?i:e.cookies,httpHeaders:{request:(a=(o=n.httpHeaders)==null?void 0:o.request)!=null?a:e.httpHeaders.request,response:(u=(c=n.httpHeaders)==null?void 0:c.response)!=null?u:e.httpHeaders.response},httpBodies:(p=n.httpBodies)!=null?p:e.httpBodies,queryParams:(f=n.queryParams)!=null?f:e.queryParams,genAI:{inputs:(d=(h=n.genAI)==null?void 0:h.inputs)!=null?d:e.genAI.inputs,outputs:(b=(_=n.genAI)==null?void 0:_.outputs)!=null?b:e.genAI.outputs},stackFrameVariables:(T=n.stackFrameVariables)!=null?T:e.stackFrameVariables,frameContextLines:(w=n.frameContextLines)!=null?w:e.frameContextLines}}const or="Not capturing exception because it's already been captured.",ar="Discarded session because of missing or non-string release",gs=Symbol.for("SentryInternalError"),ys=Symbol.for("SentryDoNotSendEventError"),La=5e3;function Me(t){return{message:t,[gs]:!0}}function Pt(t){return{message:t,[ys]:!0}}function cr(t){return!!t&&typeof t=="object"&&gs in t}function ur(t){return!!t&&typeof t=="object"&&ys in t}function lr(t,e,n,r,s){let i=0,o,a=!1;t.on(n,()=>{i=0,clearTimeout(o),a=!1}),t.on(e,c=>{var u;if(i+=r(c),i>=8e5)s(t);else if(!a){const p=(u=t.getOptions()._flushInterval)!=null?u:La;p>0&&(a=!0,o=Sn(setTimeout(()=>{s(t)},p)))}}),t.on("flush",()=>{s(t)})}class $a{constructor(e){var r,s,i,o,a,c,u;if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=hs((s=(r=e.transportOptions)==null?void 0:r.bufferSize)!=null?s:ms),this._dataCollection=Fa(e),e.dsn?this._dsn=Wi(e.dsn):g&&m.warn("No DSN provided, client will not send events."),this._dsn){const p=la(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport(E(l({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this)},e.transportOptions),{url:p}))}this._options.enableLogs=(o=this._options.enableLogs)!=null?o:(i=this._options._experiments)==null?void 0:i.enableLogs,this._options.enableLogs&&lr(this,"afterCaptureLog","flushLogs",Ua,ir),((u=(c=this._options.enableMetrics)!=null?c:(a=this._options._experiments)==null?void 0:a.enableMetrics)!=null?u:!0)&&lr(this,"afterCaptureMetric","flushMetrics",Ba,Ea)}captureException(e,n,r){const s=M();if(Fn(e))return g&&m.log(or),s;const i=l({event_id:s},n);return this._process(()=>this.eventFromException(e,i).then(o=>this._captureEvent(o,i,r)).then(o=>o),"error"),i.event_id}captureMessage(e,n,r,s){const i=l({event_id:M()},r),o=kr(e)?e:String(e),a=Ar(e),c=a?this.eventFromMessage(o,n,i):this.eventFromException(e,i);return this._process(()=>c.then(u=>this._captureEvent(u,i,s)),a?"unknown":"error"),i.event_id}captureEvent(e,n,r){const s=M();if(n!=null&&n.originalException&&Fn(n.originalException))return g&&m.log(or),s;const i=l({event_id:s},n),o=e.sdkProcessingMetadata||{},a=o.capturedSpanScope,c=o.capturedSpanIsolationScope,u=fr(e.type);return this._process(()=>this._captureEvent(e,i,a||r,c),u),i.event_id}captureSession(e){this.sendSession(e),K(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getDataCollectionOptions(){return this._dataCollection}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){return D(this,null,function*(){const n=this._transport;if(this.emit("flush"),!n)return!0;const r=yield this._isClientDoneProcessing(e),s=yield n.flush(e);return r&&s})}close(e){return D(this,null,function*(){ir(this);const n=yield this.flush(e);return this.getOptions().enabled=!1,this.emit("close"),n})}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}getIntegrationNames(){return Object.keys(this._integrations)}addIntegration(e){const n=this._integrations[e.name];!n&&e.beforeSetup&&e.beforeSetup(this),fs(this,e,this._integrations),n||sr(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);const r=wa(e,this);let s=go(e,this._dsn,this._options._metadata,this._options.tunnel);for(const i of n.attachments||[])s=Wn(s,fo(i));r&&(s=Wn(s,r)),this.sendEnvelope(s).then(i=>this.emit("afterSendEvent",e,i))}sendSession(e){const{release:n,environment:r=pn}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!n){g&&m.warn(ar);return}i.release=i.release||n,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!n){g&&m.warn(ar);return}e.release=e.release||n,e.environment=e.environment||r}this.emit("beforeSendSession",e);const s=mo(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(s)}recordDroppedEvent(e,n,r=1){if(this._options.sendClientReports){const s=`${e}:${n}`;g&&m.log(`Recording outcome: "${s}"${r>1?` (${r} times)`:""}`),this._outcomes[s]=(this._outcomes[s]||0)+r}}on(e,n){const r=this._hooks[e]=this._hooks[e]||new Set,s=(...i)=>n(...i);return r.add(s),()=>{r.delete(s)}}emit(e,...n){const r=this._hooks[e];r&&r.forEach(s=>s(...n))}sendEnvelope(e){return D(this,null,function*(){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)try{return yield this._transport.send(e)}catch(n){return g&&m.error("Error while sending envelope:",n),{}}return g&&m.error("Transport disabled"),{}})}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=fa(this,e),sr(this,e)}_updateSessionFromEvent(e,n){var c,u;let r=n.level==="fatal",s=!1;const i=(c=n.exception)==null?void 0:c.values;if(i){s=!0,r=!1;for(const p of i)if(((u=p.mechanism)==null?void 0:u.handled)===!1){r=!0;break}}const o=e.status==="ok";(o&&e.errors===0||o&&r)&&(K(e,E(l({},r&&{status:"crashed"}),{errors:e.errors||Number(s||r)})),this.captureSession(e))}_isClientDoneProcessing(e){return D(this,null,function*(){let n=0;for(;!e||n<e;){if(yield new Promise(r=>setTimeout(r,1)),!this._numProcessing)return!0;n++}return!1})}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,n,r,s){const i=this.getOptions(),o=this.getIntegrationNames();return!n.integrations&&o.length&&(n.integrations=o),this.emit("preprocessEvent",e,n),e.type||s.setLastEventId(e.event_id||n.event_id),Ho(i,e,n,r,this,s).then(a=>{var u;if(a===null)return a;this.emit("postprocessEvent",a,n),a.contexts=l({trace:l(l({},(u=a.contexts)==null?void 0:u.trace),Ri(r))},a.contexts);const c=Zr(this,r);return a.sdkProcessingMetadata=l({dynamicSamplingContext:c},a.sdkProcessingMetadata),a})}_captureEvent(e,n={},r=y(),s=A()){return g&&en(e)&&m.log(`Captured error event \`${xa(e)[0]||"<unknown>"}\``),this._processEvent(e,n,r,s).then(i=>i.event_id,i=>{g&&(ur(i)?m.log(i.message):cr(i)?m.warn(i.message):m.warn(i))})}_processEvent(e,n,r,s){const i=this.getOptions(),{sampleRate:o}=i,a=Ss(e),c=en(e),p=`before send for type \`${e.type||"error"}\``,f=typeof o=="undefined"?void 0:ln(o);if(c&&typeof f=="number"&&Le()>f)return this.recordDroppedEvent("sample_rate","error"),gn(Pt(`Discarding event because it's not included in the random sample (sampling rate = ${o})`));const h=fr(e.type);return this._prepareEvent(e,n,r,s).then(d=>{var T;if(d===null)throw this.recordDroppedEvent("event_processor",h),Pt("An event processor returned `null`, will not send event.");if(((T=n.data)==null?void 0:T.__sentry__)===!0)return d;const b=ja(this,i,d,n);return Ha(b,p)}).then(d=>{var T;if(d===null){if(this.recordDroppedEvent("before_send",h),a){const j=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",j)}throw Pt(`${p} returned \`null\`, will not send event.`)}const _=r.getSession()||s.getSession();if(c&&_&&this._updateSessionFromEvent(_,d),a){const w=((T=d.sdkProcessingMetadata)==null?void 0:T.spanCountBeforeProcessing)||0,j=d.spans?d.spans.length:0,F=w-j;F>0&&this.recordDroppedEvent("before_send","span",F)}const b=d.transaction_info;if(a&&b&&d.transaction!==e.transaction){const w="custom";d.transaction_info=E(l({},b),{source:w})}return this.sendEvent(d,n),d}).then(null,d=>{throw ur(d)||cr(d)?d:(this.captureException(d,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:d}),Me(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
7
- Reason: ${d}`))})}_process(e,n){this._numProcessing++,this._promiseBuffer.add(e).then(r=>(this._numProcessing--,r),r=>(this._numProcessing--,r===bn&&this.recordDroppedEvent("queue_overflow",n),r))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([n,r])=>{const[s,i]=n.split(":");return{reason:s,category:i,quantity:r}})}_flushOutcomes(){g&&m.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){g&&m.log("No outcomes to send");return}if(!this._dsn){g&&m.log("No dsn provided, will not send outcomes");return}g&&m.log("Sending outcomes:",e);const n=Pa(e,this._options.tunnel&&fe(this._dsn));this.sendEnvelope(n)}}function fr(t){return t==="replay_event"?"replay":t||"error"}function Ha(t,e){const n=`${e} must return \`null\` or a valid event.`;if(ce(t))return t.then(r=>{if(!Bt(r)&&r!==null)throw Me(n);return r},r=>{throw Me(`${e} rejected with ${r}`)});if(!Bt(t)&&t!==null)throw Me(n);return t}function ja(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,ignoreSpans:o}=e,a=!Qr(e.beforeSendSpan)&&e.beforeSendSpan;let c=n;if(en(c)&&s)return s(c,r);if(Ss(c)){if(a||o){const u=Na(c);if(o!=null&&o.length&&ze({description:u.description,op:u.op,attributes:u.data},o))return null;if(a){const p=a(u);p?c=Ae(n,Da(p)):Vt()}if(c.spans){const p=[],f=c.spans;for(const d of f){if(o!=null&&o.length&&ze({description:d.description,op:d.op,attributes:d.data},o)){oo(f,d);continue}if(a){const _=a(d);_?p.push(_):(Vt(),p.push(d))}else p.push(d)}const h=c.spans.length-p.length;h&&t.recordDroppedEvent("before_send","span",h),c.spans=p}}if(i){if(c.spans){const u=c.spans.length;c.sdkProcessingMetadata=E(l({},n.sdkProcessingMetadata),{spanCountBeforeProcessing:u})}return i(c,r)}}return c}function en(t){return t.type===void 0}function Ss(t){return t.type==="transaction"}function Ba(t){let e=0;return t.name&&(e+=t.name.length*2),e+=8,e+bs(t.attributes)}function Ua(t){let e=0;return t.message&&(e+=t.message.length*2),e+bs(t.attributes)}function bs(t){if(!t)return 0;let e=0;return Object.values(t).forEach(n=>{Array.isArray(n)?e+=n.length*pr(n[0]):Ar(n)?e+=pr(n):e+=100}),e}function pr(t){return typeof t=="string"?t.length*2:typeof t=="number"?8:typeof t=="boolean"?4:0}function za(t,e){e.debug===!0&&(g?m.enable():Ie(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),y().update(e.initialScope);const r=new t(e);return qa(r),r.init(),r}function qa(t){y().setClient(t)}const xt=100,Nt=5e3,Wa=36e5;function Ga(t){function e(...n){g&&m.log("[Offline]:",...n)}return n=>{const r=t(n);if(!n.createStore)throw new Error("No `createStore` function was provided");const s=n.createStore(n);let i=Nt,o;function a(f,h,d){return Jt(f,["client_report"])?!1:n.shouldStore?n.shouldStore(f,h,d):!0}function c(f){o&&clearTimeout(o),o=Sn(setTimeout(()=>D(null,null,function*(){o=void 0;const h=yield s.shift();h&&(e("Attempting to send previously queued event"),h[0].sent_at=new Date().toISOString(),p(h,!0).catch(d=>{e("Failed to retry sending",d)}))}),f))}function u(){o||(c(i),i=Math.min(i*2,Wa))}function p(f,h=!1){return D(this,null,function*(){var d,_;if(!h&&Jt(f,["replay_event","replay_recording"]))return yield s.push(f),c(xt),{};try{if(n.shouldSend&&(yield n.shouldSend(f))===!1)throw new Error("Envelope not sent because `shouldSend` callback returned false");const b=yield r.send(f);let T=xt;if(b){if((d=b.headers)!=null&&d["retry-after"])T=_s(b.headers["retry-after"]);else if((_=b.headers)!=null&&_["x-sentry-rate-limits"])T=6e4;else if((b.statusCode||0)>=400)return b}return c(T),i=Nt,b}catch(b){if(yield a(f,b,i))return h?yield s.unshift(f):yield s.push(f),u(),e("Error sending. Event queued.",b),{};throw b}})}return n.flushAtStartup&&u(),{send:p,flush:f=>(f===void 0&&(i=Nt,c(xt)),r.flush(f))}}}function Ka(t={}){const e=t.client||k();if(!cs()||!e)return{};const n=V(),r=le(n);if(r.getTraceData)return r.getTraceData(t);const s=t.scope||y(),i=t.span||Yr(),o=i?Yi(i):Va(s),a=i?ne(i):Zr(e,s),c=Mi(a);if(!Gi.test(o))return m.warn("Invalid sentry-trace data. Cannot generate trace data"),{};const p={"sentry-trace":o,baggage:c};return t.propagateTraceparent&&(p.traceparent=i?Ji(i):Ya(s)),p}function Va(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return zr(e,r,n)}function Ya(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return qr(e,r,n)}const Ja=100;function I(t,e){const n=k(),r=A();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=Ja}=n.getOptions();if(i<=0)return;const o=ke(),a=l({timestamp:o},t),c=s?Ie(()=>s(a,e)):a;c!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",c,e),r.addBreadcrumb(c,i))}function Xa(t,e){return t(e.stack||"",1)}function Za(t){return Ir(t)&&"__sentry_fetch_url_host__"in t&&typeof t.__sentry_fetch_url_host__=="string"}function Qa(t){return Za(t)?`${t.message} (${t.__sentry_fetch_url_host__})`:t.message}function ec(t,e){const n={type:e.name||e.constructor.name,value:Qa(e)},r=Xa(t,e);return r.length&&(n.stacktrace={frames:r}),n}const Fe="1.11.1",Es="sentry.javascript.miniapp",tc=/^\s*at\s+(?:(.+?)\s+\()?([^\s():]+):(\d+):(\d+)\)?$/,nc=/^\s*(?:([^@]*)@)?([^\s@:]+(?:\.[a-z]+)+):(\d+)(?::(\d+))?\s*$/,rc=/^\s*((?:pages|utils|components|subpackages|app-service|appservice)\/[^\s:]+):(\d+):(\d+)\s*$/;function re(t){if(!t)return 0;const e=parseInt(t,10);return isNaN(e)?0:e}function sc(t){const e=tc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||gt,in_app:En(r)},a=re(s),c=re(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function ic(t){const e=nc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||gt,in_app:En(r)},a=re(s),c=re(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function oc(t){const e=rc.exec(t);if(!e)return;const[,n,r,s]=e,i={filename:n||"<anonymous>",function:gt,in_app:En(n)},o=re(r),a=re(s);return o&&(i.lineno=o),a&&(i.colno=a),i}function En(t){return t?!(t.includes("sentry-miniapp")||t.includes("@sentry")||t.includes("WAService")||t.includes("WASubContext")||t.includes("aframeworkx")||t.includes("__dev__")):!0}const Ts=Ys([90,sc],[80,ic],[70,oc]),ac=()=>typeof window!="undefined"&&window!==null&&typeof document!="undefined"&&document!==null,cc=[{global:"wx",name:"wechat"},{global:"my",name:"alipay"},{global:"tt",name:"bytedance"},{global:"dd",name:"dingtalk"},{global:"qq",name:"qq"},{global:"swan",name:"swan"},{global:"ks",name:"kuaishou"}],vs=()=>{const t=globalThis;for(const e of cc){const n=t[e.global];if(typeof n=="object"&&n!==null)return{sdk:n,name:e.name}}return null},ws=()=>{const t=vs();if(!t)return ac()?console.warn(`[sentry-miniapp] 检测到当前运行在浏览器/H5 环境(如 uni-app H5、Taro H5)。
7
+ Reason: ${d}`))})}_process(e,n){this._numProcessing++,this._promiseBuffer.add(e).then(r=>(this._numProcessing--,r),r=>(this._numProcessing--,r===bn&&this.recordDroppedEvent("queue_overflow",n),r))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([n,r])=>{const[s,i]=n.split(":");return{reason:s,category:i,quantity:r}})}_flushOutcomes(){g&&m.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){g&&m.log("No outcomes to send");return}if(!this._dsn){g&&m.log("No dsn provided, will not send outcomes");return}g&&m.log("Sending outcomes:",e);const n=Pa(e,this._options.tunnel&&fe(this._dsn));this.sendEnvelope(n)}}function fr(t){return t==="replay_event"?"replay":t||"error"}function Ha(t,e){const n=`${e} must return \`null\` or a valid event.`;if(ce(t))return t.then(r=>{if(!Bt(r)&&r!==null)throw Me(n);return r},r=>{throw Me(`${e} rejected with ${r}`)});if(!Bt(t)&&t!==null)throw Me(n);return t}function ja(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,ignoreSpans:o}=e,a=!Qr(e.beforeSendSpan)&&e.beforeSendSpan;let c=n;if(en(c)&&s)return s(c,r);if(Ss(c)){if(a||o){const u=Na(c);if(o!=null&&o.length&&ze({description:u.description,op:u.op,attributes:u.data},o))return null;if(a){const p=a(u);p?c=Ae(n,Da(p)):Vt()}if(c.spans){const p=[],f=c.spans;for(const d of f){if(o!=null&&o.length&&ze({description:d.description,op:d.op,attributes:d.data},o)){oo(f,d);continue}if(a){const _=a(d);_?p.push(_):(Vt(),p.push(d))}else p.push(d)}const h=c.spans.length-p.length;h&&t.recordDroppedEvent("before_send","span",h),c.spans=p}}if(i){if(c.spans){const u=c.spans.length;c.sdkProcessingMetadata=E(l({},n.sdkProcessingMetadata),{spanCountBeforeProcessing:u})}return i(c,r)}}return c}function en(t){return t.type===void 0}function Ss(t){return t.type==="transaction"}function Ba(t){let e=0;return t.name&&(e+=t.name.length*2),e+=8,e+bs(t.attributes)}function Ua(t){let e=0;return t.message&&(e+=t.message.length*2),e+bs(t.attributes)}function bs(t){if(!t)return 0;let e=0;return Object.values(t).forEach(n=>{Array.isArray(n)?e+=n.length*pr(n[0]):Ar(n)?e+=pr(n):e+=100}),e}function pr(t){return typeof t=="string"?t.length*2:typeof t=="number"?8:typeof t=="boolean"?4:0}function za(t,e){e.debug===!0&&(g?m.enable():Ie(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),y().update(e.initialScope);const r=new t(e);return qa(r),r.init(),r}function qa(t){y().setClient(t)}const xt=100,Nt=5e3,Wa=36e5;function Ga(t){function e(...n){g&&m.log("[Offline]:",...n)}return n=>{const r=t(n);if(!n.createStore)throw new Error("No `createStore` function was provided");const s=n.createStore(n);let i=Nt,o;function a(f,h,d){return Jt(f,["client_report"])?!1:n.shouldStore?n.shouldStore(f,h,d):!0}function c(f){o&&clearTimeout(o),o=Sn(setTimeout(()=>D(null,null,function*(){o=void 0;const h=yield s.shift();h&&(e("Attempting to send previously queued event"),h[0].sent_at=new Date().toISOString(),p(h,!0).catch(d=>{e("Failed to retry sending",d)}))}),f))}function u(){o||(c(i),i=Math.min(i*2,Wa))}function p(f,h=!1){return D(this,null,function*(){var d,_;if(!h&&Jt(f,["replay_event","replay_recording"]))return yield s.push(f),c(xt),{};try{if(n.shouldSend&&(yield n.shouldSend(f))===!1)throw new Error("Envelope not sent because `shouldSend` callback returned false");const b=yield r.send(f);let T=xt;if(b){if((d=b.headers)!=null&&d["retry-after"])T=_s(b.headers["retry-after"]);else if((_=b.headers)!=null&&_["x-sentry-rate-limits"])T=6e4;else if((b.statusCode||0)>=400)return b}return c(T),i=Nt,b}catch(b){if(yield a(f,b,i))return h?yield s.unshift(f):yield s.push(f),u(),e("Error sending. Event queued.",b),{};throw b}})}return n.flushAtStartup&&u(),{send:p,flush:f=>(f===void 0&&(i=Nt,c(xt)),r.flush(f))}}}function Ka(t={}){const e=t.client||k();if(!cs()||!e)return{};const n=V(),r=le(n);if(r.getTraceData)return r.getTraceData(t);const s=t.scope||y(),i=t.span||Yr(),o=i?Yi(i):Va(s),a=i?ne(i):Zr(e,s),c=Mi(a);if(!Gi.test(o))return m.warn("Invalid sentry-trace data. Cannot generate trace data"),{};const p={"sentry-trace":o,baggage:c};return t.propagateTraceparent&&(p.traceparent=i?Ji(i):Ya(s)),p}function Va(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return zr(e,r,n)}function Ya(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return qr(e,r,n)}const Ja=100;function I(t,e){const n=k(),r=A();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=Ja}=n.getOptions();if(i<=0)return;const o=ke(),a=l({timestamp:o},t),c=s?Ie(()=>s(a,e)):a;c!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",c,e),r.addBreadcrumb(c,i))}function Xa(t,e){return t(e.stack||"",1)}function Za(t){return Ir(t)&&"__sentry_fetch_url_host__"in t&&typeof t.__sentry_fetch_url_host__=="string"}function Qa(t){return Za(t)?`${t.message} (${t.__sentry_fetch_url_host__})`:t.message}function ec(t,e){const n={type:e.name||e.constructor.name,value:Qa(e)},r=Xa(t,e);return r.length&&(n.stacktrace={frames:r}),n}const Fe="1.11.2",Es="sentry.javascript.miniapp",tc=/^\s*at\s+(?:(.+?)\s+\()?([^\s():]+):(\d+):(\d+)\)?$/,nc=/^\s*(?:([^@]*)@)?([^\s@:]+(?:\.[a-z]+)+):(\d+)(?::(\d+))?\s*$/,rc=/^\s*((?:pages|utils|components|subpackages|app-service|appservice)\/[^\s:]+):(\d+):(\d+)\s*$/;function re(t){if(!t)return 0;const e=parseInt(t,10);return isNaN(e)?0:e}function sc(t){const e=tc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||gt,in_app:En(r)},a=re(s),c=re(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function ic(t){const e=nc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||gt,in_app:En(r)},a=re(s),c=re(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function oc(t){const e=rc.exec(t);if(!e)return;const[,n,r,s]=e,i={filename:n||"<anonymous>",function:gt,in_app:En(n)},o=re(r),a=re(s);return o&&(i.lineno=o),a&&(i.colno=a),i}function En(t){return t?!(t.includes("sentry-miniapp")||t.includes("@sentry")||t.includes("WAService")||t.includes("WASubContext")||t.includes("aframeworkx")||t.includes("__dev__")):!0}const Ts=Ys([90,sc],[80,ic],[70,oc]),ac=()=>typeof window!="undefined"&&window!==null&&typeof document!="undefined"&&document!==null,cc=[{global:"wx",name:"wechat"},{global:"my",name:"alipay"},{global:"tt",name:"bytedance"},{global:"dd",name:"dingtalk"},{global:"qq",name:"qq"},{global:"swan",name:"swan"},{global:"ks",name:"kuaishou"}],vs=()=>{const t=globalThis;for(const e of cc){const n=t[e.global];if(typeof n=="object"&&n!==null)return{sdk:n,name:e.name}}return null},ws=()=>{const t=vs();if(!t)return ac()?console.warn(`[sentry-miniapp] 检测到当前运行在浏览器/H5 环境(如 uni-app H5、Taro H5)。
8
8
  本 SDK 仅适配各小程序平台,不支持浏览器原生信号(window.onerror、fetch/XHR 拦截、PerformanceObserver 等)。
9
9
  建议改用 Sentry 官方浏览器 SDK:@sentry/browser。
10
10
  若使用 uni-app/Taro,可结合条件编译按端引入:H5 用 @sentry/browser,小程序端用 sentry-miniapp。