@xcodleox/devinspector 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular.cjs +1 -1
- package/dist/angular.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +59 -23
- package/dist/index.d.ts +59 -23
- package/dist/index.js +1 -1
- package/dist/next.cjs +1 -1
- package/dist/next.js +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/react-native.cjs +1 -1
- package/dist/react-native.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/svelte.cjs +1 -1
- package/dist/svelte.d.cts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +1 -1
- package/dist/vanilla.cjs +1 -1
- package/dist/vanilla.global.js +1 -1
- package/dist/vanilla.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +1 -1
- package/package.json +3 -2
package/dist/angular.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var H=Object.create;var g=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var C=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),w=r=>{throw TypeError(r)};var z=(r,e,t)=>e in r?g(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _=(r,e)=>g(r,"name",{value:e,configurable:!0});var Y=(r,e)=>{for(var t in e)g(r,t,{get:e[t],enumerable:!0})},V=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of F(e))!L.call(r,s)&&s!==t&&g(r,s,{get:()=>e[s],enumerable:!(n=S(e,s))||n.enumerable});return r};var W=r=>V(g({},"__esModule",{value:!0}),r);var j=r=>[,,,H(r?.[C("metadata")]??null)],B=["class","method","getter","setter","accessor","field","value","get","set"],y=r=>r!==void 0&&typeof r!="function"?w("Function expected"):r,J=(r,e,t,n,s)=>({kind:B[r],name:e,metadata:n,addInitializer:o=>t._?w("Already initialized"):s.push(y(o||null))}),X=(r,e)=>z(e,C("metadata"),r[3]),$=(r,e,t,n)=>{for(var s=0,o=r[e>>1],c=o&&o.length;s<c;s++)e&1?o[s].call(t):n=o[s].call(t,n);return n},K=(r,e,t,n,s,o)=>{var c,a,d,l,m,i=e&7,I=!!(e&8),h=!!(e&16),v=i>3?r.length+1:i?I?1:2:0,D=B[i+5],k=i>3&&(r[v-1]=[]),Q=r[v]||(r[v]=[]),f=i&&(!h&&!I&&(s=s.prototype),i<5&&(i>3||!h)&&S(i<4?s:{get[t](){return q(this,o)},set[t](u){return U(this,o,u)}},t));i?h&&i<4&&_(o,(i>2?"set ":i>1?"get ":"")+t):_(s,t);for(var E=n.length-1;E>=0;E--)l=J(i,t,d={},r[3],Q),i&&(l.static=I,l.private=h,m=l.access={has:h?u=>Z(s,u):u=>t in u},i^3&&(m.get=h?u=>(i^1?q:ee)(u,s,i^4?o:f.get):u=>u[t]),i>2&&(m.set=h?(u,x)=>U(u,s,x,i^4?o:f.set):(u,x)=>u[t]=x)),a=(0,n[E])(i?i<4?h?o:f[D]:i>4?void 0:{get:f.get,set:f.set}:s,l),d._=1,i^4||a===void 0?y(a)&&(i>4?k.unshift(a):i?h?o=a:f[D]=a:s=a):typeof a!="object"||a===null?w("Object expected"):(y(c=a.get)&&(f.get=c),y(c=a.set)&&(f.set=c),y(c=a.init)&&k.unshift(c));return i||X(r,s),f&&g(s,t,f),h?i^4?o:f:s};var T=(r,e,t)=>e.has(r)||w("Cannot "+t),Z=(r,e)=>Object(e)!==e?w('Cannot use the "in" operator on this value'):r.has(e),q=(r,e,t)=>(T(r,e,"read from private field"),t?t.call(r):e.get(r));var U=(r,e,t,n)=>(T(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),ee=(r,e,t)=>(T(r,e,"access private method"),t);var ne={};Y(ne,{AuditAngularErrorHandler:()=>b,audit:()=>p,auditInterceptor:()=>re,devInspectorInterceptor:()=>N});module.exports=W(ne);var P=require("@angular/core"),G=require("rxjs/operators");var M=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.slowThresholdMs=300;this.breadcrumbs=[];this.maxBreadcrumbs=50;this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),e.release&&(this.release=e.release),typeof e.slowThresholdMs=="number"&&e.slowThresholdMs>=0&&(this.slowThresholdMs=e.slowThresholdMs),this.initialized=!0,this.listenGlobalErrors()}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}generateId(e){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`${e}_${crypto.randomUUID()}`}catch{}return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,12)}`}createRequestId(){return this.generateId("req")}createTraceId(){return this.generateId("trace")}createSpanId(){return this.generateId("span")}setUser(e){this.user=this.truncate(e,2e3)}clearUser(){this.user=void 0}getUser(){return this.user}addBreadcrumb(e){let t={...e,timestamp:new Date().toISOString()},n=this.truncate(t,2e3);this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}clearBreadcrumbs(){this.breadcrumbs=[]}getBreadcrumbs(){return[...this.breadcrumbs]}getContext(){return{environment:this.environment,release:this.release,user:this.user,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,timestamp:new Date().toISOString()}}captureRequest(e){let t=this.getContext(),n={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({environment:t.environment,timestamp:t.timestamp,route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0},5e3)};this.send(n)}captureDbQuery(e){let t=this.getContext(),n=e.operation?.trim()||"query",s=e.collection?.trim()||"Unknown",o={type:"db_query",message:`Database operation [${n}]`,stackTrace:"",url:e.url||(typeof window<"u"?window.location.href:""),browser:typeof navigator<"u"?navigator.userAgent:"",method:n,durationMs:e.durationMs,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({...e.metadata,collection:s,operation:n,durationMs:e.durationMs,environment:t.environment,timestamp:t.timestamp},5e3)};this.send(o)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=typeof e.ErrorUtils.getGlobalHandler=="function"?e.ErrorUtils.getGlobalHandler():void 0;e.ErrorUtils.setGlobalHandler((n,s)=>{let o=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(o,{type:"react_native_error",isFatal:!!s}),t&&t(n,s)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let s=n instanceof Error?n:new Error(String(n));this.captureError(s,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"){let s=e;if(n.has(s))return"[Circular Reference]";if(n.add(s),Array.isArray(e))return e.map(c=>this.truncate(c,t,n));let o={};for(let[c,a]of Object.entries(e))o[c]=this.truncate(a,t,n);return o}return e}captureError(e,t={}){let n=e?.message||"Erro Desconhecido",s=e?.stack||"",o=this.getContext(),c=t.requestId,a=t.traceId,d=t.spanId,l={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(s,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:c,traceId:a,spanId:d,environment:o.environment,release:o.release,user:o.user,breadcrumbs:o.breadcrumbs,metadata:this.truncate({...t,environment:o.environment,release:o.release,timestamp:o.timestamp},5e3)};this.send(l)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n=this.getContext(),s={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:t.requestId,traceId:t.traceId,spanId:t.spanId,environment:n.environment,release:n.release,user:n.user,breadcrumbs:n.breadcrumbs,metadata:this.truncate({...t,level:"info",environment:n.environment,release:n.release,timestamp:n.timestamp},5e3)};this.send(s)}async send(e){if(this.initialized&&!(!this.apiKey||this.apiKey==="PENDING_API_KEY"))try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},R="__DEVINSPECT_AUDIT_CORE_INSTANCE__",te=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[R]||(r[R]=new M),r[R]},p=te();var O,A;O=[(0,P.Injectable)()];var b=class{handleError(e){let t=e instanceof Error?e:new Error(String(e));p.captureError(t,{framework:"Angular",platform:typeof window<"u"?"browser":"server",url:typeof window<"u"?window.location.href:""}),console.error("[DevInspector Angular Error]:",e)}};A=j(null),b=K(A,0,"AuditAngularErrorHandler",O,b),$(A,1,b);var N=(r,e)=>{let t=r.urlWithParams||r.url||"";if(t&&p.isIngestUrl(t))return e(r);let n=p.createRequestId(),s=p.createTraceId(),o=p.createSpanId(),c=r;r&&typeof r.clone=="function"&&(c=r.clone({setHeaders:{"x-devinspector-request-id":n,"x-devinspector-trace-id":s,"x-devinspector-span-id":o}}));let a=typeof performance<"u"?performance.now():Date.now();return e(c).pipe((0,G.tap)({next:d=>{if(!(d&&typeof d=="object"&&"status"in d&&"clone"in d))return;let m=Math.round((typeof performance<"u"?performance.now():Date.now())-a),i=d.status;(i>=400||m>=300)&&p.captureRequest({method:r.method,url:t,statusCode:i,durationMs:m,route:r.url,requestId:n,traceId:s,spanId:o,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),p.addBreadcrumb({type:"http",message:`${r.method} ${t}`,metadata:{statusCode:i,durationMs:m,requestId:n,traceId:s,spanId:o}})},error:d=>{let l=Math.round((typeof performance<"u"?performance.now():Date.now())-a),m=Number(d?.status)||0;p.captureRequest({method:r.method,url:t,statusCode:m,durationMs:l,route:r.url,requestId:n,traceId:s,spanId:o,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),p.captureException(new Error(`HTTP Error ${m}: ${d?.message||d?.statusText||"Erro de rede no cliente"}`),{url:t,method:r.method,status:d?.status,statusText:d?.statusText,type:"angular_network_error",requestId:n,traceId:s,spanId:o}),p.addBreadcrumb({type:"http_error",message:`${r.method} ${t}`,metadata:{statusCode:m,durationMs:l,requestId:n,traceId:s,spanId:o,error:d?.message||d?.statusText||"Network Error"}})}}))},re=N;0&&(module.exports={AuditAngularErrorHandler,audit,auditInterceptor,devInspectorInterceptor});
|
|
1
|
+
"use strict";var ee=Object.create;var y=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var N=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),v=t=>{throw TypeError(t)};var ne=(t,e,r)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var q=(t,e)=>y(t,"name",{value:e,configurable:!0});var se=(t,e)=>{for(var r in e)y(t,r,{get:e[r],enumerable:!0})},ie=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of te(e))!re.call(t,n)&&n!==r&&y(t,n,{get:()=>e[n],enumerable:!(s=x(e,n))||s.enumerable});return t};var oe=t=>ie(y({},"__esModule",{value:!0}),t);var C=t=>[,,,ee(t?.[N("metadata")]??null)],O=["class","method","getter","setter","accessor","field","value","get","set"],E=t=>t!==void 0&&typeof t!="function"?v("Function expected"):t,ae=(t,e,r,s,n)=>({kind:O[t],name:e,metadata:s,addInitializer:i=>r._?v("Already initialized"):n.push(E(i||null))}),ue=(t,e)=>ne(e,N("metadata"),t[3]),B=(t,e,r,s)=>{for(var n=0,i=t[e>>1],a=i&&i.length;n<a;n++)e&1?i[n].call(r):s=i[n].call(r,s);return s},L=(t,e,r,s,n,i)=>{var a,u,d,h,l,o=e&7,T=!!(e&8),g=!!(e&16),M=o>3?t.length+1:o?T?1:2:0,D=O[o+5],k=o>3&&(t[M-1]=[]),Z=t[M]||(t[M]=[]),f=o&&(!g&&!T&&(n=n.prototype),o<5&&(o>3||!g)&&x(o<4?n:{get[r](){return P(this,i)},set[r](p){return Q(this,i,p)}},r));o?g&&o<4&&q(i,(o>2?"set ":o>1?"get ":"")+r):q(n,r);for(var R=s.length-1;R>=0;R--)h=ae(o,r,d={},t[3],Z),o&&(h.static=T,h.private=g,l=h.access={has:g?p=>de(n,p):p=>r in p},o^3&&(l.get=g?p=>(o^1?P:ce)(p,n,o^4?i:f.get):p=>p[r]),o>2&&(l.set=g?(p,U)=>Q(p,n,U,o^4?i:f.set):(p,U)=>p[r]=U)),u=(0,s[R])(o?o<4?g?i:f[D]:o>4?void 0:{get:f.get,set:f.set}:n,h),d._=1,o^4||u===void 0?E(u)&&(o>4?k.unshift(u):o?g?i=u:f[D]=u:n=u):typeof u!="object"||u===null?v("Object expected"):(E(a=u.get)&&(f.get=a),E(a=u.set)&&(f.set=a),E(a=u.init)&&k.unshift(a));return o||ue(t,n),f&&y(n,r,f),g?o^4?i:f:n};var S=(t,e,r)=>e.has(t)||v("Cannot "+r),de=(t,e)=>Object(e)!==e?v('Cannot use the "in" operator on this value'):t.has(e),P=(t,e,r)=>(S(t,e,"read from private field"),r?r.call(t):e.get(t));var Q=(t,e,r,s)=>(S(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),ce=(t,e,r)=>(S(t,e,"access private method"),r);var ge={};se(ge,{AuditAngularErrorHandler:()=>w,audit:()=>c,auditInterceptor:()=>he,devInspectorInterceptor:()=>Y});module.exports=oe(ge);var J=require("@angular/core"),W=require("rxjs/operators");var G="https://api.devinspector.com.br/api/ingest/track",z="https://api.devinspector.com.br/api/ingest/apm";var pe=["password","senha","token","authorization","auth","bearer","credit_card","creditcard","cartao","cvv","cpf","rg","secret","private_key","privatekey"];function me(t){let e=t.toLowerCase().replace(/[\s-]/g,"_");return pe.some(r=>e.includes(r))}function b(t,e=0,r=new WeakSet){if(t==null)return t;if(typeof t=="string")return t.length>1e4?`${t.slice(0,1e4)}...[truncated]`:t;if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="bigint")return String(t);if(typeof t=="function")return"[Function]";if(e>=6)return"[MaxDepth]";if(typeof t!="object")return String(t);if(r.has(t))return"[Circular]";r.add(t);try{if(Array.isArray(t))return t.slice(0,100).map(i=>b(i,e+1,r));let s=t,n={};for(let[i,a]of Object.entries(s)){if(me(i)){n[i]="[REDACTED]";continue}n[i]=b(a,e+1,r)}return n}finally{r.delete(t)}}function $(t){if(t instanceof Error)return t.message||"Erro desconhecido";if(typeof t=="string")return t||"Erro desconhecido";try{let e=b(t);return typeof e=="string"?e||"Erro desconhecido":JSON.stringify(e)||"Erro desconhecido"}catch{return"Erro desconhecido"}}function F(t){return t&&String(t).trim().toUpperCase()||void 0}function K(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.round(t)}function H(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.max(0,Math.round(t))}function le(t){return String(t??"").trim().slice(0,200)}function fe(t){let e=Number(t);if(!Number.isFinite(e))throw new Error("metricValue deve ser um n\xFAmero finito.");return e}function I(t){let e=typeof globalThis<"u"?globalThis.crypto:void 0;return e&&typeof e.randomUUID=="function"?`${t}-${e.randomUUID()}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,12)}`}function m(t){return b(t)}var A=class{constructor(){this.apiKey="";this.endpoint=G;this.apmEndpoint=z;this.environment="production";this.slowThresholdMs=300;this.requestTimeoutMs=1e4;this.breadcrumbs=[];this.initialized=!1;this.listenersAttached=!1;this.sendQueue=[];this.isProcessingQueue=!1;this.flushResolvers=[]}init(e){if(!e?.apiKey?.trim())throw new Error("DevInspector: apiKey \xE9 obrigat\xF3rio.");this.apiKey=e.apiKey.trim(),this.endpoint=e.endpoint?.trim()||G,this.apmEndpoint=e.apmEndpoint?.trim()||z,this.environment=e.environment?.trim()||"production",this.release=e.release?.trim()||void 0,this.slowThresholdMs=typeof e.slowThresholdMs=="number"&&Number.isFinite(e.slowThresholdMs)&&e.slowThresholdMs>=0?Math.round(e.slowThresholdMs):300,this.requestTimeoutMs=typeof e.requestTimeoutMs=="number"&&Number.isFinite(e.requestTimeoutMs)&&e.requestTimeoutMs>0?Math.round(e.requestTimeoutMs):1e4,this.initialized=!0,this.attachGlobalListeners(),this.processQueue()}getApiKey(){return this.apiKey}getEndpoint(){return this.endpoint}getApmEndpoint(){return this.apmEndpoint}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}getRequestTimeoutMs(){return this.requestTimeoutMs}isInitialized(){return this.initialized}setUser(e){this.user=e?b(e):void 0}getUser(){return this.user}clearUser(){this.user=void 0}addBreadcrumb(e){if(!e||!e.type?.trim())return;let r={timestamp:e.timestamp||new Date().toISOString(),type:e.type.trim().slice(0,200),message:e.message?.slice(0,1e4),metadata:e.metadata?b(e.metadata):void 0};this.breadcrumbs.push(r),this.breadcrumbs.length>50&&(this.breadcrumbs=this.breadcrumbs.slice(-50))}getBreadcrumbs(){return this.breadcrumbs.map(e=>m(e))}clearBreadcrumbs(){this.breadcrumbs=[]}getContext(){return{environment:this.environment,release:this.release,user:m(this.user),breadcrumbs:this.getBreadcrumbs()}}isIngestUrl(e){if(!e)return!1;try{let r=new URL(this.endpoint),s=new URL(this.apmEndpoint),n=new URL(e,r.origin),i=n.origin,a=n.pathname.replace(/\/$/,""),u=r.pathname.replace(/\/$/,""),d=s.pathname.replace(/\/$/,"");return i===r.origin&&a===u||i===s.origin&&a===d}catch{return e.includes(this.endpoint)||e.includes(this.apmEndpoint)}}createRequestId(){return I("req")}createTraceId(){return I("trace")}createSpanId(){return I("span")}captureRequest(e){let r=F(e.method)||"GET",s=String(e.url||"").trim();if(!s)return Promise.resolve();let n=K(e.statusCode)??0,i=H(e.durationMs)??0,a={...e.metadata||{},...e.route!==void 0?{route:e.route}:{},...e.dbQueriesCount!==void 0?{dbQueriesCount:e.dbQueriesCount}:{},...e.slowQueryMs!==void 0?{slowQueryMs:e.slowQueryMs}:{},timestamp:new Date().toISOString()};return this.sendApm({type:"request_metric",method:r,url:s,statusCode:n,durationMs:i,browser:e.userAgent,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:m(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:m(a)})}captureDbQuery(e){let r=String(e.operation||"").trim();if(!r)return Promise.resolve();let s=H(e.durationMs)??0,n={...e.metadata||{},operation:r,collection:e.collection||"Unknown",durationMs:s,timestamp:new Date().toISOString()};return this.sendApm({type:"db_query",message:`Database operation: ${r}`,url:e.url,method:"DB",durationMs:s,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:m(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:m(n)})}captureMetric(e,r,s={},n={}){let i=le(e);if(!i)return Promise.resolve();let a;try{a=fe(r)}catch{return Promise.resolve()}return this.sendApm({type:"custom_metric",metricName:i,metricValue:a,requestId:n.requestId,traceId:n.traceId,spanId:n.spanId,environment:this.environment,release:this.release,user:m(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:m({...s,timestamp:new Date().toISOString()})})}captureCustomMetric(e){return this.captureMetric(e.metricName,e.metricValue,e.metadata||{},{requestId:e.requestId,traceId:e.traceId,spanId:e.spanId})}captureError(e,r={}){let s=e?.message?.trim()||"Erro desconhecido",n={...r},i=F(n.method),a=K(n.statusCode??n.status),u=n.url!==void 0&&n.url!==null?String(n.url).trim():void 0;return delete n.method,delete n.statusCode,delete n.status,delete n.requestId,delete n.traceId,delete n.spanId,delete n.durationMs,this.sendError({type:"error",message:s,stackTrace:e?.stack||"",...u?{url:u}:{},...i?{method:i}:{},...a!==void 0?{statusCode:a}:{},environment:this.environment,release:this.release,user:m(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:m({...n,timestamp:new Date().toISOString()})})}captureException(e,r={}){let s=e instanceof Error?e:new Error($(e));return this.captureError(s,r)}captureMessage(e,r={}){let s=String(e||"").trim();return s?this.sendApm({type:"message",message:s.slice(0,1e4),environment:this.environment,release:this.release,user:m(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:m({...r,timestamp:new Date().toISOString()})}):Promise.resolve()}async flush(){if(!(this.sendQueue.length===0&&!this.isProcessingQueue))return new Promise(e=>{this.flushResolvers.push(e),this.processQueue()})}attachGlobalListeners(){if(this.listenersAttached||typeof globalThis>"u")return;this.listenersAttached=!0;let e=globalThis;if(typeof e.ErrorUtils<"u"){let r=e.ErrorUtils.getGlobalHandler?.();e.ErrorUtils.setGlobalHandler?.((s,n)=>{this.captureError(s,{platform:"react-native",fatal:n}).finally(()=>{typeof r=="function"&&r(s,n)})})}if(typeof window<"u"&&typeof window.addEventListener=="function"){window.addEventListener("error",r=>{let s=r.error instanceof Error?r.error:new Error(r.message||"Erro global");this.captureError(s,{url:r.filename||window.location.href,line:r.lineno,column:r.colno,platform:"browser"})}),window.addEventListener("unhandledrejection",r=>{let s=r.reason instanceof Error?r.reason:new Error($(r.reason));this.captureError(s,{platform:"browser",url:window.location.href})});return}typeof process<"u"&&typeof process.on=="function"&&(process.on("uncaughtException",r=>{this.captureError(r,{platform:"node"})}),process.on("unhandledRejection",r=>{this.captureException(r,{platform:"node"})}))}sendError(e){return this.enqueue(this.endpoint,e)}sendApm(e){return this.enqueue(this.apmEndpoint,e)}enqueue(e,r){if(!this.initialized||!this.apiKey)return Promise.resolve();let s={id:I("event"),endpoint:e,payload:m(r),resolve:()=>{}};return new Promise(n=>{s.resolve=n,this.sendQueue.push(s),this.processQueue()})}async processQueue(){if(!(this.isProcessingQueue||!this.initialized||!this.apiKey)){this.isProcessingQueue=!0;try{for(;this.sendQueue.length>0;){let e=this.sendQueue.shift();if(e)try{await this.sendToEndpoint(e.endpoint,e.payload)}finally{e.resolve()}}}finally{if(this.isProcessingQueue=!1,this.sendQueue.length===0){let e=this.flushResolvers.splice(0);for(let r of e)r()}this.sendQueue.length>0&&this.processQueue()}}}async sendToEndpoint(e,r){let s=typeof fetch=="function"?fetch:void 0;if(!s)return;let n=b(r),i,a;try{typeof AbortController<"u"&&(i=new AbortController,a=setTimeout(()=>{i?.abort()},this.requestTimeoutMs));let u=typeof window<"u"&&typeof window.document<"u",d={method:"POST",headers:{"content-type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(n),signal:i?.signal};if(u&&(d.keepalive=!0),!(await s(e,d)).ok)return}catch{return}finally{a!==void 0&&clearTimeout(a)}}},j="__DEVINSPECT_AUDIT_CORE_INSTANCE__",X=typeof globalThis<"u"?globalThis:{},c=X[j]||new A;X[j]=c;var V,_;V=[(0,J.Injectable)()];var w=class{handleError(e){let r=e instanceof Error?e:new Error(String(e));c.captureError(r,{framework:"Angular",platform:typeof window<"u"?"browser":"server",url:typeof window<"u"?window.location.href:""}),console.error("[DevInspector Angular Error]:",e)}};_=C(null),w=L(_,0,"AuditAngularErrorHandler",V,w),B(_,1,w);var Y=(t,e)=>{let r=t.urlWithParams||t.url||"";if(r&&c.isIngestUrl(r))return e(t);let s=c.createRequestId(),n=c.createTraceId(),i=c.createSpanId(),a=t;t&&typeof t.clone=="function"&&(a=t.clone({setHeaders:{"x-devinspector-request-id":s,"x-devinspector-trace-id":n,"x-devinspector-span-id":i}}));let u=typeof performance<"u"?performance.now():Date.now();return e(a).pipe((0,W.tap)({next:d=>{if(!(d&&typeof d=="object"&&"status"in d&&"clone"in d))return;let l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-u)),o=Number(d.status)||0;(o>=400||l>=c.getSlowThresholdMs())&&c.captureRequest({method:t.method||"GET",url:r,statusCode:o,durationMs:l,route:t.url,requestId:s,traceId:n,spanId:i,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),c.addBreadcrumb({type:"http",message:`${t.method||"GET"} ${r} `,metadata:{statusCode:o,durationMs:l,requestId:s,traceId:n,spanId:i}})},error:d=>{let h=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-u)),l=Number(d?.status)||0;c.captureRequest({method:t.method||"GET",url:r,statusCode:l,durationMs:h,route:t.url,requestId:s,traceId:n,spanId:i,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),c.captureException(new Error(`HTTP Error ${l}: ${d?.message||d?.statusText||"Erro de rede no cliente"} `),{url:r,method:t.method||"GET",status:d?.status,statusText:d?.statusText,type:"angular_network_error",requestId:s,traceId:n,spanId:i}),c.addBreadcrumb({type:"http_error",message:`${t.method||"GET"} ${r} `,metadata:{statusCode:l,durationMs:h,requestId:s,traceId:n,spanId:i,error:d?.message||d?.statusText||"Network Error"}})}}))},he=Y;0&&(module.exports={AuditAngularErrorHandler,audit,auditInterceptor,devInspectorInterceptor});
|
package/dist/angular.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var P=Object.create;var x=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var S=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),b=r=>{throw TypeError(r)};var N=(r,e,t)=>e in r?x(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _=(r,e)=>x(r,"name",{value:e,configurable:!0});var C=r=>[,,,P(r?.[S("metadata")]??null)],j=["class","method","getter","setter","accessor","field","value","get","set"],g=r=>r!==void 0&&typeof r!="function"?b("Function expected"):r,Q=(r,e,t,n,s)=>({kind:j[r],name:e,metadata:n,addInitializer:o=>t._?b("Already initialized"):s.push(g(o||null))}),H=(r,e)=>N(e,S("metadata"),r[3]),B=(r,e,t,n)=>{for(var s=0,o=r[e>>1],c=o&&o.length;s<c;s++)e&1?o[s].call(t):n=o[s].call(t,n);return n},$=(r,e,t,n,s,o)=>{var c,a,d,p,l,i=e&7,w=!!(e&8),h=!!(e&16),I=i>3?r.length+1:i?w?1:2:0,D=j[i+5],k=i>3&&(r[I-1]=[]),O=r[I]||(r[I]=[]),m=i&&(!h&&!w&&(s=s.prototype),i<5&&(i>3||!h)&&G(i<4?s:{get[t](){return q(this,o)},set[t](u){return U(this,o,u)}},t));i?h&&i<4&&_(o,(i>2?"set ":i>1?"get ":"")+t):_(s,t);for(var v=n.length-1;v>=0;v--)p=Q(i,t,d={},r[3],O),i&&(p.static=w,p.private=h,l=p.access={has:h?u=>F(s,u):u=>t in u},i^3&&(l.get=h?u=>(i^1?q:L)(u,s,i^4?o:m.get):u=>u[t]),i>2&&(l.set=h?(u,E)=>U(u,s,E,i^4?o:m.set):(u,E)=>u[t]=E)),a=(0,n[v])(i?i<4?h?o:m[D]:i>4?void 0:{get:m.get,set:m.set}:s,p),d._=1,i^4||a===void 0?g(a)&&(i>4?k.unshift(a):i?h?o=a:m[D]=a:s=a):typeof a!="object"||a===null?b("Object expected"):(g(c=a.get)&&(m.get=c),g(c=a.set)&&(m.set=c),g(c=a.init)&&k.unshift(c));return i||H(r,s),m&&x(s,t,m),h?i^4?o:m:s};var T=(r,e,t)=>e.has(r)||b("Cannot "+t),F=(r,e)=>Object(e)!==e?b('Cannot use the "in" operator on this value'):r.has(e),q=(r,e,t)=>(T(r,e,"read from private field"),t?t.call(r):e.get(r));var U=(r,e,t,n)=>(T(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),L=(r,e,t)=>(T(r,e,"access private method"),t);import{Injectable as Y}from"@angular/core";import{tap as V}from"rxjs/operators";var M=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.slowThresholdMs=300;this.breadcrumbs=[];this.maxBreadcrumbs=50;this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),e.release&&(this.release=e.release),typeof e.slowThresholdMs=="number"&&e.slowThresholdMs>=0&&(this.slowThresholdMs=e.slowThresholdMs),this.initialized=!0,this.listenGlobalErrors()}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}generateId(e){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`${e}_${crypto.randomUUID()}`}catch{}return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,12)}`}createRequestId(){return this.generateId("req")}createTraceId(){return this.generateId("trace")}createSpanId(){return this.generateId("span")}setUser(e){this.user=this.truncate(e,2e3)}clearUser(){this.user=void 0}getUser(){return this.user}addBreadcrumb(e){let t={...e,timestamp:new Date().toISOString()},n=this.truncate(t,2e3);this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}clearBreadcrumbs(){this.breadcrumbs=[]}getBreadcrumbs(){return[...this.breadcrumbs]}getContext(){return{environment:this.environment,release:this.release,user:this.user,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,timestamp:new Date().toISOString()}}captureRequest(e){let t=this.getContext(),n={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({environment:t.environment,timestamp:t.timestamp,route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0},5e3)};this.send(n)}captureDbQuery(e){let t=this.getContext(),n=e.operation?.trim()||"query",s=e.collection?.trim()||"Unknown",o={type:"db_query",message:`Database operation [${n}]`,stackTrace:"",url:e.url||(typeof window<"u"?window.location.href:""),browser:typeof navigator<"u"?navigator.userAgent:"",method:n,durationMs:e.durationMs,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({...e.metadata,collection:s,operation:n,durationMs:e.durationMs,environment:t.environment,timestamp:t.timestamp},5e3)};this.send(o)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=typeof e.ErrorUtils.getGlobalHandler=="function"?e.ErrorUtils.getGlobalHandler():void 0;e.ErrorUtils.setGlobalHandler((n,s)=>{let o=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(o,{type:"react_native_error",isFatal:!!s}),t&&t(n,s)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let s=n instanceof Error?n:new Error(String(n));this.captureError(s,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"){let s=e;if(n.has(s))return"[Circular Reference]";if(n.add(s),Array.isArray(e))return e.map(c=>this.truncate(c,t,n));let o={};for(let[c,a]of Object.entries(e))o[c]=this.truncate(a,t,n);return o}return e}captureError(e,t={}){let n=e?.message||"Erro Desconhecido",s=e?.stack||"",o=this.getContext(),c=t.requestId,a=t.traceId,d=t.spanId,p={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(s,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:c,traceId:a,spanId:d,environment:o.environment,release:o.release,user:o.user,breadcrumbs:o.breadcrumbs,metadata:this.truncate({...t,environment:o.environment,release:o.release,timestamp:o.timestamp},5e3)};this.send(p)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n=this.getContext(),s={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:t.requestId,traceId:t.traceId,spanId:t.spanId,environment:n.environment,release:n.release,user:n.user,breadcrumbs:n.breadcrumbs,metadata:this.truncate({...t,level:"info",environment:n.environment,release:n.release,timestamp:n.timestamp},5e3)};this.send(s)}async send(e){if(this.initialized&&!(!this.apiKey||this.apiKey==="PENDING_API_KEY"))try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},R="__DEVINSPECT_AUDIT_CORE_INSTANCE__",z=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[R]||(r[R]=new M),r[R]},f=z();var K,A;K=[Y()];var y=class{handleError(e){let t=e instanceof Error?e:new Error(String(e));f.captureError(t,{framework:"Angular",platform:typeof window<"u"?"browser":"server",url:typeof window<"u"?window.location.href:""}),console.error("[DevInspector Angular Error]:",e)}};A=C(null),y=$(A,0,"AuditAngularErrorHandler",K,y),B(A,1,y);var W=(r,e)=>{let t=r.urlWithParams||r.url||"";if(t&&f.isIngestUrl(t))return e(r);let n=f.createRequestId(),s=f.createTraceId(),o=f.createSpanId(),c=r;r&&typeof r.clone=="function"&&(c=r.clone({setHeaders:{"x-devinspector-request-id":n,"x-devinspector-trace-id":s,"x-devinspector-span-id":o}}));let a=typeof performance<"u"?performance.now():Date.now();return e(c).pipe(V({next:d=>{if(!(d&&typeof d=="object"&&"status"in d&&"clone"in d))return;let l=Math.round((typeof performance<"u"?performance.now():Date.now())-a),i=d.status;(i>=400||l>=300)&&f.captureRequest({method:r.method,url:t,statusCode:i,durationMs:l,route:r.url,requestId:n,traceId:s,spanId:o,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),f.addBreadcrumb({type:"http",message:`${r.method} ${t}`,metadata:{statusCode:i,durationMs:l,requestId:n,traceId:s,spanId:o}})},error:d=>{let p=Math.round((typeof performance<"u"?performance.now():Date.now())-a),l=Number(d?.status)||0;f.captureRequest({method:r.method,url:t,statusCode:l,durationMs:p,route:r.url,requestId:n,traceId:s,spanId:o,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),f.captureException(new Error(`HTTP Error ${l}: ${d?.message||d?.statusText||"Erro de rede no cliente"}`),{url:t,method:r.method,status:d?.status,statusText:d?.statusText,type:"angular_network_error",requestId:n,traceId:s,spanId:o}),f.addBreadcrumb({type:"http_error",message:`${r.method} ${t}`,metadata:{statusCode:l,durationMs:p,requestId:n,traceId:s,spanId:o,error:d?.message||d?.statusText||"Network Error"}})}}))},se=W;export{y as AuditAngularErrorHandler,f as audit,se as auditInterceptor,W as devInspectorInterceptor};
|
|
1
|
+
var J=Object.create;var U=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var x=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),w=t=>{throw TypeError(t)};var Y=(t,e,r)=>e in t?U(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var q=(t,e)=>U(t,"name",{value:e,configurable:!0});var N=t=>[,,,J(t?.[x("metadata")]??null)],C=["class","method","getter","setter","accessor","field","value","get","set"],y=t=>t!==void 0&&typeof t!="function"?w("Function expected"):t,Z=(t,e,r,s,n)=>({kind:C[t],name:e,metadata:s,addInitializer:i=>r._?w("Already initialized"):n.push(y(i||null))}),ee=(t,e)=>Y(e,x("metadata"),t[3]),O=(t,e,r,s)=>{for(var n=0,i=t[e>>1],a=i&&i.length;n<a;n++)e&1?i[n].call(r):s=i[n].call(r,s);return s},B=(t,e,r,s,n,i)=>{var a,u,d,h,l,o=e&7,I=!!(e&8),g=!!(e&16),T=o>3?t.length+1:o?I?1:2:0,D=C[o+5],k=o>3&&(t[T-1]=[]),V=t[T]||(t[T]=[]),f=o&&(!g&&!I&&(n=n.prototype),o<5&&(o>3||!g)&&W(o<4?n:{get[r](){return P(this,i)},set[r](c){return Q(this,i,c)}},r));o?g&&o<4&&q(i,(o>2?"set ":o>1?"get ":"")+r):q(n,r);for(var M=s.length-1;M>=0;M--)h=Z(o,r,d={},t[3],V),o&&(h.static=I,h.private=g,l=h.access={has:g?c=>te(n,c):c=>r in c},o^3&&(l.get=g?c=>(o^1?P:re)(c,n,o^4?i:f.get):c=>c[r]),o>2&&(l.set=g?(c,R)=>Q(c,n,R,o^4?i:f.set):(c,R)=>c[r]=R)),u=(0,s[M])(o?o<4?g?i:f[D]:o>4?void 0:{get:f.get,set:f.set}:n,h),d._=1,o^4||u===void 0?y(u)&&(o>4?k.unshift(u):o?g?i=u:f[D]=u:n=u):typeof u!="object"||u===null?w("Object expected"):(y(a=u.get)&&(f.get=a),y(a=u.set)&&(f.set=a),y(a=u.init)&&k.unshift(a));return o||ee(t,n),f&&U(n,r,f),g?o^4?i:f:n};var S=(t,e,r)=>e.has(t)||w("Cannot "+r),te=(t,e)=>Object(e)!==e?w('Cannot use the "in" operator on this value'):t.has(e),P=(t,e,r)=>(S(t,e,"read from private field"),r?r.call(t):e.get(t));var Q=(t,e,r,s)=>(S(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),re=(t,e,r)=>(S(t,e,"access private method"),r);import{Injectable as ae}from"@angular/core";import{tap as ue}from"rxjs/operators";var L="https://api.devinspector.com.br/api/ingest/track",G="https://api.devinspector.com.br/api/ingest/apm";var ne=["password","senha","token","authorization","auth","bearer","credit_card","creditcard","cartao","cvv","cpf","rg","secret","private_key","privatekey"];function se(t){let e=t.toLowerCase().replace(/[\s-]/g,"_");return ne.some(r=>e.includes(r))}function b(t,e=0,r=new WeakSet){if(t==null)return t;if(typeof t=="string")return t.length>1e4?`${t.slice(0,1e4)}...[truncated]`:t;if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="bigint")return String(t);if(typeof t=="function")return"[Function]";if(e>=6)return"[MaxDepth]";if(typeof t!="object")return String(t);if(r.has(t))return"[Circular]";r.add(t);try{if(Array.isArray(t))return t.slice(0,100).map(i=>b(i,e+1,r));let s=t,n={};for(let[i,a]of Object.entries(s)){if(se(i)){n[i]="[REDACTED]";continue}n[i]=b(a,e+1,r)}return n}finally{r.delete(t)}}function z(t){if(t instanceof Error)return t.message||"Erro desconhecido";if(typeof t=="string")return t||"Erro desconhecido";try{let e=b(t);return typeof e=="string"?e||"Erro desconhecido":JSON.stringify(e)||"Erro desconhecido"}catch{return"Erro desconhecido"}}function $(t){return t&&String(t).trim().toUpperCase()||void 0}function F(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.round(t)}function K(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.max(0,Math.round(t))}function ie(t){return String(t??"").trim().slice(0,200)}function oe(t){let e=Number(t);if(!Number.isFinite(e))throw new Error("metricValue deve ser um n\xFAmero finito.");return e}function v(t){let e=typeof globalThis<"u"?globalThis.crypto:void 0;return e&&typeof e.randomUUID=="function"?`${t}-${e.randomUUID()}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,12)}`}function p(t){return b(t)}var A=class{constructor(){this.apiKey="";this.endpoint=L;this.apmEndpoint=G;this.environment="production";this.slowThresholdMs=300;this.requestTimeoutMs=1e4;this.breadcrumbs=[];this.initialized=!1;this.listenersAttached=!1;this.sendQueue=[];this.isProcessingQueue=!1;this.flushResolvers=[]}init(e){if(!e?.apiKey?.trim())throw new Error("DevInspector: apiKey \xE9 obrigat\xF3rio.");this.apiKey=e.apiKey.trim(),this.endpoint=e.endpoint?.trim()||L,this.apmEndpoint=e.apmEndpoint?.trim()||G,this.environment=e.environment?.trim()||"production",this.release=e.release?.trim()||void 0,this.slowThresholdMs=typeof e.slowThresholdMs=="number"&&Number.isFinite(e.slowThresholdMs)&&e.slowThresholdMs>=0?Math.round(e.slowThresholdMs):300,this.requestTimeoutMs=typeof e.requestTimeoutMs=="number"&&Number.isFinite(e.requestTimeoutMs)&&e.requestTimeoutMs>0?Math.round(e.requestTimeoutMs):1e4,this.initialized=!0,this.attachGlobalListeners(),this.processQueue()}getApiKey(){return this.apiKey}getEndpoint(){return this.endpoint}getApmEndpoint(){return this.apmEndpoint}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}getRequestTimeoutMs(){return this.requestTimeoutMs}isInitialized(){return this.initialized}setUser(e){this.user=e?b(e):void 0}getUser(){return this.user}clearUser(){this.user=void 0}addBreadcrumb(e){if(!e||!e.type?.trim())return;let r={timestamp:e.timestamp||new Date().toISOString(),type:e.type.trim().slice(0,200),message:e.message?.slice(0,1e4),metadata:e.metadata?b(e.metadata):void 0};this.breadcrumbs.push(r),this.breadcrumbs.length>50&&(this.breadcrumbs=this.breadcrumbs.slice(-50))}getBreadcrumbs(){return this.breadcrumbs.map(e=>p(e))}clearBreadcrumbs(){this.breadcrumbs=[]}getContext(){return{environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs()}}isIngestUrl(e){if(!e)return!1;try{let r=new URL(this.endpoint),s=new URL(this.apmEndpoint),n=new URL(e,r.origin),i=n.origin,a=n.pathname.replace(/\/$/,""),u=r.pathname.replace(/\/$/,""),d=s.pathname.replace(/\/$/,"");return i===r.origin&&a===u||i===s.origin&&a===d}catch{return e.includes(this.endpoint)||e.includes(this.apmEndpoint)}}createRequestId(){return v("req")}createTraceId(){return v("trace")}createSpanId(){return v("span")}captureRequest(e){let r=$(e.method)||"GET",s=String(e.url||"").trim();if(!s)return Promise.resolve();let n=F(e.statusCode)??0,i=K(e.durationMs)??0,a={...e.metadata||{},...e.route!==void 0?{route:e.route}:{},...e.dbQueriesCount!==void 0?{dbQueriesCount:e.dbQueriesCount}:{},...e.slowQueryMs!==void 0?{slowQueryMs:e.slowQueryMs}:{},timestamp:new Date().toISOString()};return this.sendApm({type:"request_metric",method:r,url:s,statusCode:n,durationMs:i,browser:e.userAgent,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p(a)})}captureDbQuery(e){let r=String(e.operation||"").trim();if(!r)return Promise.resolve();let s=K(e.durationMs)??0,n={...e.metadata||{},operation:r,collection:e.collection||"Unknown",durationMs:s,timestamp:new Date().toISOString()};return this.sendApm({type:"db_query",message:`Database operation: ${r}`,url:e.url,method:"DB",durationMs:s,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p(n)})}captureMetric(e,r,s={},n={}){let i=ie(e);if(!i)return Promise.resolve();let a;try{a=oe(r)}catch{return Promise.resolve()}return this.sendApm({type:"custom_metric",metricName:i,metricValue:a,requestId:n.requestId,traceId:n.traceId,spanId:n.spanId,environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p({...s,timestamp:new Date().toISOString()})})}captureCustomMetric(e){return this.captureMetric(e.metricName,e.metricValue,e.metadata||{},{requestId:e.requestId,traceId:e.traceId,spanId:e.spanId})}captureError(e,r={}){let s=e?.message?.trim()||"Erro desconhecido",n={...r},i=$(n.method),a=F(n.statusCode??n.status),u=n.url!==void 0&&n.url!==null?String(n.url).trim():void 0;return delete n.method,delete n.statusCode,delete n.status,delete n.requestId,delete n.traceId,delete n.spanId,delete n.durationMs,this.sendError({type:"error",message:s,stackTrace:e?.stack||"",...u?{url:u}:{},...i?{method:i}:{},...a!==void 0?{statusCode:a}:{},environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p({...n,timestamp:new Date().toISOString()})})}captureException(e,r={}){let s=e instanceof Error?e:new Error(z(e));return this.captureError(s,r)}captureMessage(e,r={}){let s=String(e||"").trim();return s?this.sendApm({type:"message",message:s.slice(0,1e4),environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p({...r,timestamp:new Date().toISOString()})}):Promise.resolve()}async flush(){if(!(this.sendQueue.length===0&&!this.isProcessingQueue))return new Promise(e=>{this.flushResolvers.push(e),this.processQueue()})}attachGlobalListeners(){if(this.listenersAttached||typeof globalThis>"u")return;this.listenersAttached=!0;let e=globalThis;if(typeof e.ErrorUtils<"u"){let r=e.ErrorUtils.getGlobalHandler?.();e.ErrorUtils.setGlobalHandler?.((s,n)=>{this.captureError(s,{platform:"react-native",fatal:n}).finally(()=>{typeof r=="function"&&r(s,n)})})}if(typeof window<"u"&&typeof window.addEventListener=="function"){window.addEventListener("error",r=>{let s=r.error instanceof Error?r.error:new Error(r.message||"Erro global");this.captureError(s,{url:r.filename||window.location.href,line:r.lineno,column:r.colno,platform:"browser"})}),window.addEventListener("unhandledrejection",r=>{let s=r.reason instanceof Error?r.reason:new Error(z(r.reason));this.captureError(s,{platform:"browser",url:window.location.href})});return}typeof process<"u"&&typeof process.on=="function"&&(process.on("uncaughtException",r=>{this.captureError(r,{platform:"node"})}),process.on("unhandledRejection",r=>{this.captureException(r,{platform:"node"})}))}sendError(e){return this.enqueue(this.endpoint,e)}sendApm(e){return this.enqueue(this.apmEndpoint,e)}enqueue(e,r){if(!this.initialized||!this.apiKey)return Promise.resolve();let s={id:v("event"),endpoint:e,payload:p(r),resolve:()=>{}};return new Promise(n=>{s.resolve=n,this.sendQueue.push(s),this.processQueue()})}async processQueue(){if(!(this.isProcessingQueue||!this.initialized||!this.apiKey)){this.isProcessingQueue=!0;try{for(;this.sendQueue.length>0;){let e=this.sendQueue.shift();if(e)try{await this.sendToEndpoint(e.endpoint,e.payload)}finally{e.resolve()}}}finally{if(this.isProcessingQueue=!1,this.sendQueue.length===0){let e=this.flushResolvers.splice(0);for(let r of e)r()}this.sendQueue.length>0&&this.processQueue()}}}async sendToEndpoint(e,r){let s=typeof fetch=="function"?fetch:void 0;if(!s)return;let n=b(r),i,a;try{typeof AbortController<"u"&&(i=new AbortController,a=setTimeout(()=>{i?.abort()},this.requestTimeoutMs));let u=typeof window<"u"&&typeof window.document<"u",d={method:"POST",headers:{"content-type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(n),signal:i?.signal};if(u&&(d.keepalive=!0),!(await s(e,d)).ok)return}catch{return}finally{a!==void 0&&clearTimeout(a)}}},H="__DEVINSPECT_AUDIT_CORE_INSTANCE__",j=typeof globalThis<"u"?globalThis:{},m=j[H]||new A;j[H]=m;var X,_;X=[ae()];var E=class{handleError(e){let r=e instanceof Error?e:new Error(String(e));m.captureError(r,{framework:"Angular",platform:typeof window<"u"?"browser":"server",url:typeof window<"u"?window.location.href:""}),console.error("[DevInspector Angular Error]:",e)}};_=N(null),E=B(_,0,"AuditAngularErrorHandler",X,E),O(_,1,E);var de=(t,e)=>{let r=t.urlWithParams||t.url||"";if(r&&m.isIngestUrl(r))return e(t);let s=m.createRequestId(),n=m.createTraceId(),i=m.createSpanId(),a=t;t&&typeof t.clone=="function"&&(a=t.clone({setHeaders:{"x-devinspector-request-id":s,"x-devinspector-trace-id":n,"x-devinspector-span-id":i}}));let u=typeof performance<"u"?performance.now():Date.now();return e(a).pipe(ue({next:d=>{if(!(d&&typeof d=="object"&&"status"in d&&"clone"in d))return;let l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-u)),o=Number(d.status)||0;(o>=400||l>=m.getSlowThresholdMs())&&m.captureRequest({method:t.method||"GET",url:r,statusCode:o,durationMs:l,route:t.url,requestId:s,traceId:n,spanId:i,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),m.addBreadcrumb({type:"http",message:`${t.method||"GET"} ${r} `,metadata:{statusCode:o,durationMs:l,requestId:s,traceId:n,spanId:i}})},error:d=>{let h=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-u)),l=Number(d?.status)||0;m.captureRequest({method:t.method||"GET",url:r,statusCode:l,durationMs:h,route:t.url,requestId:s,traceId:n,spanId:i,userAgent:typeof navigator<"u"?navigator.userAgent:void 0}),m.captureException(new Error(`HTTP Error ${l}: ${d?.message||d?.statusText||"Erro de rede no cliente"} `),{url:r,method:t.method||"GET",status:d?.status,statusText:d?.statusText,type:"angular_network_error",requestId:s,traceId:n,spanId:i}),m.addBreadcrumb({type:"http_error",message:`${t.method||"GET"} ${r} `,metadata:{statusCode:l,durationMs:h,requestId:s,traceId:n,spanId:i,error:d?.message||d?.statusText||"Network Error"}})}}))},ge=de;export{E as AuditAngularErrorHandler,m as audit,ge as auditInterceptor,de as devInspectorInterceptor};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var g=(i,e)=>{for(var r in e)c(i,r,{get:e[r],enumerable:!0})},y=(i,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of b(e))!f.call(i,n)&&n!==r&&c(i,n,{get:()=>e[n],enumerable:!(t=h(e,n))||t.enumerable});return i};var w=i=>y(c({},"__esModule",{value:!0}),i);var I={};g(I,{AuditCore:()=>a,audit:()=>l});module.exports=w(I);var a=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.slowThresholdMs=300;this.breadcrumbs=[];this.maxBreadcrumbs=50;this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),e.release&&(this.release=e.release),typeof e.slowThresholdMs=="number"&&e.slowThresholdMs>=0&&(this.slowThresholdMs=e.slowThresholdMs),this.initialized=!0,this.listenGlobalErrors()}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}generateId(e){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`${e}_${crypto.randomUUID()}`}catch{}return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,12)}`}createRequestId(){return this.generateId("req")}createTraceId(){return this.generateId("trace")}createSpanId(){return this.generateId("span")}setUser(e){this.user=this.truncate(e,2e3)}clearUser(){this.user=void 0}getUser(){return this.user}addBreadcrumb(e){let r={...e,timestamp:new Date().toISOString()},t=this.truncate(r,2e3);this.breadcrumbs.push(t),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}clearBreadcrumbs(){this.breadcrumbs=[]}getBreadcrumbs(){return[...this.breadcrumbs]}getContext(){return{environment:this.environment,release:this.release,user:this.user,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,timestamp:new Date().toISOString()}}captureRequest(e){let r=this.getContext(),t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:r.environment,release:r.release,user:r.user,breadcrumbs:r.breadcrumbs,metadata:this.truncate({environment:r.environment,timestamp:r.timestamp,route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0},5e3)};this.send(t)}captureDbQuery(e){let r=this.getContext(),t=e.operation?.trim()||"query",n=e.collection?.trim()||"Unknown",s={type:"db_query",message:`Database operation [${t}]`,stackTrace:"",url:e.url||(typeof window<"u"?window.location.href:""),browser:typeof navigator<"u"?navigator.userAgent:"",method:t,durationMs:e.durationMs,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:r.environment,release:r.release,user:r.user,breadcrumbs:r.breadcrumbs,metadata:this.truncate({...e.metadata,collection:n,operation:t,durationMs:e.durationMs,environment:r.environment,timestamp:r.timestamp},5e3)};this.send(s)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=typeof e.ErrorUtils.getGlobalHandler=="function"?e.ErrorUtils.getGlobalHandler():void 0;e.ErrorUtils.setGlobalHandler((t,n)=>{let s=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!n}),r&&r(t,n)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let n=t instanceof Error?t:new Error(String(t));this.captureError(n,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"){let n=e;if(t.has(n))return"[Circular Reference]";if(t.add(n),Array.isArray(e))return e.map(o=>this.truncate(o,r,t));let s={};for(let[o,d]of Object.entries(e))s[o]=this.truncate(d,r,t);return s}return e}captureError(e,r={}){let t=e?.message||"Erro Desconhecido",n=e?.stack||"",s=this.getContext(),o=r.requestId,d=r.traceId,p=r.spanId,m={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(n,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:o,traceId:d,spanId:p,environment:s.environment,release:s.release,user:s.user,breadcrumbs:s.breadcrumbs,metadata:this.truncate({...r,environment:s.environment,release:s.release,timestamp:s.timestamp},5e3)};this.send(m)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t=this.getContext(),n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:r.requestId,traceId:r.traceId,spanId:r.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({...r,level:"info",environment:t.environment,release:t.release,timestamp:t.timestamp},5e3)};this.send(n)}async send(e){if(this.initialized&&!(!this.apiKey||this.apiKey==="PENDING_API_KEY"))try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},u="__DEVINSPECT_AUDIT_CORE_INSTANCE__",v=()=>{let i=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return i[u]||(i[u]=new a),i[u]},l=v();0&&(module.exports={AuditCore,audit});
|
|
1
|
+
"use strict";var y=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var P=(t,e)=>{for(var r in e)y(t,r,{get:e[r],enumerable:!0})},Q=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _(e))!k.call(t,n)&&n!==r&&y(t,n,{get:()=>e[n],enumerable:!(i=D(e,n))||i.enumerable});return t};var C=t=>Q(y({},"__esModule",{value:!0}),t);var x={};P(x,{AuditCore:()=>f,audit:()=>a,coreAuditFetch:()=>S});module.exports=C(x);var I="https://api.devinspector.com.br/api/ingest/track",T="https://api.devinspector.com.br/api/ingest/apm";var N=["password","senha","token","authorization","auth","bearer","credit_card","creditcard","cartao","cvv","cpf","rg","secret","private_key","privatekey"];function O(t){let e=t.toLowerCase().replace(/[\s-]/g,"_");return N.some(r=>e.includes(r))}function m(t,e=0,r=new WeakSet){if(t==null)return t;if(typeof t=="string")return t.length>1e4?`${t.slice(0,1e4)}...[truncated]`:t;if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="bigint")return String(t);if(typeof t=="function")return"[Function]";if(e>=6)return"[MaxDepth]";if(typeof t!="object")return String(t);if(r.has(t))return"[Circular]";r.add(t);try{if(Array.isArray(t))return t.slice(0,100).map(s=>m(s,e+1,r));let i=t,n={};for(let[s,o]of Object.entries(i)){if(O(s)){n[s]="[REDACTED]";continue}n[s]=m(o,e+1,r)}return n}finally{r.delete(t)}}function w(t){if(t instanceof Error)return t.message||"Erro desconhecido";if(typeof t=="string")return t||"Erro desconhecido";try{let e=m(t);return typeof e=="string"?e||"Erro desconhecido":JSON.stringify(e)||"Erro desconhecido"}catch{return"Erro desconhecido"}}function E(t){return t&&String(t).trim().toUpperCase()||void 0}function M(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.round(t)}function A(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.max(0,Math.round(t))}function B(t){return String(t??"").trim().slice(0,200)}function L(t){let e=Number(t);if(!Number.isFinite(e))throw new Error("metricValue deve ser um n\xFAmero finito.");return e}function g(t){let e=typeof globalThis<"u"?globalThis.crypto:void 0;return e&&typeof e.randomUUID=="function"?`${t}-${e.randomUUID()}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,12)}`}function u(t){return m(t)}var f=class{constructor(){this.apiKey="";this.endpoint=I;this.apmEndpoint=T;this.environment="production";this.slowThresholdMs=300;this.requestTimeoutMs=1e4;this.breadcrumbs=[];this.initialized=!1;this.listenersAttached=!1;this.sendQueue=[];this.isProcessingQueue=!1;this.flushResolvers=[]}init(e){if(!e?.apiKey?.trim())throw new Error("DevInspector: apiKey \xE9 obrigat\xF3rio.");this.apiKey=e.apiKey.trim(),this.endpoint=e.endpoint?.trim()||I,this.apmEndpoint=e.apmEndpoint?.trim()||T,this.environment=e.environment?.trim()||"production",this.release=e.release?.trim()||void 0,this.slowThresholdMs=typeof e.slowThresholdMs=="number"&&Number.isFinite(e.slowThresholdMs)&&e.slowThresholdMs>=0?Math.round(e.slowThresholdMs):300,this.requestTimeoutMs=typeof e.requestTimeoutMs=="number"&&Number.isFinite(e.requestTimeoutMs)&&e.requestTimeoutMs>0?Math.round(e.requestTimeoutMs):1e4,this.initialized=!0,this.attachGlobalListeners(),this.processQueue()}getApiKey(){return this.apiKey}getEndpoint(){return this.endpoint}getApmEndpoint(){return this.apmEndpoint}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}getRequestTimeoutMs(){return this.requestTimeoutMs}isInitialized(){return this.initialized}setUser(e){this.user=e?m(e):void 0}getUser(){return this.user}clearUser(){this.user=void 0}addBreadcrumb(e){if(!e||!e.type?.trim())return;let r={timestamp:e.timestamp||new Date().toISOString(),type:e.type.trim().slice(0,200),message:e.message?.slice(0,1e4),metadata:e.metadata?m(e.metadata):void 0};this.breadcrumbs.push(r),this.breadcrumbs.length>50&&(this.breadcrumbs=this.breadcrumbs.slice(-50))}getBreadcrumbs(){return this.breadcrumbs.map(e=>u(e))}clearBreadcrumbs(){this.breadcrumbs=[]}getContext(){return{environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs()}}isIngestUrl(e){if(!e)return!1;try{let r=new URL(this.endpoint),i=new URL(this.apmEndpoint),n=new URL(e,r.origin),s=n.origin,o=n.pathname.replace(/\/$/,""),d=r.pathname.replace(/\/$/,""),c=i.pathname.replace(/\/$/,"");return s===r.origin&&o===d||s===i.origin&&o===c}catch{return e.includes(this.endpoint)||e.includes(this.apmEndpoint)}}createRequestId(){return g("req")}createTraceId(){return g("trace")}createSpanId(){return g("span")}captureRequest(e){let r=E(e.method)||"GET",i=String(e.url||"").trim();if(!i)return Promise.resolve();let n=M(e.statusCode)??0,s=A(e.durationMs)??0,o={...e.metadata||{},...e.route!==void 0?{route:e.route}:{},...e.dbQueriesCount!==void 0?{dbQueriesCount:e.dbQueriesCount}:{},...e.slowQueryMs!==void 0?{slowQueryMs:e.slowQueryMs}:{},timestamp:new Date().toISOString()};return this.sendApm({type:"request_metric",method:r,url:i,statusCode:n,durationMs:s,browser:e.userAgent,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u(o)})}captureDbQuery(e){let r=String(e.operation||"").trim();if(!r)return Promise.resolve();let i=A(e.durationMs)??0,n={...e.metadata||{},operation:r,collection:e.collection||"Unknown",durationMs:i,timestamp:new Date().toISOString()};return this.sendApm({type:"db_query",message:`Database operation: ${r}`,url:e.url,method:"DB",durationMs:i,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u(n)})}captureMetric(e,r,i={},n={}){let s=B(e);if(!s)return Promise.resolve();let o;try{o=L(r)}catch{return Promise.resolve()}return this.sendApm({type:"custom_metric",metricName:s,metricValue:o,requestId:n.requestId,traceId:n.traceId,spanId:n.spanId,environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u({...i,timestamp:new Date().toISOString()})})}captureCustomMetric(e){return this.captureMetric(e.metricName,e.metricValue,e.metadata||{},{requestId:e.requestId,traceId:e.traceId,spanId:e.spanId})}captureError(e,r={}){let i=e?.message?.trim()||"Erro desconhecido",n={...r},s=E(n.method),o=M(n.statusCode??n.status),d=n.url!==void 0&&n.url!==null?String(n.url).trim():void 0;return delete n.method,delete n.statusCode,delete n.status,delete n.requestId,delete n.traceId,delete n.spanId,delete n.durationMs,this.sendError({type:"error",message:i,stackTrace:e?.stack||"",...d?{url:d}:{},...s?{method:s}:{},...o!==void 0?{statusCode:o}:{},environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u({...n,timestamp:new Date().toISOString()})})}captureException(e,r={}){let i=e instanceof Error?e:new Error(w(e));return this.captureError(i,r)}captureMessage(e,r={}){let i=String(e||"").trim();return i?this.sendApm({type:"message",message:i.slice(0,1e4),environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u({...r,timestamp:new Date().toISOString()})}):Promise.resolve()}async flush(){if(!(this.sendQueue.length===0&&!this.isProcessingQueue))return new Promise(e=>{this.flushResolvers.push(e),this.processQueue()})}attachGlobalListeners(){if(this.listenersAttached||typeof globalThis>"u")return;this.listenersAttached=!0;let e=globalThis;if(typeof e.ErrorUtils<"u"){let r=e.ErrorUtils.getGlobalHandler?.();e.ErrorUtils.setGlobalHandler?.((i,n)=>{this.captureError(i,{platform:"react-native",fatal:n}).finally(()=>{typeof r=="function"&&r(i,n)})})}if(typeof window<"u"&&typeof window.addEventListener=="function"){window.addEventListener("error",r=>{let i=r.error instanceof Error?r.error:new Error(r.message||"Erro global");this.captureError(i,{url:r.filename||window.location.href,line:r.lineno,column:r.colno,platform:"browser"})}),window.addEventListener("unhandledrejection",r=>{let i=r.reason instanceof Error?r.reason:new Error(w(r.reason));this.captureError(i,{platform:"browser",url:window.location.href})});return}typeof process<"u"&&typeof process.on=="function"&&(process.on("uncaughtException",r=>{this.captureError(r,{platform:"node"})}),process.on("unhandledRejection",r=>{this.captureException(r,{platform:"node"})}))}sendError(e){return this.enqueue(this.endpoint,e)}sendApm(e){return this.enqueue(this.apmEndpoint,e)}enqueue(e,r){if(!this.initialized||!this.apiKey)return Promise.resolve();let i={id:g("event"),endpoint:e,payload:u(r),resolve:()=>{}};return new Promise(n=>{i.resolve=n,this.sendQueue.push(i),this.processQueue()})}async processQueue(){if(!(this.isProcessingQueue||!this.initialized||!this.apiKey)){this.isProcessingQueue=!0;try{for(;this.sendQueue.length>0;){let e=this.sendQueue.shift();if(e)try{await this.sendToEndpoint(e.endpoint,e.payload)}finally{e.resolve()}}}finally{if(this.isProcessingQueue=!1,this.sendQueue.length===0){let e=this.flushResolvers.splice(0);for(let r of e)r()}this.sendQueue.length>0&&this.processQueue()}}}async sendToEndpoint(e,r){let i=typeof fetch=="function"?fetch:void 0;if(!i)return;let n=m(r),s,o;try{typeof AbortController<"u"&&(s=new AbortController,o=setTimeout(()=>{s?.abort()},this.requestTimeoutMs));let d=typeof window<"u"&&typeof window.document<"u",c={method:"POST",headers:{"content-type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(n),signal:s?.signal};if(d&&(c.keepalive=!0),!(await i(e,c)).ok)return}catch{return}finally{o!==void 0&&clearTimeout(o)}}},R="__DEVINSPECT_AUDIT_CORE_INSTANCE__",U=typeof globalThis<"u"?globalThis:{},a=U[R]||new f;U[R]=a;async function S(t,e,r={}){let i=r.nativeFetch||(typeof fetch=="function"?fetch:void 0);if(!i)throw new Error("fetch n\xE3o est\xE1 dispon\xEDvel.");let n=typeof t=="string"?t:t instanceof URL?t.toString():String(t.url||""),s=E(e?.method||(typeof t!="string"&&!(t instanceof URL)?t.method:"GET"))||"GET";if(n&&a.isIngestUrl(n))return i(t,e);let o=a.createRequestId(),d=a.createTraceId(),c=a.createSpanId(),h=new Headers(e?.headers||(typeof t!="string"&&!(t instanceof URL)?t.headers:void 0));h.set("x-devinspector-request-id",o),h.set("x-devinspector-trace-id",d),h.set("x-devinspector-span-id",c);let q={...e,headers:h},v=typeof performance<"u"?performance.now():Date.now();try{let p=await i(t,q),l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-v)),b=p.status>=400||l>=a.getSlowThresholdMs();return a.addBreadcrumb({type:"http",message:`${s} ${n}`,metadata:{phase:"complete",statusCode:p.status,durationMs:l,requestId:o,traceId:d,spanId:c}}),b&&a.captureRequest({method:s,url:n,statusCode:p.status,durationMs:l,userAgent:typeof navigator<"u"?navigator.userAgent:r.defaultUserAgent,requestId:o,traceId:d,spanId:c}),p}catch(p){let l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-v));a.addBreadcrumb({type:"http_error",message:`${s} ${n}`,metadata:{phase:"error",statusCode:0,durationMs:l,requestId:o,traceId:d,spanId:c}}),a.captureRequest({method:s,url:n,statusCode:0,durationMs:l,userAgent:typeof navigator<"u"?navigator.userAgent:r.defaultUserAgent,requestId:o,traceId:d,spanId:c});let b=p instanceof Error?p:new Error(w(p));throw a.captureError(b,{url:n,method:s,type:r.errorType||"network_error"}),p}}0&&(module.exports={AuditCore,audit,coreAuditFetch});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type UnknownRecord = Record<string, unknown>;
|
|
1
2
|
interface AuditUser {
|
|
2
3
|
id?: string;
|
|
3
4
|
email?: string;
|
|
@@ -5,17 +6,19 @@ interface AuditUser {
|
|
|
5
6
|
[key: string]: unknown;
|
|
6
7
|
}
|
|
7
8
|
interface Breadcrumb {
|
|
8
|
-
timestamp
|
|
9
|
+
timestamp?: string;
|
|
9
10
|
type: string;
|
|
10
11
|
message?: string;
|
|
11
|
-
metadata?:
|
|
12
|
+
metadata?: UnknownRecord;
|
|
12
13
|
}
|
|
13
14
|
interface InitOptions {
|
|
14
15
|
apiKey: string;
|
|
15
16
|
endpoint?: string;
|
|
17
|
+
apmEndpoint?: string;
|
|
16
18
|
environment?: string;
|
|
17
19
|
release?: string;
|
|
18
20
|
slowThresholdMs?: number;
|
|
21
|
+
requestTimeoutMs?: number;
|
|
19
22
|
}
|
|
20
23
|
interface RequestMetricData {
|
|
21
24
|
method: string;
|
|
@@ -29,6 +32,7 @@ interface RequestMetricData {
|
|
|
29
32
|
requestId?: string;
|
|
30
33
|
traceId?: string;
|
|
31
34
|
spanId?: string;
|
|
35
|
+
metadata?: UnknownRecord;
|
|
32
36
|
}
|
|
33
37
|
interface DbQueryData {
|
|
34
38
|
operation: string;
|
|
@@ -38,44 +42,76 @@ interface DbQueryData {
|
|
|
38
42
|
requestId?: string;
|
|
39
43
|
traceId?: string;
|
|
40
44
|
spanId?: string;
|
|
41
|
-
metadata?:
|
|
45
|
+
metadata?: UnknownRecord;
|
|
42
46
|
}
|
|
47
|
+
interface CustomMetricData {
|
|
48
|
+
metricName: string;
|
|
49
|
+
metricValue: number;
|
|
50
|
+
metadata?: UnknownRecord;
|
|
51
|
+
requestId?: string;
|
|
52
|
+
traceId?: string;
|
|
53
|
+
spanId?: string;
|
|
54
|
+
}
|
|
55
|
+
type AuditEventType = "error" | "message" | "request_metric" | "db_query" | "custom_metric";
|
|
43
56
|
declare class AuditCore {
|
|
44
57
|
private apiKey;
|
|
45
58
|
private endpoint;
|
|
59
|
+
private apmEndpoint;
|
|
46
60
|
private environment;
|
|
47
61
|
private release?;
|
|
48
62
|
private slowThresholdMs;
|
|
63
|
+
private requestTimeoutMs;
|
|
49
64
|
private user?;
|
|
50
65
|
private breadcrumbs;
|
|
51
|
-
private
|
|
52
|
-
initialized: boolean;
|
|
66
|
+
private initialized;
|
|
53
67
|
private listenersAttached;
|
|
68
|
+
private sendQueue;
|
|
69
|
+
private isProcessingQueue;
|
|
70
|
+
private flushResolvers;
|
|
54
71
|
init(options: InitOptions): void;
|
|
72
|
+
getApiKey(): string;
|
|
73
|
+
getEndpoint(): string;
|
|
74
|
+
getApmEndpoint(): string;
|
|
55
75
|
getEnvironment(): string;
|
|
56
76
|
getRelease(): string | undefined;
|
|
57
77
|
getSlowThresholdMs(): number;
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
getRequestTimeoutMs(): number;
|
|
79
|
+
isInitialized(): boolean;
|
|
80
|
+
setUser(user?: AuditUser): void;
|
|
81
|
+
getUser(): AuditUser | undefined;
|
|
82
|
+
clearUser(): void;
|
|
83
|
+
addBreadcrumb(breadcrumb: Breadcrumb): void;
|
|
84
|
+
getBreadcrumbs(): Breadcrumb[];
|
|
85
|
+
clearBreadcrumbs(): void;
|
|
86
|
+
getContext(): UnknownRecord;
|
|
87
|
+
isIngestUrl(url: string): boolean;
|
|
60
88
|
createRequestId(): string;
|
|
61
89
|
createTraceId(): string;
|
|
62
90
|
createSpanId(): string;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
private
|
|
91
|
+
captureRequest(data: RequestMetricData): Promise<void>;
|
|
92
|
+
captureDbQuery(data: DbQueryData): Promise<void>;
|
|
93
|
+
captureMetric(metricName: string, metricValue: number, metadata?: UnknownRecord, contextIds?: {
|
|
94
|
+
requestId?: string;
|
|
95
|
+
traceId?: string;
|
|
96
|
+
spanId?: string;
|
|
97
|
+
}): Promise<void>;
|
|
98
|
+
captureCustomMetric(data: CustomMetricData): Promise<void>;
|
|
99
|
+
captureError(error: Error, metadata?: UnknownRecord): Promise<void>;
|
|
100
|
+
captureException(error: unknown, metadata?: UnknownRecord): Promise<void>;
|
|
101
|
+
captureMessage(message: string, metadata?: UnknownRecord): Promise<void>;
|
|
102
|
+
flush(): Promise<void>;
|
|
103
|
+
private attachGlobalListeners;
|
|
104
|
+
private sendError;
|
|
105
|
+
private sendApm;
|
|
106
|
+
private enqueue;
|
|
107
|
+
private processQueue;
|
|
108
|
+
private sendToEndpoint;
|
|
78
109
|
}
|
|
79
110
|
declare const audit: AuditCore;
|
|
111
|
+
declare function coreAuditFetch(input: RequestInfo | URL, init?: RequestInit, options?: {
|
|
112
|
+
errorType?: string;
|
|
113
|
+
defaultUserAgent?: string;
|
|
114
|
+
nativeFetch?: typeof fetch;
|
|
115
|
+
}): Promise<Response>;
|
|
80
116
|
|
|
81
|
-
export { AuditCore, type AuditUser, type Breadcrumb, type InitOptions, type RequestMetricData, audit };
|
|
117
|
+
export { AuditCore, type AuditEventType, type AuditUser, type Breadcrumb, type CustomMetricData, type DbQueryData, type InitOptions, type RequestMetricData, audit, coreAuditFetch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type UnknownRecord = Record<string, unknown>;
|
|
1
2
|
interface AuditUser {
|
|
2
3
|
id?: string;
|
|
3
4
|
email?: string;
|
|
@@ -5,17 +6,19 @@ interface AuditUser {
|
|
|
5
6
|
[key: string]: unknown;
|
|
6
7
|
}
|
|
7
8
|
interface Breadcrumb {
|
|
8
|
-
timestamp
|
|
9
|
+
timestamp?: string;
|
|
9
10
|
type: string;
|
|
10
11
|
message?: string;
|
|
11
|
-
metadata?:
|
|
12
|
+
metadata?: UnknownRecord;
|
|
12
13
|
}
|
|
13
14
|
interface InitOptions {
|
|
14
15
|
apiKey: string;
|
|
15
16
|
endpoint?: string;
|
|
17
|
+
apmEndpoint?: string;
|
|
16
18
|
environment?: string;
|
|
17
19
|
release?: string;
|
|
18
20
|
slowThresholdMs?: number;
|
|
21
|
+
requestTimeoutMs?: number;
|
|
19
22
|
}
|
|
20
23
|
interface RequestMetricData {
|
|
21
24
|
method: string;
|
|
@@ -29,6 +32,7 @@ interface RequestMetricData {
|
|
|
29
32
|
requestId?: string;
|
|
30
33
|
traceId?: string;
|
|
31
34
|
spanId?: string;
|
|
35
|
+
metadata?: UnknownRecord;
|
|
32
36
|
}
|
|
33
37
|
interface DbQueryData {
|
|
34
38
|
operation: string;
|
|
@@ -38,44 +42,76 @@ interface DbQueryData {
|
|
|
38
42
|
requestId?: string;
|
|
39
43
|
traceId?: string;
|
|
40
44
|
spanId?: string;
|
|
41
|
-
metadata?:
|
|
45
|
+
metadata?: UnknownRecord;
|
|
42
46
|
}
|
|
47
|
+
interface CustomMetricData {
|
|
48
|
+
metricName: string;
|
|
49
|
+
metricValue: number;
|
|
50
|
+
metadata?: UnknownRecord;
|
|
51
|
+
requestId?: string;
|
|
52
|
+
traceId?: string;
|
|
53
|
+
spanId?: string;
|
|
54
|
+
}
|
|
55
|
+
type AuditEventType = "error" | "message" | "request_metric" | "db_query" | "custom_metric";
|
|
43
56
|
declare class AuditCore {
|
|
44
57
|
private apiKey;
|
|
45
58
|
private endpoint;
|
|
59
|
+
private apmEndpoint;
|
|
46
60
|
private environment;
|
|
47
61
|
private release?;
|
|
48
62
|
private slowThresholdMs;
|
|
63
|
+
private requestTimeoutMs;
|
|
49
64
|
private user?;
|
|
50
65
|
private breadcrumbs;
|
|
51
|
-
private
|
|
52
|
-
initialized: boolean;
|
|
66
|
+
private initialized;
|
|
53
67
|
private listenersAttached;
|
|
68
|
+
private sendQueue;
|
|
69
|
+
private isProcessingQueue;
|
|
70
|
+
private flushResolvers;
|
|
54
71
|
init(options: InitOptions): void;
|
|
72
|
+
getApiKey(): string;
|
|
73
|
+
getEndpoint(): string;
|
|
74
|
+
getApmEndpoint(): string;
|
|
55
75
|
getEnvironment(): string;
|
|
56
76
|
getRelease(): string | undefined;
|
|
57
77
|
getSlowThresholdMs(): number;
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
getRequestTimeoutMs(): number;
|
|
79
|
+
isInitialized(): boolean;
|
|
80
|
+
setUser(user?: AuditUser): void;
|
|
81
|
+
getUser(): AuditUser | undefined;
|
|
82
|
+
clearUser(): void;
|
|
83
|
+
addBreadcrumb(breadcrumb: Breadcrumb): void;
|
|
84
|
+
getBreadcrumbs(): Breadcrumb[];
|
|
85
|
+
clearBreadcrumbs(): void;
|
|
86
|
+
getContext(): UnknownRecord;
|
|
87
|
+
isIngestUrl(url: string): boolean;
|
|
60
88
|
createRequestId(): string;
|
|
61
89
|
createTraceId(): string;
|
|
62
90
|
createSpanId(): string;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
private
|
|
91
|
+
captureRequest(data: RequestMetricData): Promise<void>;
|
|
92
|
+
captureDbQuery(data: DbQueryData): Promise<void>;
|
|
93
|
+
captureMetric(metricName: string, metricValue: number, metadata?: UnknownRecord, contextIds?: {
|
|
94
|
+
requestId?: string;
|
|
95
|
+
traceId?: string;
|
|
96
|
+
spanId?: string;
|
|
97
|
+
}): Promise<void>;
|
|
98
|
+
captureCustomMetric(data: CustomMetricData): Promise<void>;
|
|
99
|
+
captureError(error: Error, metadata?: UnknownRecord): Promise<void>;
|
|
100
|
+
captureException(error: unknown, metadata?: UnknownRecord): Promise<void>;
|
|
101
|
+
captureMessage(message: string, metadata?: UnknownRecord): Promise<void>;
|
|
102
|
+
flush(): Promise<void>;
|
|
103
|
+
private attachGlobalListeners;
|
|
104
|
+
private sendError;
|
|
105
|
+
private sendApm;
|
|
106
|
+
private enqueue;
|
|
107
|
+
private processQueue;
|
|
108
|
+
private sendToEndpoint;
|
|
78
109
|
}
|
|
79
110
|
declare const audit: AuditCore;
|
|
111
|
+
declare function coreAuditFetch(input: RequestInfo | URL, init?: RequestInit, options?: {
|
|
112
|
+
errorType?: string;
|
|
113
|
+
defaultUserAgent?: string;
|
|
114
|
+
nativeFetch?: typeof fetch;
|
|
115
|
+
}): Promise<Response>;
|
|
80
116
|
|
|
81
|
-
export { AuditCore, type AuditUser, type Breadcrumb, type InitOptions, type RequestMetricData, audit };
|
|
117
|
+
export { AuditCore, type AuditEventType, type AuditUser, type Breadcrumb, type CustomMetricData, type DbQueryData, type InitOptions, type RequestMetricData, audit, coreAuditFetch };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.slowThresholdMs=300;this.breadcrumbs=[];this.maxBreadcrumbs=50;this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),e.release&&(this.release=e.release),typeof e.slowThresholdMs=="number"&&e.slowThresholdMs>=0&&(this.slowThresholdMs=e.slowThresholdMs),this.initialized=!0,this.listenGlobalErrors()}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}generateId(e){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`${e}_${crypto.randomUUID()}`}catch{}return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,12)}`}createRequestId(){return this.generateId("req")}createTraceId(){return this.generateId("trace")}createSpanId(){return this.generateId("span")}setUser(e){this.user=this.truncate(e,2e3)}clearUser(){this.user=void 0}getUser(){return this.user}addBreadcrumb(e){let r={...e,timestamp:new Date().toISOString()},t=this.truncate(r,2e3);this.breadcrumbs.push(t),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}clearBreadcrumbs(){this.breadcrumbs=[]}getBreadcrumbs(){return[...this.breadcrumbs]}getContext(){return{environment:this.environment,release:this.release,user:this.user,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,timestamp:new Date().toISOString()}}captureRequest(e){let r=this.getContext(),t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:r.environment,release:r.release,user:r.user,breadcrumbs:r.breadcrumbs,metadata:this.truncate({environment:r.environment,timestamp:r.timestamp,route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0},5e3)};this.send(t)}captureDbQuery(e){let r=this.getContext(),t=e.operation?.trim()||"query",s=e.collection?.trim()||"Unknown",n={type:"db_query",message:`Database operation [${t}]`,stackTrace:"",url:e.url||(typeof window<"u"?window.location.href:""),browser:typeof navigator<"u"?navigator.userAgent:"",method:t,durationMs:e.durationMs,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:r.environment,release:r.release,user:r.user,breadcrumbs:r.breadcrumbs,metadata:this.truncate({...e.metadata,collection:s,operation:t,durationMs:e.durationMs,environment:r.environment,timestamp:r.timestamp},5e3)};this.send(n)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=typeof e.ErrorUtils.getGlobalHandler=="function"?e.ErrorUtils.getGlobalHandler():void 0;e.ErrorUtils.setGlobalHandler((t,s)=>{let n=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(n,{type:"react_native_error",isFatal:!!s}),r&&r(t,s)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let s=t instanceof Error?t:new Error(String(t));this.captureError(s,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"){let s=e;if(t.has(s))return"[Circular Reference]";if(t.add(s),Array.isArray(e))return e.map(i=>this.truncate(i,r,t));let n={};for(let[i,d]of Object.entries(e))n[i]=this.truncate(d,r,t);return n}return e}captureError(e,r={}){let t=e?.message||"Erro Desconhecido",s=e?.stack||"",n=this.getContext(),i=r.requestId,d=r.traceId,u=r.spanId,l={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(s,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:i,traceId:d,spanId:u,environment:n.environment,release:n.release,user:n.user,breadcrumbs:n.breadcrumbs,metadata:this.truncate({...r,environment:n.environment,release:n.release,timestamp:n.timestamp},5e3)};this.send(l)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t=this.getContext(),s={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:r.requestId,traceId:r.traceId,spanId:r.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({...r,level:"info",environment:t.environment,release:t.release,timestamp:t.timestamp},5e3)};this.send(s)}async send(e){if(this.initialized&&!(!this.apiKey||this.apiKey==="PENDING_API_KEY"))try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},c="__DEVINSPECT_AUDIT_CORE_INSTANCE__",p=()=>{let o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return o[c]||(o[c]=new a),o[c]},m=p();export{a as AuditCore,m as audit};
|
|
1
|
+
var v="https://api.devinspector.com.br/api/ingest/track",I="https://api.devinspector.com.br/api/ingest/apm";var S=["password","senha","token","authorization","auth","bearer","credit_card","creditcard","cartao","cvv","cpf","rg","secret","private_key","privatekey"];function q(t){let e=t.toLowerCase().replace(/[\s-]/g,"_");return S.some(r=>e.includes(r))}function m(t,e=0,r=new WeakSet){if(t==null)return t;if(typeof t=="string")return t.length>1e4?`${t.slice(0,1e4)}...[truncated]`:t;if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="bigint")return String(t);if(typeof t=="function")return"[Function]";if(e>=6)return"[MaxDepth]";if(typeof t!="object")return String(t);if(r.has(t))return"[Circular]";r.add(t);try{if(Array.isArray(t))return t.slice(0,100).map(s=>m(s,e+1,r));let i=t,n={};for(let[s,o]of Object.entries(i)){if(q(s)){n[s]="[REDACTED]";continue}n[s]=m(o,e+1,r)}return n}finally{r.delete(t)}}function y(t){if(t instanceof Error)return t.message||"Erro desconhecido";if(typeof t=="string")return t||"Erro desconhecido";try{let e=m(t);return typeof e=="string"?e||"Erro desconhecido":JSON.stringify(e)||"Erro desconhecido"}catch{return"Erro desconhecido"}}function w(t){return t&&String(t).trim().toUpperCase()||void 0}function T(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.round(t)}function M(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.max(0,Math.round(t))}function D(t){return String(t??"").trim().slice(0,200)}function _(t){let e=Number(t);if(!Number.isFinite(e))throw new Error("metricValue deve ser um n\xFAmero finito.");return e}function f(t){let e=typeof globalThis<"u"?globalThis.crypto:void 0;return e&&typeof e.randomUUID=="function"?`${t}-${e.randomUUID()}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,12)}`}function u(t){return m(t)}var g=class{constructor(){this.apiKey="";this.endpoint=v;this.apmEndpoint=I;this.environment="production";this.slowThresholdMs=300;this.requestTimeoutMs=1e4;this.breadcrumbs=[];this.initialized=!1;this.listenersAttached=!1;this.sendQueue=[];this.isProcessingQueue=!1;this.flushResolvers=[]}init(e){if(!e?.apiKey?.trim())throw new Error("DevInspector: apiKey \xE9 obrigat\xF3rio.");this.apiKey=e.apiKey.trim(),this.endpoint=e.endpoint?.trim()||v,this.apmEndpoint=e.apmEndpoint?.trim()||I,this.environment=e.environment?.trim()||"production",this.release=e.release?.trim()||void 0,this.slowThresholdMs=typeof e.slowThresholdMs=="number"&&Number.isFinite(e.slowThresholdMs)&&e.slowThresholdMs>=0?Math.round(e.slowThresholdMs):300,this.requestTimeoutMs=typeof e.requestTimeoutMs=="number"&&Number.isFinite(e.requestTimeoutMs)&&e.requestTimeoutMs>0?Math.round(e.requestTimeoutMs):1e4,this.initialized=!0,this.attachGlobalListeners(),this.processQueue()}getApiKey(){return this.apiKey}getEndpoint(){return this.endpoint}getApmEndpoint(){return this.apmEndpoint}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}getRequestTimeoutMs(){return this.requestTimeoutMs}isInitialized(){return this.initialized}setUser(e){this.user=e?m(e):void 0}getUser(){return this.user}clearUser(){this.user=void 0}addBreadcrumb(e){if(!e||!e.type?.trim())return;let r={timestamp:e.timestamp||new Date().toISOString(),type:e.type.trim().slice(0,200),message:e.message?.slice(0,1e4),metadata:e.metadata?m(e.metadata):void 0};this.breadcrumbs.push(r),this.breadcrumbs.length>50&&(this.breadcrumbs=this.breadcrumbs.slice(-50))}getBreadcrumbs(){return this.breadcrumbs.map(e=>u(e))}clearBreadcrumbs(){this.breadcrumbs=[]}getContext(){return{environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs()}}isIngestUrl(e){if(!e)return!1;try{let r=new URL(this.endpoint),i=new URL(this.apmEndpoint),n=new URL(e,r.origin),s=n.origin,o=n.pathname.replace(/\/$/,""),a=r.pathname.replace(/\/$/,""),c=i.pathname.replace(/\/$/,"");return s===r.origin&&o===a||s===i.origin&&o===c}catch{return e.includes(this.endpoint)||e.includes(this.apmEndpoint)}}createRequestId(){return f("req")}createTraceId(){return f("trace")}createSpanId(){return f("span")}captureRequest(e){let r=w(e.method)||"GET",i=String(e.url||"").trim();if(!i)return Promise.resolve();let n=T(e.statusCode)??0,s=M(e.durationMs)??0,o={...e.metadata||{},...e.route!==void 0?{route:e.route}:{},...e.dbQueriesCount!==void 0?{dbQueriesCount:e.dbQueriesCount}:{},...e.slowQueryMs!==void 0?{slowQueryMs:e.slowQueryMs}:{},timestamp:new Date().toISOString()};return this.sendApm({type:"request_metric",method:r,url:i,statusCode:n,durationMs:s,browser:e.userAgent,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u(o)})}captureDbQuery(e){let r=String(e.operation||"").trim();if(!r)return Promise.resolve();let i=M(e.durationMs)??0,n={...e.metadata||{},operation:r,collection:e.collection||"Unknown",durationMs:i,timestamp:new Date().toISOString()};return this.sendApm({type:"db_query",message:`Database operation: ${r}`,url:e.url,method:"DB",durationMs:i,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u(n)})}captureMetric(e,r,i={},n={}){let s=D(e);if(!s)return Promise.resolve();let o;try{o=_(r)}catch{return Promise.resolve()}return this.sendApm({type:"custom_metric",metricName:s,metricValue:o,requestId:n.requestId,traceId:n.traceId,spanId:n.spanId,environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u({...i,timestamp:new Date().toISOString()})})}captureCustomMetric(e){return this.captureMetric(e.metricName,e.metricValue,e.metadata||{},{requestId:e.requestId,traceId:e.traceId,spanId:e.spanId})}captureError(e,r={}){let i=e?.message?.trim()||"Erro desconhecido",n={...r},s=w(n.method),o=T(n.statusCode??n.status),a=n.url!==void 0&&n.url!==null?String(n.url).trim():void 0;return delete n.method,delete n.statusCode,delete n.status,delete n.requestId,delete n.traceId,delete n.spanId,delete n.durationMs,this.sendError({type:"error",message:i,stackTrace:e?.stack||"",...a?{url:a}:{},...s?{method:s}:{},...o!==void 0?{statusCode:o}:{},environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u({...n,timestamp:new Date().toISOString()})})}captureException(e,r={}){let i=e instanceof Error?e:new Error(y(e));return this.captureError(i,r)}captureMessage(e,r={}){let i=String(e||"").trim();return i?this.sendApm({type:"message",message:i.slice(0,1e4),environment:this.environment,release:this.release,user:u(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:u({...r,timestamp:new Date().toISOString()})}):Promise.resolve()}async flush(){if(!(this.sendQueue.length===0&&!this.isProcessingQueue))return new Promise(e=>{this.flushResolvers.push(e),this.processQueue()})}attachGlobalListeners(){if(this.listenersAttached||typeof globalThis>"u")return;this.listenersAttached=!0;let e=globalThis;if(typeof e.ErrorUtils<"u"){let r=e.ErrorUtils.getGlobalHandler?.();e.ErrorUtils.setGlobalHandler?.((i,n)=>{this.captureError(i,{platform:"react-native",fatal:n}).finally(()=>{typeof r=="function"&&r(i,n)})})}if(typeof window<"u"&&typeof window.addEventListener=="function"){window.addEventListener("error",r=>{let i=r.error instanceof Error?r.error:new Error(r.message||"Erro global");this.captureError(i,{url:r.filename||window.location.href,line:r.lineno,column:r.colno,platform:"browser"})}),window.addEventListener("unhandledrejection",r=>{let i=r.reason instanceof Error?r.reason:new Error(y(r.reason));this.captureError(i,{platform:"browser",url:window.location.href})});return}typeof process<"u"&&typeof process.on=="function"&&(process.on("uncaughtException",r=>{this.captureError(r,{platform:"node"})}),process.on("unhandledRejection",r=>{this.captureException(r,{platform:"node"})}))}sendError(e){return this.enqueue(this.endpoint,e)}sendApm(e){return this.enqueue(this.apmEndpoint,e)}enqueue(e,r){if(!this.initialized||!this.apiKey)return Promise.resolve();let i={id:f("event"),endpoint:e,payload:u(r),resolve:()=>{}};return new Promise(n=>{i.resolve=n,this.sendQueue.push(i),this.processQueue()})}async processQueue(){if(!(this.isProcessingQueue||!this.initialized||!this.apiKey)){this.isProcessingQueue=!0;try{for(;this.sendQueue.length>0;){let e=this.sendQueue.shift();if(e)try{await this.sendToEndpoint(e.endpoint,e.payload)}finally{e.resolve()}}}finally{if(this.isProcessingQueue=!1,this.sendQueue.length===0){let e=this.flushResolvers.splice(0);for(let r of e)r()}this.sendQueue.length>0&&this.processQueue()}}}async sendToEndpoint(e,r){let i=typeof fetch=="function"?fetch:void 0;if(!i)return;let n=m(r),s,o;try{typeof AbortController<"u"&&(s=new AbortController,o=setTimeout(()=>{s?.abort()},this.requestTimeoutMs));let a=typeof window<"u"&&typeof window.document<"u",c={method:"POST",headers:{"content-type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(n),signal:s?.signal};if(a&&(c.keepalive=!0),!(await i(e,c)).ok)return}catch{return}finally{o!==void 0&&clearTimeout(o)}}},A="__DEVINSPECT_AUDIT_CORE_INSTANCE__",R=typeof globalThis<"u"?globalThis:{},d=R[A]||new g;R[A]=d;async function k(t,e,r={}){let i=r.nativeFetch||(typeof fetch=="function"?fetch:void 0);if(!i)throw new Error("fetch n\xE3o est\xE1 dispon\xEDvel.");let n=typeof t=="string"?t:t instanceof URL?t.toString():String(t.url||""),s=w(e?.method||(typeof t!="string"&&!(t instanceof URL)?t.method:"GET"))||"GET";if(n&&d.isIngestUrl(n))return i(t,e);let o=d.createRequestId(),a=d.createTraceId(),c=d.createSpanId(),h=new Headers(e?.headers||(typeof t!="string"&&!(t instanceof URL)?t.headers:void 0));h.set("x-devinspector-request-id",o),h.set("x-devinspector-trace-id",a),h.set("x-devinspector-span-id",c);let U={...e,headers:h},E=typeof performance<"u"?performance.now():Date.now();try{let p=await i(t,U),l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-E)),b=p.status>=400||l>=d.getSlowThresholdMs();return d.addBreadcrumb({type:"http",message:`${s} ${n}`,metadata:{phase:"complete",statusCode:p.status,durationMs:l,requestId:o,traceId:a,spanId:c}}),b&&d.captureRequest({method:s,url:n,statusCode:p.status,durationMs:l,userAgent:typeof navigator<"u"?navigator.userAgent:r.defaultUserAgent,requestId:o,traceId:a,spanId:c}),p}catch(p){let l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-E));d.addBreadcrumb({type:"http_error",message:`${s} ${n}`,metadata:{phase:"error",statusCode:0,durationMs:l,requestId:o,traceId:a,spanId:c}}),d.captureRequest({method:s,url:n,statusCode:0,durationMs:l,userAgent:typeof navigator<"u"?navigator.userAgent:r.defaultUserAgent,requestId:o,traceId:a,spanId:c});let b=p instanceof Error?p:new Error(y(p));throw d.captureError(b,{url:n,method:s,type:r.errorType||"network_error"}),p}}export{g as AuditCore,d as audit,k as coreAuditFetch};
|
package/dist/next.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var q=(r,e)=>{for(var t in e)h(r,t,{get:e[t],enumerable:!0})},R=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of x(e))!A.call(r,s)&&s!==t&&h(r,s,{get:()=>e[s],enumerable:!(n=E(e,s))||n.enumerable});return r};var T=r=>R(h({},"__esModule",{value:!0}),r);var j={};q(j,{audit:()=>i,auditFetch:()=>k,captureNextError:()=>w,initNextDevInspector:()=>_,withAuditAction:()=>C,withAuditApi:()=>D});module.exports=T(j);var b=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.slowThresholdMs=300;this.breadcrumbs=[];this.maxBreadcrumbs=50;this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),e.release&&(this.release=e.release),typeof e.slowThresholdMs=="number"&&e.slowThresholdMs>=0&&(this.slowThresholdMs=e.slowThresholdMs),this.initialized=!0,this.listenGlobalErrors()}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}generateId(e){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`${e}_${crypto.randomUUID()}`}catch{}return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,12)}`}createRequestId(){return this.generateId("req")}createTraceId(){return this.generateId("trace")}createSpanId(){return this.generateId("span")}setUser(e){this.user=this.truncate(e,2e3)}clearUser(){this.user=void 0}getUser(){return this.user}addBreadcrumb(e){let t={...e,timestamp:new Date().toISOString()},n=this.truncate(t,2e3);this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}clearBreadcrumbs(){this.breadcrumbs=[]}getBreadcrumbs(){return[...this.breadcrumbs]}getContext(){return{environment:this.environment,release:this.release,user:this.user,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,timestamp:new Date().toISOString()}}captureRequest(e){let t=this.getContext(),n={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({environment:t.environment,timestamp:t.timestamp,route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0},5e3)};this.send(n)}captureDbQuery(e){let t=this.getContext(),n=e.operation?.trim()||"query",s=e.collection?.trim()||"Unknown",o={type:"db_query",message:`Database operation [${n}]`,stackTrace:"",url:e.url||(typeof window<"u"?window.location.href:""),browser:typeof navigator<"u"?navigator.userAgent:"",method:n,durationMs:e.durationMs,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({...e.metadata,collection:s,operation:n,durationMs:e.durationMs,environment:t.environment,timestamp:t.timestamp},5e3)};this.send(o)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=typeof e.ErrorUtils.getGlobalHandler=="function"?e.ErrorUtils.getGlobalHandler():void 0;e.ErrorUtils.setGlobalHandler((n,s)=>{let o=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(o,{type:"react_native_error",isFatal:!!s}),t&&t(n,s)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let s=n instanceof Error?n:new Error(String(n));this.captureError(s,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"){let s=e;if(n.has(s))return"[Circular Reference]";if(n.add(s),Array.isArray(e))return e.map(a=>this.truncate(a,t,n));let o={};for(let[a,c]of Object.entries(e))o[a]=this.truncate(c,t,n);return o}return e}captureError(e,t={}){let n=e?.message||"Erro Desconhecido",s=e?.stack||"",o=this.getContext(),a=t.requestId,c=t.traceId,d=t.spanId,p={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(s,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:a,traceId:c,spanId:d,environment:o.environment,release:o.release,user:o.user,breadcrumbs:o.breadcrumbs,metadata:this.truncate({...t,environment:o.environment,release:o.release,timestamp:o.timestamp},5e3)};this.send(p)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n=this.getContext(),s={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:t.requestId,traceId:t.traceId,spanId:t.spanId,environment:n.environment,release:n.release,user:n.user,breadcrumbs:n.breadcrumbs,metadata:this.truncate({...t,level:"info",environment:n.environment,release:n.release,timestamp:n.timestamp},5e3)};this.send(s)}async send(e){if(this.initialized&&!(!this.apiKey||this.apiKey==="PENDING_API_KEY"))try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},g="__DEVINSPECT_AUDIT_CORE_INSTANCE__",M=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[g]||(r[g]=new b),r[g]},i=M();async function I(r,e,t){let n=t?.nativeFetch||(typeof window<"u"?window.fetch.bind(window):typeof globalThis<"u"?globalThis.fetch:fetch),s="";if(typeof r=="string"?s=r:r instanceof URL?s=r.toString():typeof r=="object"&&r!==null&&"url"in r&&(s=r.url),s&&i.isIngestUrl(s))return n(r,e);let o=e?.method||(typeof r=="object"&&r!==null&&"method"in r?r.method:"GET"),a=i.createRequestId(),c=i.createTraceId(),d=i.createSpanId(),p=new Headers(e?.headers||(typeof r=="object"&&r!==null&&"headers"in r?r.headers:void 0));p.set("x-devinspector-request-id",a),p.set("x-devinspector-trace-id",c),p.set("x-devinspector-span-id",d);let f={...e,headers:p},m=typeof performance<"u"?performance.now():Date.now();try{let u=await n(r,f),l=Math.round((typeof performance<"u"?performance.now():Date.now())-m),v=i.getSlowThresholdMs();return(u.status>=400||l>=v)&&i.captureRequest({method:o,url:s,statusCode:u.status,durationMs:l,route:s,requestId:a,traceId:c,spanId:d,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),i.addBreadcrumb({type:"http",message:`${o} ${s}`,metadata:{statusCode:u.status,durationMs:l,requestId:a,traceId:c,spanId:d}}),u}catch(u){let l=Math.round((typeof performance<"u"?performance.now():Date.now())-m);throw i.captureRequest({method:o,url:s,statusCode:0,durationMs:l,route:s,requestId:a,traceId:c,spanId:d,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),i.captureException(u instanceof Error?u:new Error(String(u)),{url:s,method:o,type:t?.errorType||"network_error",requestId:a,traceId:c,spanId:d}),i.addBreadcrumb({type:"http_error",message:`${o} ${s}`,metadata:{durationMs:l,requestId:a,traceId:c,spanId:d}}),u}}function _(r){i.init(r)}function w(r,e={}){let t=r instanceof Error?r:new Error(String(r));i.captureError(t,{framework:"Next.js",...e})}async function k(r,e){return I(r,e,{errorType:"nextjs_network_error"})}function D(r){return async function(...e){let t=typeof performance<"u"?performance.now():Date.now(),n=e[0],s=e[1],o=n?.method||"GET",a=n?.url||n?.nextUrl?.href||"/api",c=typeof n?.headers?.get=="function"?n.headers.get("user-agent")||"":n?.headers?.["user-agent"]||"",d=y(n,"x-devinspector-request-id")||i.createRequestId(),p=y(n,"x-devinspector-trace-id")||i.createTraceId(),f=y(n,"x-devinspector-span-id")||i.createSpanId();i.addBreadcrumb({type:"http",message:`${o} ${a}`,metadata:{framework:"Next.js",phase:"start",requestId:d,traceId:p,spanId:f}});try{let m=await r(...e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-t),l=m?.status||s?.statusCode||200;return(l>=400||u>=300)&&i.captureRequest({method:o,url:a,statusCode:l,durationMs:u,route:a,userAgent:c,requestId:d,traceId:p,spanId:f}),i.addBreadcrumb({type:"http",message:`${o} ${a}`,metadata:{framework:"Next.js",phase:"complete",statusCode:l,durationMs:u,requestId:d,traceId:p,spanId:f}}),m}catch(m){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-t);throw i.captureRequest({method:o,url:a,statusCode:500,durationMs:u,route:a,userAgent:c,requestId:d,traceId:p,spanId:f}),i.addBreadcrumb({type:"http_error",message:`${o} ${a}`,metadata:{framework:"Next.js",statusCode:500,durationMs:u,requestId:d,traceId:p,spanId:f}}),w(m,{url:a,method:o,type:"api_route_error",requestId:d,traceId:p,spanId:f}),m}}}function C(r,e){return(async(...t)=>{let n=typeof performance<"u"?performance.now():Date.now(),s=i.createRequestId(),o=i.createTraceId(),a=i.createSpanId();i.addBreadcrumb({type:"server_action",message:r,metadata:{framework:"Next.js",phase:"start",requestId:s,traceId:o,spanId:a}});try{let c=await e(...t),d=Math.round((typeof performance<"u"?performance.now():Date.now())-n);return d>=300&&i.captureRequest({method:"ACTION",url:r,statusCode:200,durationMs:d,route:r,requestId:s,traceId:o,spanId:a}),i.addBreadcrumb({type:"server_action",message:r,metadata:{framework:"Next.js",phase:"complete",statusCode:200,durationMs:d,requestId:s,traceId:o,spanId:a}}),c}catch(c){let d=Math.round((typeof performance<"u"?performance.now():Date.now())-n);throw i.captureRequest({method:"ACTION",url:r,statusCode:500,durationMs:d,route:r,requestId:s,traceId:o,spanId:a}),i.addBreadcrumb({type:"server_action_error",message:r,metadata:{framework:"Next.js",statusCode:500,durationMs:d,requestId:s,traceId:o,spanId:a}}),w(c,{actionName:r,type:"server_action_error",requestId:s,traceId:o,spanId:a}),c}})}function y(r,e){if(!r?.headers)return;if(typeof r.headers.get=="function")return r.headers.get(e)||void 0;let t=r.headers[e]||r.headers[e.toLowerCase()];return Array.isArray(t)?t[0]:t?String(t):void 0}0&&(module.exports={audit,auditFetch,captureNextError,initNextDevInspector,withAuditAction,withAuditApi});
|
|
1
|
+
"use strict";var w=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var P=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},N=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!C.call(t,n)&&n!==r&&w(t,n,{get:()=>e[n],enumerable:!(s=D(e,n))||s.enumerable});return t};var O=t=>N(w({},"__esModule",{value:!0}),t);var K={};P(K,{audit:()=>a,auditFetch:()=>j,captureNextError:()=>M,initNextDevInspector:()=>$,withAuditAction:()=>F,withAuditApi:()=>G});module.exports=O(K);var R="https://api.devinspector.com.br/api/ingest/track",A="https://api.devinspector.com.br/api/ingest/apm";var Q=["password","senha","token","authorization","auth","bearer","credit_card","creditcard","cartao","cvv","cpf","rg","secret","private_key","privatekey"];function B(t){let e=t.toLowerCase().replace(/[\s-]/g,"_");return Q.some(r=>e.includes(r))}function g(t,e=0,r=new WeakSet){if(t==null)return t;if(typeof t=="string")return t.length>1e4?`${t.slice(0,1e4)}...[truncated]`:t;if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="bigint")return String(t);if(typeof t=="function")return"[Function]";if(e>=6)return"[MaxDepth]";if(typeof t!="object")return String(t);if(r.has(t))return"[Circular]";r.add(t);try{if(Array.isArray(t))return t.slice(0,100).map(i=>g(i,e+1,r));let s=t,n={};for(let[i,o]of Object.entries(s)){if(B(i)){n[i]="[REDACTED]";continue}n[i]=g(o,e+1,r)}return n}finally{r.delete(t)}}function v(t){if(t instanceof Error)return t.message||"Erro desconhecido";if(typeof t=="string")return t||"Erro desconhecido";try{let e=g(t);return typeof e=="string"?e||"Erro desconhecido":JSON.stringify(e)||"Erro desconhecido"}catch{return"Erro desconhecido"}}function I(t){return t&&String(t).trim().toUpperCase()||void 0}function S(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.round(t)}function U(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.max(0,Math.round(t))}function L(t){return String(t??"").trim().slice(0,200)}function z(t){let e=Number(t);if(!Number.isFinite(e))throw new Error("metricValue deve ser um n\xFAmero finito.");return e}function y(t){let e=typeof globalThis<"u"?globalThis.crypto:void 0;return e&&typeof e.randomUUID=="function"?`${t}-${e.randomUUID()}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,12)}`}function p(t){return g(t)}var E=class{constructor(){this.apiKey="";this.endpoint=R;this.apmEndpoint=A;this.environment="production";this.slowThresholdMs=300;this.requestTimeoutMs=1e4;this.breadcrumbs=[];this.initialized=!1;this.listenersAttached=!1;this.sendQueue=[];this.isProcessingQueue=!1;this.flushResolvers=[]}init(e){if(!e?.apiKey?.trim())throw new Error("DevInspector: apiKey \xE9 obrigat\xF3rio.");this.apiKey=e.apiKey.trim(),this.endpoint=e.endpoint?.trim()||R,this.apmEndpoint=e.apmEndpoint?.trim()||A,this.environment=e.environment?.trim()||"production",this.release=e.release?.trim()||void 0,this.slowThresholdMs=typeof e.slowThresholdMs=="number"&&Number.isFinite(e.slowThresholdMs)&&e.slowThresholdMs>=0?Math.round(e.slowThresholdMs):300,this.requestTimeoutMs=typeof e.requestTimeoutMs=="number"&&Number.isFinite(e.requestTimeoutMs)&&e.requestTimeoutMs>0?Math.round(e.requestTimeoutMs):1e4,this.initialized=!0,this.attachGlobalListeners(),this.processQueue()}getApiKey(){return this.apiKey}getEndpoint(){return this.endpoint}getApmEndpoint(){return this.apmEndpoint}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}getRequestTimeoutMs(){return this.requestTimeoutMs}isInitialized(){return this.initialized}setUser(e){this.user=e?g(e):void 0}getUser(){return this.user}clearUser(){this.user=void 0}addBreadcrumb(e){if(!e||!e.type?.trim())return;let r={timestamp:e.timestamp||new Date().toISOString(),type:e.type.trim().slice(0,200),message:e.message?.slice(0,1e4),metadata:e.metadata?g(e.metadata):void 0};this.breadcrumbs.push(r),this.breadcrumbs.length>50&&(this.breadcrumbs=this.breadcrumbs.slice(-50))}getBreadcrumbs(){return this.breadcrumbs.map(e=>p(e))}clearBreadcrumbs(){this.breadcrumbs=[]}getContext(){return{environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs()}}isIngestUrl(e){if(!e)return!1;try{let r=new URL(this.endpoint),s=new URL(this.apmEndpoint),n=new URL(e,r.origin),i=n.origin,o=n.pathname.replace(/\/$/,""),d=r.pathname.replace(/\/$/,""),u=s.pathname.replace(/\/$/,"");return i===r.origin&&o===d||i===s.origin&&o===u}catch{return e.includes(this.endpoint)||e.includes(this.apmEndpoint)}}createRequestId(){return y("req")}createTraceId(){return y("trace")}createSpanId(){return y("span")}captureRequest(e){let r=I(e.method)||"GET",s=String(e.url||"").trim();if(!s)return Promise.resolve();let n=S(e.statusCode)??0,i=U(e.durationMs)??0,o={...e.metadata||{},...e.route!==void 0?{route:e.route}:{},...e.dbQueriesCount!==void 0?{dbQueriesCount:e.dbQueriesCount}:{},...e.slowQueryMs!==void 0?{slowQueryMs:e.slowQueryMs}:{},timestamp:new Date().toISOString()};return this.sendApm({type:"request_metric",method:r,url:s,statusCode:n,durationMs:i,browser:e.userAgent,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p(o)})}captureDbQuery(e){let r=String(e.operation||"").trim();if(!r)return Promise.resolve();let s=U(e.durationMs)??0,n={...e.metadata||{},operation:r,collection:e.collection||"Unknown",durationMs:s,timestamp:new Date().toISOString()};return this.sendApm({type:"db_query",message:`Database operation: ${r}`,url:e.url,method:"DB",durationMs:s,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p(n)})}captureMetric(e,r,s={},n={}){let i=L(e);if(!i)return Promise.resolve();let o;try{o=z(r)}catch{return Promise.resolve()}return this.sendApm({type:"custom_metric",metricName:i,metricValue:o,requestId:n.requestId,traceId:n.traceId,spanId:n.spanId,environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p({...s,timestamp:new Date().toISOString()})})}captureCustomMetric(e){return this.captureMetric(e.metricName,e.metricValue,e.metadata||{},{requestId:e.requestId,traceId:e.traceId,spanId:e.spanId})}captureError(e,r={}){let s=e?.message?.trim()||"Erro desconhecido",n={...r},i=I(n.method),o=S(n.statusCode??n.status),d=n.url!==void 0&&n.url!==null?String(n.url).trim():void 0;return delete n.method,delete n.statusCode,delete n.status,delete n.requestId,delete n.traceId,delete n.spanId,delete n.durationMs,this.sendError({type:"error",message:s,stackTrace:e?.stack||"",...d?{url:d}:{},...i?{method:i}:{},...o!==void 0?{statusCode:o}:{},environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p({...n,timestamp:new Date().toISOString()})})}captureException(e,r={}){let s=e instanceof Error?e:new Error(v(e));return this.captureError(s,r)}captureMessage(e,r={}){let s=String(e||"").trim();return s?this.sendApm({type:"message",message:s.slice(0,1e4),environment:this.environment,release:this.release,user:p(this.user),breadcrumbs:this.getBreadcrumbs(),metadata:p({...r,timestamp:new Date().toISOString()})}):Promise.resolve()}async flush(){if(!(this.sendQueue.length===0&&!this.isProcessingQueue))return new Promise(e=>{this.flushResolvers.push(e),this.processQueue()})}attachGlobalListeners(){if(this.listenersAttached||typeof globalThis>"u")return;this.listenersAttached=!0;let e=globalThis;if(typeof e.ErrorUtils<"u"){let r=e.ErrorUtils.getGlobalHandler?.();e.ErrorUtils.setGlobalHandler?.((s,n)=>{this.captureError(s,{platform:"react-native",fatal:n}).finally(()=>{typeof r=="function"&&r(s,n)})})}if(typeof window<"u"&&typeof window.addEventListener=="function"){window.addEventListener("error",r=>{let s=r.error instanceof Error?r.error:new Error(r.message||"Erro global");this.captureError(s,{url:r.filename||window.location.href,line:r.lineno,column:r.colno,platform:"browser"})}),window.addEventListener("unhandledrejection",r=>{let s=r.reason instanceof Error?r.reason:new Error(v(r.reason));this.captureError(s,{platform:"browser",url:window.location.href})});return}typeof process<"u"&&typeof process.on=="function"&&(process.on("uncaughtException",r=>{this.captureError(r,{platform:"node"})}),process.on("unhandledRejection",r=>{this.captureException(r,{platform:"node"})}))}sendError(e){return this.enqueue(this.endpoint,e)}sendApm(e){return this.enqueue(this.apmEndpoint,e)}enqueue(e,r){if(!this.initialized||!this.apiKey)return Promise.resolve();let s={id:y("event"),endpoint:e,payload:p(r),resolve:()=>{}};return new Promise(n=>{s.resolve=n,this.sendQueue.push(s),this.processQueue()})}async processQueue(){if(!(this.isProcessingQueue||!this.initialized||!this.apiKey)){this.isProcessingQueue=!0;try{for(;this.sendQueue.length>0;){let e=this.sendQueue.shift();if(e)try{await this.sendToEndpoint(e.endpoint,e.payload)}finally{e.resolve()}}}finally{if(this.isProcessingQueue=!1,this.sendQueue.length===0){let e=this.flushResolvers.splice(0);for(let r of e)r()}this.sendQueue.length>0&&this.processQueue()}}}async sendToEndpoint(e,r){let s=typeof fetch=="function"?fetch:void 0;if(!s)return;let n=g(r),i,o;try{typeof AbortController<"u"&&(i=new AbortController,o=setTimeout(()=>{i?.abort()},this.requestTimeoutMs));let d=typeof window<"u"&&typeof window.document<"u",u={method:"POST",headers:{"content-type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(n),signal:i?.signal};if(d&&(u.keepalive=!0),!(await s(e,u)).ok)return}catch{return}finally{o!==void 0&&clearTimeout(o)}}},q="__DEVINSPECT_AUDIT_CORE_INSTANCE__",_=typeof globalThis<"u"?globalThis:{},a=_[q]||new E;_[q]=a;async function k(t,e,r={}){let s=r.nativeFetch||(typeof fetch=="function"?fetch:void 0);if(!s)throw new Error("fetch n\xE3o est\xE1 dispon\xEDvel.");let n=typeof t=="string"?t:t instanceof URL?t.toString():String(t.url||""),i=I(e?.method||(typeof t!="string"&&!(t instanceof URL)?t.method:"GET"))||"GET";if(n&&a.isIngestUrl(n))return s(t,e);let o=a.createRequestId(),d=a.createTraceId(),u=a.createSpanId(),m=new Headers(e?.headers||(typeof t!="string"&&!(t instanceof URL)?t.headers:void 0));m.set("x-devinspector-request-id",o),m.set("x-devinspector-trace-id",d),m.set("x-devinspector-span-id",u);let f={...e,headers:m},h=typeof performance<"u"?performance.now():Date.now();try{let c=await s(t,f),l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-h)),b=c.status>=400||l>=a.getSlowThresholdMs();return a.addBreadcrumb({type:"http",message:`${i} ${n}`,metadata:{phase:"complete",statusCode:c.status,durationMs:l,requestId:o,traceId:d,spanId:u}}),b&&a.captureRequest({method:i,url:n,statusCode:c.status,durationMs:l,userAgent:typeof navigator<"u"?navigator.userAgent:r.defaultUserAgent,requestId:o,traceId:d,spanId:u}),c}catch(c){let l=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-h));a.addBreadcrumb({type:"http_error",message:`${i} ${n}`,metadata:{phase:"error",statusCode:0,durationMs:l,requestId:o,traceId:d,spanId:u}}),a.captureRequest({method:i,url:n,statusCode:0,durationMs:l,userAgent:typeof navigator<"u"?navigator.userAgent:r.defaultUserAgent,requestId:o,traceId:d,spanId:u});let b=c instanceof Error?c:new Error(v(c));throw a.captureError(b,{url:n,method:i,type:r.errorType||"network_error"}),c}}function $(t){a.init(t)}function M(t,e={}){let r=t instanceof Error?t:new Error(String(t));a.captureError(r,{framework:"Next.js",...e})}async function j(t,e){return k(t,e,{errorType:"nextjs_network_error"})}function G(t){return async function(...e){let r=typeof performance<"u"?performance.now():Date.now(),s=e[0],n=e[1],i=s?.method||"GET",o=s?.url||s?.nextUrl?.href||"/api",d=typeof s?.headers?.get=="function"?s.headers.get("user-agent")||"":s?.headers?.["user-agent"]||"",u=T(s,"x-devinspector-request-id")||a.createRequestId(),m=T(s,"x-devinspector-trace-id")||a.createTraceId(),f=T(s,"x-devinspector-span-id")||a.createSpanId();a.addBreadcrumb({type:"http",message:`${i} ${o}`,metadata:{framework:"Next.js",phase:"start",requestId:u,traceId:m,spanId:f}});try{let h=await t(...e),c=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-r)),l=Number(h?.status??n?.statusCode??200)||200;return(l>=400||c>=a.getSlowThresholdMs())&&a.captureRequest({method:i,url:o,statusCode:l,durationMs:c,route:o,userAgent:d,requestId:u,traceId:m,spanId:f}),a.addBreadcrumb({type:"http",message:`${i} ${o}`,metadata:{framework:"Next.js",phase:"complete",statusCode:l,durationMs:c,requestId:u,traceId:m,spanId:f}}),h}catch(h){let c=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-r));throw a.captureRequest({method:i,url:o,statusCode:500,durationMs:c,route:o,userAgent:d,requestId:u,traceId:m,spanId:f}),a.addBreadcrumb({type:"http_error",message:`${i} ${o}`,metadata:{framework:"Next.js",statusCode:500,durationMs:c,requestId:u,traceId:m,spanId:f}}),M(h,{url:o,method:i,type:"api_route_error",requestId:u,traceId:m,spanId:f}),h}}}function F(t,e){return(async(...r)=>{let s=typeof performance<"u"?performance.now():Date.now(),n=a.createRequestId(),i=a.createTraceId(),o=a.createSpanId();a.addBreadcrumb({type:"server_action",message:t,metadata:{framework:"Next.js",phase:"start",requestId:n,traceId:i,spanId:o}});try{let d=await e(...r),u=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-s));return u>=a.getSlowThresholdMs()&&a.captureRequest({method:"ACTION",url:t,statusCode:200,durationMs:u,route:t,requestId:n,traceId:i,spanId:o}),a.addBreadcrumb({type:"server_action",message:t,metadata:{framework:"Next.js",phase:"complete",statusCode:200,durationMs:u,requestId:n,traceId:i,spanId:o}}),d}catch(d){let u=Math.max(0,Math.round((typeof performance<"u"?performance.now():Date.now())-s));throw a.captureRequest({method:"ACTION",url:t,statusCode:500,durationMs:u,route:t,requestId:n,traceId:i,spanId:o}),a.addBreadcrumb({type:"server_action_error",message:t,metadata:{framework:"Next.js",statusCode:500,durationMs:u,requestId:n,traceId:i,spanId:o}}),M(d,{actionName:t,type:"server_action_error",requestId:n,traceId:i,spanId:o}),d}})}function T(t,e){if(!t?.headers)return;if(typeof t.headers.get=="function")return t.headers.get(e)||void 0;let r=t.headers[e]??t.headers[e.toLowerCase()];return Array.isArray(r)?r[0]:r?String(r):void 0}0&&(module.exports={audit,auditFetch,captureNextError,initNextDevInspector,withAuditAction,withAuditApi});
|