forked from off-topic/apps.apple.com
3 lines
14 KiB
JavaScript
3 lines
14 KiB
JavaScript
import{g as M,s as z,m as V,i as W,l as U,S as X,f as w,e as G,a as J,r as $,c as Q,b as Z,d as x,G as ee,u as te,h as re,j as ne}from"./version~BNUm1OH-k3.js";var ae=Object.defineProperty,ie=Object.defineProperties,oe=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,C=(e,n,t)=>n in e?ae(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,h=(e,n)=>{for(var t in n||(n={}))se.call(n,t)&&C(e,t,n[t]);if(Y)for(var t of Y(n))ce.call(n,t)&&C(e,t,n[t]);return e},b=(e,n)=>ie(e,oe(n)),_e=30;function I(e,n,t=V(e.bufferSize||_e)){let a={};const o=i=>t.drain(i);function r(i){const c=[];if(w(i,(p,y)=>{const u=G(y);if(J(a,u)){const l=P(p,y);e.recordDroppedEvent("ratelimit_backoff",u,l)}else c.push(p)}),c.length===0)return $();const s=Q(i[0],c),f=p=>{w(s,(y,u)=>{const l=P(y,u);e.recordDroppedEvent(p,G(u),l)})},S=(e.getRequest||(p=>({body:Z(p,e.textEncoder)})))(s);if(!S)return $();const v=()=>n(S).then(p=>(p.statusCode!==void 0&&(p.statusCode<200||p.statusCode>=300)&&(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&U.warn("Sentry responded with status code ".concat(p.statusCode," to sent event.")),a=te(a,p),p),p=>{throw f("network_error"),p});return t.add(v).then(p=>p,p=>{if(p instanceof x)return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&U.error("Skipped sending event because buffer is full."),f("queue_overflow"),$();throw p})}return r.__sentry__baseTransport__=!0,{send:r,flush:o}}function P(e,n){if(!(n!=="event"&&n!=="transaction"))return Array.isArray(e)?e[1]:void 0}var E=ee,g=void 0;function pe(){if(g)return g;if(W(E.fetch))return g=E.fetch.bind(E);const e=E.document;let n=E.fetch;if(e&&typeof e.createElement=="function")try{const t=e.createElement("iframe");t.hidden=!0,e.head.appendChild(t);const a=t.contentWindow;a&&a.fetch&&(n=a.fetch),e.head.removeChild(t)}catch(t){(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&U.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",t)}return g=n.bind(E)}function fe(){g=void 0}function ue(e,n=pe()){let t=0,a=0;function o(r){const i=r.body.length;t+=i,a++;const c=h({body:r.body,method:"POST",referrerPolicy:"origin",headers:r.headers,keepalive:t<=6e4&&a<15},e.fetchOptions);try{return n(r.url,c).then(s=>(t-=i,a--,{statusCode:s.status,headers:{"x-sentry-rate-limits":s.headers.get("X-Sentry-Rate-Limits"),"retry-after":s.headers.get("Retry-After")}}))}catch(s){return fe(),t-=i,a--,re(s)}}return I(e,o)}var de=4;function le(e){function n(t){return new ne((a,o)=>{const r=new XMLHttpRequest;r.onerror=o,r.onreadystatechange=()=>{r.readyState===de&&a({statusCode:r.status,headers:{"x-sentry-rate-limits":r.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":r.getResponseHeader("Retry-After")}})},r.open("POST",t.url);for(const i in t.headers)Object.prototype.hasOwnProperty.call(t.headers,i)&&r.setRequestHeader(i,t.headers[i]);r.send(t.body)})}return I(e,n)}function he(e,n){const[t,a]=e;delete t.dsn;const o={_envelopeHeader:t,project:n.project,v:4};return a.map(r=>{const i=r[0].type;if(i!=="event"&&i!=="transaction")return b(h({},o),{_itemHeader:r[0],_debugLogs:['Items of type "'.concat(i,'" are not supported yet. Dropped the item.')]});const[c,s]=r;return h(b(h({},o),{_itemHeader:c}),s)})}function ye(){return navigator.userAgent===void 0||navigator.appVersion===void 0||navigator.plugins===void 0||navigator.languages===void 0||navigator.languages.length===0||navigator.language===""||navigator.webdriver||navigator.plugins.length===0||/HeadlessChrome/.test(navigator.userAgent)||/headless/i.test(navigator.appVersion)}function j(e){return e||(e="unknown"),"Version mismatch between the installed Sentry SDK version (".concat(e,") and supported SDK version (").concat(D,") by SentryKit. Make sure to use supported version of the Sentry SDK (").concat(D,").")}function L(e){return e!==D?(console.error("[SentryKit Versioning Error] ".concat(j(e)," All sent data will be discarded.")),!1):!0}function ve(){return L(X)}function me(e){var n;const t=(n=e[0].sdk)==null?void 0:n.version;return L(t)}var K="The correct way to use SentryKit is as follows:\n\nimport {createSentryConfig} from '@amp-metrics/sentrykit'\n\nSentry.init(createSentryConfig({\n // all your configs\n}))";function Ee(e){return e.__sentrykit_original_config=h({},e),e}function ge(){const e=M(),n=e.bindClient;e.bindClient=t=>{Se(t.getOptions()),n.call(e,t)}}function Se(e){var n,t;const a=(t=(n=e._metadata)==null?void 0:n.sdk)==null?void 0:t.version;if(a!==D)throw new Error("[SentryKit Initialization Error] ".concat(j(a)));const o=e.__sentrykit_original_config;if(!o)throw new Error("[SentryKit Initialization Error] Configuration has to be generated through `createSentryConfig` function. ".concat(K));for(const r in o)if(r!=="integrations"&&o[r]!==e[r])throw new Error("[SentryKit Initialization Error] Configuration generated through `createSentryConfig` function has been changed. ".concat(K))}var Re=console.log,H=!1,Te=()=>{H=!0},B=e=>(...n)=>{(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&H&&Re(e,...n)},d=B("[SentryKit Privacy rules]");function F(e,n,t){const a=t!=null&&t.path?t.path+".":"",o=r=>{const i=a+r,c=e[r],s=n({obj:e,key:r,value:c,path:i,parentContext:t});if(s==="remove")return s;c!==null&&typeof c=="object"&&F(c,n,{obj:e,key:r,value:c,path:i,parentContext:t})};if(Array.isArray(e))for(let r=0;r<e.length;r++)o(r.toString())==="remove"&&(e.splice(r,1),r--);else for(const r in e)o(r)==="remove"&&delete e[r]}var R=(e,n,t)=>(e.type==="url"||e.type==="url-query")&&typeof t.obj[t.key]!="string"||e.type==="timestamp"&&typeof t.obj[t.key]!="number"?!1:e.matchPath?typeof e.matchPath=="function"?e.matchPath({eventType:n,path:t.path,key:t.key,value:t.value}):e.matchPath.test(t.path):e.type==="url"||e.type==="url-query"?De(t):e.type==="timestamp"?$e(t):!0,k=(e,n,t,a,o)=>e.type!=="url-query"?!1:e.matchQueryName?typeof e.matchQueryName=="function"?e.matchQueryName({eventType:n,path:t.path,key:t.key,url:t.value,queryName:a,queryValue:o}):e.matchQueryName.test(a):!0,be=[e=>/^spans\.\d+\.data\.url$/.test(e.path)&&e.parentContext.obj.op==="http.client"&&(Object.defineProperty(e.obj,"_url",{enumerable:!1,value:e.value})||!0),e=>/^spans\.\d+\.description$/.test(e.path)&&e.obj.op==="http.client"&&e.obj.data&&e.obj.description==="".concat(e.obj.data.method," ").concat(e.obj.data._url||e.obj.data.url),e=>/^breadcrumbs\.\d+\.data\.url$/.test(e.path)&&(e.parentContext.obj.category==="fetch"||e.parentContext.obj.category==="xhr"),e=>/^breadcrumbs\.\d+\.data\.from$/.test(e.path)&&e.parentContext.obj.category==="navigation",e=>/^breadcrumbs\.\d+\.data\.to$/.test(e.path)&&e.parentContext.obj.category==="navigation",e=>/^request\.url$/.test(e.path),e=>/^request\.headers\.Referer$/.test(e.path)],De=e=>be.some(n=>n(e)),$e=e=>typeof e.value=="number"&&e.path.toLowerCase().endsWith("timestamp"),Ue=(e,n)=>{const t=e._itemHeader.type==="transaction"?"transaction":"error";return F(e,a=>{const{path:o,key:r,obj:i}=a;for(const[c,s]of n.entries())if(R(s,t,a)&&!("action"in s&&s.action==="keep")){if(s.type==="timestamp"){const f=i[r],_=typeof s.precision=="function"?s.precision({eventType:t,path:o,key:r,timestamp:f}):s.precision;typeof _=="number"?((typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&f!==_&&d('Setting timestamp to a new value of "'.concat(_,'" for path: "').concat(o,'"')),i[r]=_):_==="seconds"?((typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Reducing timestamp to "'.concat(_,'" for path: "').concat(o,'"')),i[r]=Math.round(f)):_==="minutes"&&((typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Reducing timestamp to "'.concat(_,'" for path: "').concat(o,'"')),i[r]=Math.round(f/60)*60)}else if(s.type==="url-query"){const f=i[r],[_,S=""]=f.split("?"),v=new URLSearchParams(S);[...v.entries()].forEach(([u,l])=>{if(k(s,t,a,u,l)){if(n.slice(c+1).some(m=>R(m,t,a)&&k(m,t,a,u,l))){(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Skipping the active rule as there is an overriding rule for the query "'.concat(u,'" in the url "').concat(f,'" in path "').concat(o,'".'));return}if(s.action==="remove")(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Removing query "'.concat(u,'" from the url "').concat(f,'" in the path: "').concat(o,'" (value was: "').concat(l,'")')),v.delete(u);else if(s.action==="replace"){const m=typeof s.replace=="function"?s.replace({key:r,path:o,url:f,queryName:u,queryValue:l,eventType:t}):s.replace;(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&m!==l&&d('Setting query "'.concat(u,'" in the url "').concat(f,'" to a new value of "').concat(m,'" for path: "').concat(o,'" (value was: "').concat(l,'")')),v.set(u,m)}}});const y=v.toString();i[r]=_+(y?"?".concat(y):"")}else if(s.type==="url"){if(n.slice(c+1).some(_=>R(_,t,a)&&_.type==="url")){(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Skipping the active rule as there is an overriding rule for the url "'.concat(i[r],'" in path "').concat(o,'".'));continue}if(s.action==="remove")return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Removing the url "'.concat(i[r],'" in the path: "').concat(o,'"')),"remove";if(s.action==="replace"){const _=typeof s.replace=="function"?s.replace({key:r,path:o,url:i[r],eventType:t}):s.replace;(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&_!==i[r]&&d('Setting the url"'.concat(i[r],'" to a new value of "').concat(_,'" for path: "').concat(o,'" (value was: "').concat(i[r],'")')),i[r]=_}}else if(s.type==="any"&&"action"in s){if(n.slice(c+1).some(_=>R(_,t,a)&&_.type==="any")){(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Skipping the active rule as there is an overriding rule for the path "'.concat(o,'".'));continue}if(s.action==="remove")return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&d('Removing the path "'.concat(o,'" (value was: "').concat(i[r],'")')),"remove";if(s.action==="replace"){const _=typeof s.replace=="function"?s.replace({key:r,path:o,value:i[r],eventType:t}):s.replace;(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&_!==i[r]&&d('Setting a new value of "'.concat(_,'" for path: "').concat(o,'" (value was: "').concat(i[r],'")')),i[r]=_}}}}),e};function Ne(e,n){const t=new URL(e);return t.pathname="/report/2/"+n,t.toString()}function Be(e){return e.getRequest=n=>{if(!me(n))return!1;const t=he(n,e.sentryKitConfig).map(r=>Ue(JSON.parse(JSON.stringify(r)),e.sentryKitConfig.privacyRules)),a=t[0]._itemHeader.type==="transaction"?"traces":"error";return{url:Ne(e.sentryKitConfig.ingestUrl,e.sentryKitConfig.topic[a]),body:JSON.stringify({events:t}),headers:{"Content-type":"application/json"}}},z()?ue(e):le(e)}var T=B("[SentryKit Privacy settings]");function we({allowQueryParams:e,allowExtra:n,allowTags:t,timestampPrecision:a}){const o=[];return t&&o.push({type:"any",matchPath:({path:r,key:i})=>{const c=r==="tags.".concat(i)&&t.includes(i);return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&c&&T('Keeping the tag "'.concat(i,'" for path: "').concat(r,'"')),c},action:"keep"}),n&&o.push({type:"any",matchPath:({path:r,key:i})=>{const c=r==="extra.".concat(i)&&n.includes(i);return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&c&&T('Keeping the extra "'.concat(i,'" for path: "').concat(r,'"')),c},action:"keep"}),e&&o.push({type:"url-query",matchQueryName:({url:r,queryName:i,path:c})=>{const f=(typeof e=="function"?e(r):e).includes(i);return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&f&&T('Keeping the query name "'.concat(i,'" for path: "').concat(c,'"')),f},action:"keep"}),a&&o.push({type:"timestamp",precision:({eventType:r,timestamp:i,path:c})=>r==="error"?((typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&T('Reducing timestamp to "'.concat(a,'" for path: "').concat(c,'"')),a):i}),o}var N=B("[SentryKit Config]"),D="7.57.0",q={prod:"prod",qa:"qa"},O={prod:"https://xp.apple.com",qa:"https://xp-qa.apple.com"},A=[{type:"any",matchPath:/tags\..+$/,action:"remove"},{type:"any",matchPath:/tags\.(http\.status_code|visibilitychange|effectiveConnectionType|connectionType|deviceMemory|hardwareConcurrency|lcp\..+)$/,action:"keep"},{type:"any",matchPath:/^extra\.[^.]+$/,action:"remove"},{type:"any",matchPath:/^extra\.arguments$/,action:"keep"},{type:"any",matchPath:/^user\.[^.]+$/,action:"remove"},{type:"url-query",action:"replace",replace:"REMOVED"}];function Ge(e){const n=typeof e.privacyRules=="function"?e.privacyRules(A):e.privacyRules===!1?[]:[...A,...e.privacyRules||[]];e.privacySettings&&n.push(...we(e.privacySettings));const t=b(h({transport:Be,ingestUrl:"",topic:"xp_amp_web_error_log",environment:"qa",filterHeadless:!0,maxBreadcrumbs:0,release:void 0,redactKeys:void 0,sampleRate:void 0,tracesSampleRate:void 0,tracesSampler:void 0},e),{privacyRules:n,dsn:"https://dsn@bypass/1",autoSessionTracking:!1,sendClientReports:!1,replaysSessionSampleRate:void 0,replaysOnErrorSampleRate:void 0});typeof t.topic=="string"&&(t.topic={error:t.topic,traces:""});const a=t;return a.transportOptions=b(h({},a.transportOptions),{sentryKitConfig:a}),a.ingestUrl||(a.ingestUrl=a.environment===q.prod?O.prod:O.qa),(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&N('Initialized with environment "'.concat(a.environment,'" and ingestUrl "').concat(a.ingestUrl,'".')),(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&N(a.topic.traces?'Tracing topic is set to "'.concat(a.topic.traces,'".'):"No tracing topic is set."),a}function Ye(e){const n=e.environment===q.prod&&e.filterHeadless&&ye();return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&n&&N("Events and transactions will not be sent to sentry."),{beforeSend:(t,a)=>n?null:e.beforeSend?e.beforeSend(t,a):t,beforeSendTransaction(t,a){return n?null:e.beforeSendTransaction?e.beforeSendTransaction(t,a):t},beforeBreadcrumb(t,a){return t.category==="console"?null:e.beforeBreadcrumb?e.beforeBreadcrumb(t,a):t}}}ve();(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&ge();function Ce(e){(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&(e!=null&&e.debug)&&Te();const n=Ge(e||{});if(!n.project)throw new Error("[SentryKit Configuration Error]: The required `project` field is not set.");const t=n.tracesSampleRate||n.tracesSampler,a=n.topic.traces;if(t&&!a)throw new Error("[SentryKit Configuration Error]: The `topic.traces` field is not set while trace sampling is configured.");if(a&&!t)throw new Error("[SentryKit Configuration Error]: Trace sampling is configured but `topic.traces` is not set.");const o=h(h({},n),Ye(n));return(typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__)&&Ee(o),o}var Pe={createSentryConfig:Ce},Oe=Pe;export{Pe as SentryKit,Ce as createSentryConfig,Oe as default};
|
|
//# sourceMappingURL=index~C16D7IckKX.js.map
|